简体   繁体   English

将 DirectShow 与 Direct2D 结合使用

[英]Using DirectShow with Direct2D

I have a windows only Direct2D application and would like to implement a video playback system for cutscenes.我有一个仅限 Windows 的 Direct2D 应用程序,并希望为过场动画实现一个视频播放系统。 These files are mp4 but the format can be changed, if need be.这些文件是 mp4,但如果需要,可以更改格式。

It seems like DirectShow is the advised way to render video/audio on windows.似乎 DirectShow 是在 Windows 上呈现视频/音频的建议方法。

Now how do I let DirectShow render the video frames to my Direct2D render target?现在如何让 DirectShow 将视频帧渲染到我的 Direct2D 渲染目标?

The VMR-9 filter looks like the best route, but I can't seem to find an elegant way of integrating it into my application VMR-9 过滤器看起来是最好的方法,但我似乎找不到将它集成到我的应用程序中的优雅方式

There is no Direct2D/DirectShow interoperability layer in Windows. Windows 中没有 Direct2D/DirectShow 互操作层。 To fit these two technologies you would have to copy data between the APIs in a rather inefficient way (and this will still take some time to develop the fitting).为了适应这两种技术,您必须以相当低效的方式在 API 之间复制数据(这仍然需要一些时间来开发拟合)。

With H.264/HEVC MP4 video files you would be better off using Media Foundation to read and decode frames, then load them into Direct2D bitmaps and display in your application.对于 H.264/HEVC MP4 视频文件,您最好使用 Media Foundation 读取和解码帧,然后将它们加载到 Direct2D 位图并显示在您的应用程序中。 Performance wise it is possible to transfer video frames to Direct2D bitmaps via GPU at reasonable cost and with reasonable development effort, but even if you make a shortcut and do integration roughly and inefficiently it will be on par with DirectShow.在性能方面,可以通过 GPU 以合理的成本和合理的开发工作将视频帧传输到 Direct2D 位图,但即使您创建了一条捷径并粗略且低效地进行集成,它也将与 DirectShow 相提并论。

I recommend to start with looking at reading and decoding video frames with Media Foundation Source Reader API .我建议首先查看使用 Media Foundation Source Reader API读取和解码视频帧。 Once you get familiar with fitting the technologies, you will take next step and optimize the transfer by using GPU capacity and interop between Direct3D and Direct2D .一旦您熟悉了拟合技术,您将采取下一步并通过使用 GPU 容量以及Direct3D 和 Direct2D 之间的互操作来优化传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM