1
如何使用Direct Show.net库制作屏幕截图视频? 我读取msdn直接显示文件,并找到在以下代码中更改视频源设备的方式。 此代码将webcamera作为视频设备。如何使用Direct Show.net库制作截屏视频?
public IBaseFilter FindCaptureDevice()
{
int hr = 0;
IEnumMoniker classEnum = null;
IMoniker[] moniker = new IMoniker[1];
object source = null;
// Create the system device enumerator
ICreateDevEnum devEnum = (ICreateDevEnum) new CreateDevEnum();
// Create an enumerator for the video capture devices
hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum,0);
DsError.ThrowExceptionForHR(hr);
// The device enumerator is no more needed
Marshal.ReleaseComObject(devEnum);
// If there are no enumerators for the requested type, then
// CreateClassEnumerator will succeed, but classEnum will be NULL.
if (classEnum == null)
{
throw new ApplicationException("No video capture device was detected.\r\n\r\n" +
"This sample requires a video capture device, such as a USB WebCam,\r\n" +
"to be installed and working properly. The sample will now close.");
}
if (classEnum.Next (moniker.Length, moniker, IntPtr.Zero) == 0)
{
Guid iid = typeof(IBaseFilter).GUID;
moniker[0].BindToObject(null, null, ref iid, out source);
}
else
{
throw new ApplicationException("Unable to access video capture device!");
}
Marshal.ReleaseComObject(moniker[0]);
Marshal.ReleaseComObject(classEnum);
return (IBaseFilter) source;
}
我发现PushSourceDestop并编译,我会得到PushSourceDestop.obj。如何将它插入我的项目和图表?我是这个新手。谢谢 – 2010-11-08 09:14:36