您可以将Elgato的HDMIComponent Game Capture HD用作C#中的视频输入设备吗?



我们想知道是否有可能从Elgato的Game capture HD(或类似的东西-模型/品牌无关紧要)捕获视频流并使用c#将其显示在窗口中。我们没有发现任何关于使用该产品的信息,除了它自己的软件,我们也没有发现任何其他硬件可以捕获这样的东西。

同样,我们的目标只是让一个带有Component Out的设备出现在屏幕上的窗口中,仅此而已。没有录音,没有截屏,没有叠加,什么都没有。只是纯粹的"现场"视频。

我已经找了几个月了,一无所获,所以我想我应该把这个扔给so社区。

查找已注册的视频捕获DirectShow过滤器,您可以通过其GUID加载它。它将在Game Capture HD 1.2.1安装时安装。如有问题请联系Elgato支持。

看看这个Github项目。它似乎展示了如何在c++ DirectShow应用程序中使用Elgato的Game Capture HD作为捕获设备。同样的方法应该适用于c#项目。

我知道这是一个老问题,但万一有人偶然发现它是很容易使用c#中的Elgato捕获卡的视频流与DirectShow。下面是一个创建简单图形并预览Elgato视频流的示例。

using DirectShowLib;
DsROTEntry rot; //Used for remotely connecting to graph
IFilterGraph2 graph;
ICaptureGraphBuilder2 captureGraph;
IBaseFilter elgatoFilter;
IBaseFilter smartTeeFilter;
IBaseFilter videoRendererFilter;
Size videoSize;
//Set the video size to use for capture and recording
videoSize = new Size(1280, 720);
//Initialize filter graph and capture graph
graph = (IFilterGraph2)new FilterGraph();
captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
captureGraph.SetFiltergraph(graph);
rot = new DsROTEntry(graph);
//Create filter for Elgato
Guid elgatoGuid = new Guid("39F50F4C-99E1-464A-B6F9-D605B4FB5918");
Type comType = Type.GetTypeFromCLSID(elgatoGuid);
elgatoFilter = (IBaseFilter)Activator.CreateInstance(comType);
graph.AddFilter(elgatoFilter, "Elgato Video Capture Filter");
//Create smart tee filter, add to graph, connect Elgato's video out to smart tee in
smartTeeFilter = (IBaseFilter)new SmartTee();
graph.AddFilter(smartTeeFilter, "Smart Tee");
IPin outPin = GetPin(PinDirection.Output, "Video", elgatoFilter);
IPin inPin = GetPin(PinDirection.Input, smartTeeFilter);
graph.Connect(outPin, inPin);
//Create video renderer filter, add it to graph, connect smartTee Preview pin to video renderer's input pin
videoRendererFilter = (IBaseFilter)new VideoRenderer();
graph.AddFilter(videoRendererFilter, "Video Renderer");
outPin = GetPin(PinDirection.Output, "Preview", smartTeeFilter);
inPin = GetPin(PinDirection.Input, videoRendererFilter);
graph.Connect(outPin, inPin);
//Render stream from video renderer
captureGraph.RenderStream(PinCategory.Preview, MediaType.Video, videoRendererFilter, null, null);
//Set the video preview to be the videoFeed panel
IVideoWindow vw = (IVideoWindow)graph;
vw.put_Owner(videoFeed.Handle);
vw.put_MessageDrain(this.Handle);
vw.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
vw.SetWindowPosition(0, 0, 1280, 720);
//Start the preview
mediaControl = graph as IMediaControl;
mediaControl.Run();
private IPin GetPin(PinDirection pinDir, IBaseFilter filter)
{
    IEnumPins epins;
    int hr = filter.EnumPins(out epins);
    if (hr < 0)
        return null;
    IntPtr fetched = Marshal.AllocCoTaskMem(4);
    IPin[] pins = new IPin[1];
    epins.Reset();
    while (epins.Next(1, pins, fetched) == 0)
    {
        PinInfo pinfo;
        pins[0].QueryPinInfo(out pinfo);
        bool found = (pinfo.dir == pinDir);
        DsUtils.FreePinInfo(pinfo);
        if (found)
            return pins[0];
    }
    return null;
}
private IPin GetPin(PinDirection pinDir, string name, IBaseFilter filter)
{
    IEnumPins epins;
    int hr = filter.EnumPins(out epins);
    if (hr < 0)
        return null;
    IntPtr fetched = Marshal.AllocCoTaskMem(4);
    IPin[] pins = new IPin[1];
    epins.Reset();
    while (epins.Next(1, pins, fetched) == 0)
    {
        PinInfo pinfo;
        pins[0].QueryPinInfo(out pinfo);
        bool found = (pinfo.dir == pinDir && pinfo.name == name);
        DsUtils.FreePinInfo(pinfo);
        if (found)
            return pins[0];
    }
    return null;
}

最新更新