问题描述
DSpack具有示例代码,可播放兼容DirectShow的视频设备并同时捕获视频帧. TVideoWindow附加到FilterGraph上以显示视频(Firgure-1).如果删除TVideoWindow,则操作系统(Windows)将自动启动ActiveMovie并将视频显示在单独的窗口中(图2).
DSpack has example code to play a DirectShow compatible video device and to capture the video frames simultaneously. A TVideoWindow is attached to the FilterGraph to display the video (Firgure-1). If you remove the TVideoWindow, then the Operating System (Windows) will automatically bring up ActiveMovie and display the video on a separate window (Figure-2).
是否可以使用DSPack捕获视频帧而无需使用任何GUI组件并且不显示视频?
Is there a way to use DSPack to capture video frames without using any of the GUI components and without displaying the video?
DSPack论坛上有一些有关NullRenderer过滤器的提及,但没有有关如何使用它的文档或示例.如果直接在GraphEdit中用Null Render手动替换Video Renderer,则看起来可以实现这一点(图3).
DSPack forum has some mention about NullRenderer filter but there is no documentation or examples on how to use it. Looks like we can achieve that if we manually replace the Video Renderer with Null Render directly in the GraphEdit (Figure-3).
如何通过在代码内进行所有操作来达到图3所示的结果? DSPack没有说明如何创建Null渲染器.
How can we achive the result shown in Figure-3 by doing all manipulations within the code? DSPack does not explain how to create a Null Renderer.
Figure-1: The graph of the default example code
Figure-2: Shows what happens if I remove the TVideoWindow
Figure-3: Shows what happens if I replace Video Renderer with a
Null Renderer and manually connect them in the GraphEdit.
这是我到目前为止所做的(到目前为止)
在filterGraph.Play;
procedure TForm1.ReassignSampleGrabberOutput;
var
nullRenderer : IBaseFilter;
nullRendererPins: IEnumPins;
nullRendererPin : IPin;
graph: IGraphBuilder;
begin
nullRenderer := CreateComObject(CLSID_NullRenderer) as IBaseFilter;
FilterGraph1.QueryInterface(IID_IGraphBuilder, graph);
graph.AddFilter(nullRenderer, 'Null Renderer');
nullRenderer.EnumPins(nullRendererPins);
nullRendererPins.Reset;
if nullRendererPins.Next(1, nullRendererPin, nil) = S_OK then
begin
//SampleGrabber1.OutPutPin.Disconnect;
//SampleGrabber1.OutPutPin.Connect(nullRendererPin, nil);
graph.Disconnect(SampleGrabber1.OutPutPin);
graph.FindFilterByName('Video Renderer', filter);
graph.RemoveFilter(filter);
graph.Connect(SampleGrabber1.OutPutPin, nullRendererPin);
end;
end;
推荐答案
是标准的过滤器/类.在代码中,您只需要实例化它(CoCreateInstance
),将其添加到图形中,然后将其输入引脚连接到Sample Grabber的未连接输出引脚即可.
Null Renderer Filter
is a standard filter/class. In code you just need to instantiate it (CoCreateInstance
), add it to the graph, and connect its input pin to the unconnected output pin of the Sample Grabber.
在Delphi/DSPack中,它应该是这样的:
In Delphi/DSPack it should be like this:
Renderer := CreateComObject(CLSID_NullRenderer) as IBaseFilter;
这篇关于如何在不将其显示在TVideoWindow上的情况下使用Delphi/DSPack捕获帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!