如何在不将其显示在TVideoWindow上的情况下使用Delphi/DSPack捕获帧? [英] How to capture frames using Delphi/DSPack without displaying it on TVideoWindow?

查看:397
本文介绍了如何在不将其显示在TVideoWindow上的情况下使用Delphi/DSPack捕获帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;

推荐答案

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捕获帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆