如果在主机选项卡不可见时启动图形 (TVideoWindow),DirectShow 渲染窗口将显示黑色

发布于 2024-12-26 02:07:41 字数 281 浏览 2 评论 0原文

我有一个使用 DirectShow DSPACK 组件套件的 Delphi 6 应用程序。它有一个 TVideoWindow 组件,可以渲染过滤器图表中的图像。 TVideoWindow 组件位于页面组件的选项卡上。如果当我运行过滤器图表时选项卡可见,则视频显示得很好。另外,我可以切换到另一个选项卡并返回,视频仍然很好。但是,如果我在选项卡不可见时运行过滤器图表,那么当我切换到该选项卡时,视频窗口区域将为黑色。我尝试切换到另一个选项卡并返回,最小化主机窗体并恢复它,它保持黑色。我想知道这是否是窗口/组件句柄生命周期问题?我该如何解决这个问题?

I have a Delphi 6 application that uses the DirectShow DSPACK component suite. It has a TVideoWindow component that will render the images from a filter graph. The TVideoWindow component is on a Tab in a page component. If the Tab is visible when I run the Filter Graph the video shows just fine. Also, I can switch to another Tab and come back and the video is still fine. However, if I run the Filter Graph when the Tab is not visible, then when I switch to that Tab the video window area is black. I tried switching to another Tab and back, minimizing the host form and restoring it, and it stays black. I am wondering if this is a window/component handle life-cycle problem? How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌梦深 2025-01-02 02:07:41

直接使用 COM 对象(例如将 EVR 设置为随后显示的隐藏面板)时,不会发生此问题。我建议花时间摆脱 TVideoWindow 并直接使用 VMR9 和 EVR 等渲染器会更有效率。您不必摆脱 DSPack 即可执行此操作,请

  FDisplayControl: IMFVideoDisplayControl;
  FEVR: IBaseFilter;
  R: TNormalizedRect;
  R: TRect;

  hr := Succeeded(CoCreateInstance(CLSID_EnhancedVideoRenderer, nil, CLSCTX_INPROC, IID_IBaseFilter, FEVR));
  if (hr <> S_OK) then
  begin
    showmessage(GetErrorString(hr) + ' (Could not create the enhanced video renderer : ' + inttohex(hr,8) + ')');
    Exit;
  end;
  (FilterGraph as IFilterGraph2).AddFilter().AddFilter(FEVR, PWideChar(WideString('EVR')));
  (FEVR as IMFGetService).GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, FDisplayControl);
  FDisplayControl.SetVideoWindow(Panel.Handle);
  NR.Left := 0;
  NR.Top := 0;
  NR.Right := 1;
  NR.Bottom := 1;
  R := ClientRect;
  FDisplayControl.SetVideoPosition(@nr, @r);
  FDisplayControl.SetAspectRatioMode(MFVideoARMode_None);

注意:上述内容需要 EVR.pas

This problem does not happen when using COM objects directly such as setting the EVR to a hidden Panel that is subsequently shown. I'd suggest that time spent getting rid of the TVideoWindow and using renders such as the VMR9 and EVR directly would be more productive. You don't have to get rid of DSPack to do this, something along the lines of

  FDisplayControl: IMFVideoDisplayControl;
  FEVR: IBaseFilter;
  R: TNormalizedRect;
  R: TRect;

  hr := Succeeded(CoCreateInstance(CLSID_EnhancedVideoRenderer, nil, CLSCTX_INPROC, IID_IBaseFilter, FEVR));
  if (hr <> S_OK) then
  begin
    showmessage(GetErrorString(hr) + ' (Could not create the enhanced video renderer : ' + inttohex(hr,8) + ')');
    Exit;
  end;
  (FilterGraph as IFilterGraph2).AddFilter().AddFilter(FEVR, PWideChar(WideString('EVR')));
  (FEVR as IMFGetService).GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, FDisplayControl);
  FDisplayControl.SetVideoWindow(Panel.Handle);
  NR.Left := 0;
  NR.Top := 0;
  NR.Right := 1;
  NR.Bottom := 1;
  R := ClientRect;
  FDisplayControl.SetVideoPosition(@nr, @r);
  FDisplayControl.SetAspectRatioMode(MFVideoARMode_None);

Note: the above requires EVR.pas

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文