IMediaSample(DirectShow) 到 IDirect3DSurface9/IMFSample(MediaFoundation)
我正在开发一个自定义视频播放器。我在我的架构中混合使用 DirectShow/Media Foundation。基本上,我使用 DS 来抓取 VOB 帧(MF 不支持)。我能够从 DirectShow 获取示例,但仍无法将其传递给渲染器。在 MF 中,我获取 Direct3DSurface9(来自 IMFSample),并使用 IDirect3D9Device 将其呈现在后台缓冲区上。
使用 DirectShow,我将 IMediaSample 作为我的数据缓冲区对象。我不知道如何转换并将其作为 IMFSample 传递。我发现其他人从示例中获取位图信息并使用 GDI+ 进行渲染。但我的视频数据可能并不总是有 RGB 数据。我希望从 IMediaSample 获取 IDirect3DSurface9 或 IMFSample 并将其传递给渲染,这样我就不必担心颜色空间转换。
我对此很陌生。如果我错了,请纠正我。 谢谢
I am working on a custom video player. I am using a mix of DirectShow/Media Foundation in my architecture. Basically, I'm using DS to grab VOB frames(unsupported by MF). I am able to get a sample from DirectShow but am stuck on passing it to the renderer. In MF, I get a Direct3DSurface9 (from IMFSample), and present it on the backbuffer using the IDirect3D9Device.
Using DirectShow, I'm getting IMediaSample as my data buffer object. I don't know how to convert and pass this as IMFSample. I found others getting bitmap info from the sample and use GDI+ to render. But my video data may not always have RGB data. I wish to get a IDirect3DSurface9 or maybe IMFSample from IMediaSample and pass it for rendering, where I will not have to bother about color space conversion.
I'm new to this. Please correct me if I'm going wrong.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您从 DirectShow 中的上游解码器获得的 IMediaSample 只不过是内存支持缓冲区的包装器。它后面没有也不可能有任何
D3D
表面(除非您自己处理它并提供自定义分配器,在这种情况下您首先不会有问题)。因此,您需要将此缓冲区中的数据内存复制到 MF 示例缓冲区中。您会遇到这样的问题:您希望缓冲区格式(媒体类型)匹配,以便您可以在不进行转换的情况下进行复制。其中一种方法(可能有几种)是首先建立 MF 管道,并找出视频硬件上的缓冲区为您提供的确切像素类型。然后,通过使用相应的采集器初始化或色彩空间转换过滤器,或通过色彩空间转换
DMO
/,确保
。DirectShow
管道中具有此像素格式和媒体类型MFTIMediaSample
you have from upstream decoder inDirectShow
is nothing but a wrapper over memory backed buffer. There is no and cannot be anyD3D
surface behind it (unless you take care of it on your own and provide a custom allocator, in which case you would not have a question in first place). Hence, you are to memory-copy data from this buffer intoMF
sample buffer.There you come to the question that you want buffer formats (media types) match, so that you could copy without conversion. One of the ways - and there might be perhaps a few - is to first establish
MF
pipeline and find out what exactly pixel type you are offered with buffers on the video hardware. Then make sure you have this pixel format and media type inDirectShow
pipeline, by using respective grabber initialization or color space conversion filters, or via color space conversionDMO
/MFT
.