本文介绍了如何使用直接Show.net图书馆合作,将屏幕捕捉的视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用直接Show.net库使屏幕捕获的视频?我读的MSDN直接显示文件,并找到在以下code更改视频源设备的方式。这code得到Mobiola®WebCamera的视频设备。
公共IBaseFilter FindCaptureDevice()
{
INT HR = 0;
IEnumMoniker classEnum中= NULL;
的IMoniker []名字=新的IMoniker [1];
对象源= NULL;
//创建系统设备枚举器
ICreateDevEnum devEnum =(ICreateDevEnum)新CreateDevEnum();
//创建一个枚举视频捕获设备
HR = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice,classEnum中出,0);
DsError.ThrowExceptionForHR(小时);
//设备枚举没有更多的需要
对Marshal.ReleaseComObject(devEnum);
//如果没有枚举为所请求的类型,则
// CreateClassEnumerator会成功,但classEnum中将为NULL。
如果(classEnum中== NULL)
{
抛出新ApplicationException的(未检测到视频采集设备。\ r \ñ\ r \ N+
此示例需要视频捕捉设备,如USB摄像头,\ r \ N+
要安装并正常工作的样品将立即关闭。);
}
如果(classEnum.Next(moniker.Length,绰号,IntPtr.Zero)== 0)
{
GUID IID = typeof运算(IBaseFilter).GUID;
绰号[0] .BindToObject(NULL,NULL,裁判IID,出源);
}
其他
{
抛出新ApplicationException的(无法访问视频采集设备!);
}
Marshal.ReleaseComObject的(绰号[0]);
对Marshal.ReleaseComObject(classEnum中);
返回(IBaseFilter)来源;
}
解决方案
您需要一个过滤器捕获屏幕,并发送视频往下流。在DirectShow的SDK中有一个叫PushSource样品过滤器和里边有PushSourceDesktop。编译它,并插入到图形作为源过滤器。
How to make screen capture video using Direct Show.net Library?I read msdn Direct show document and find the way to change video source device within the following code.This code got webcamera as video device.
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;
}
解决方案
You need a filter which captures screen and sends the video down the stream. In DirectShow SDK there is a sample filter called PushSource and inside there is PushSourceDesktop. Compile it and insert into your graph as a source filter.
这篇关于如何使用直接Show.net图书馆合作,将屏幕捕捉的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!