video - DirectShow、Media Foundation、DXVA,什么?

标签 video directx directshow ms-media-foundation dxva

我的任务是修改一个使用 DirectShow 进行视频渲染的应用程序。旧应用程序运行良好,但开始显示老化。

因为我有游戏背景,所以我想我应该这样处理。在使用不同的技术制作了一堆原型(prototype)之后,我非常确定我可以进行视频到纹理渲染并使用 DirectX 来满足所有客户的要求。

然而,我现在正处于必须选择一种技术的地步,我不能再迷茫了......

  • DirectShow
  • 媒体基金会
    • 媒体 session (< Windows 8)
    • 媒体引擎(> Windows 8)
  • DXVA1
  • DXVA2
  • DXVA-HD

DirectShow 显然是最古老的,但仍然运行良好,这主要也是因为有大量可用的编解码器。

Media Foundation 已随 Windows Vista 引入,并且在 Windows 8 之前有一个称为“媒体 session ”的东西,之后他们引入了“媒体引擎”。 如果我是正确的编解码器称为 MFT?是否真的有像 free-codecs.com 这样提供这些功能的网站?

在这 2 种技术之上,还有 DXVA,它允许您将视频解码卸载到 GPU。目前,我遇到了 3 种不同的类型。 DXVA1 是自 XP 以来一直存在的实现,DXVA2 是较新的 API。 但什么是 DXVA-HD?它比 DXVA2 更新还是等效名称?

我真的很想转向 Media Foundation,开箱即用的编解码器非常适合客户想要使用的格式。我所关心的是获取编解码器有多容易... Windows 8+ 默认媒体播放器是否仍然具有 DirectShow 和 MF 渲染路径并即时交换它们,或者微软是否完全逐步淘汰 DirectShow?

我也不太明白 DXVA 应该如何工作。鉴于我基本上想在游戏中渲染视频,只有让所有渲染实际发生在 GPU 上并将应用程序逻辑保留在 CPU 上才有意义,但我真的找不到任何关于如何使用 Media 使用它的好例子基础。这主要是因为我不知道 DXVA2 和 DXVA-HD 之间的区别。 Windows 7 SDK 附带了所有 3 种实现的示例...

如果有人能以粗体回答我的问题,纠正我的错误信息并指出正确示例的方向(DirectX + Media Foundation + DXVA-whatever),我将非常感激!它可以像“组合这 3 个 Windows 7 SDK 示例以获得您想要的东西”一样简单。

整个任务的目标是再次以一流的形式获得应用程序,我想绝对确定我选择的技术将持续到下一个十年,就像 DirectShow 已经拥有的那样:P

最佳答案

If I'm correct codecs are called MFTs? Are there actually sites that have these available much like free-codecs.com?

编解码器通常是软件项目,可以从压缩格式解压缩为未压缩格式(解码器),反之亦然(编码器)。这两个 API 都没有使用精确的编解码器运行,而是为具有输入和输出的组件定义了一个通用接口(interface),例如DirectShow 中的过滤器、DirectX 媒体对象 (DMO) 或其演变 - Media Foundnation Transform (MFT)。

MFT 是 Media Foundation 的基础组件:编码器、解码器、效果器、缩放器、视频捕获设备 - 所有内部都有 MFT,更高级别的 API 构建于其之上。

由于对 Media Foundation 的兴趣有限,整体第三方 MFT 很少见。虽然您几乎可以在 DirectShow 过滤器外形中找到任何东西,但 Media Foundation 和 MFT 却不是这样。

But what is DXVA-HD? Is it newer than DXVA2 or is it an equivalent name?

DXVA-HD 是 DXVA 2.0 API 系列的一部分,涵盖硬件加速视频处理。作为公共(public)低级接口(interface)提供,它还集成在 DirectShow 和 Media Foundation 库存组件中。

Does Windows 8+ default media player still have both DirectShow and MF render paths and swaps them on the fly or is Microsoft completely phasing out DirectShow?

是的,WMP 12 仍然兼具两者。 Windows 10 电影和电视播放器仅支持 MF。

Given I want to basically render videos inside a game, it would only make sense to make all rendering actually happen on the GPU and keep application logic on the CPU, but I can't really find any good examples on how to utilize it using Media Foundation.

DirectShow 和 Media Foundation 都提供支持 DXVA 的库存解码器(主要用于 H.264,但不仅限于此)。我会说 DirectShow 实现相当不灵活,并且旨在与 EVR 一起使用。 Media Foundation 的实现更加灵活,可以作为 MFT 在 MF 管道之外使用。然而,两者都是为了隐藏所有复杂性并在幕后自动使用 DXVA 解码。

... and I want to absolutely sure I pick the techniques that will last for the next decade like DirectShow already has

DirectShow 仍然作为遗留 API,在示例、代码、公共(public)信息、文档和第三方可扩展性方面提供了更多慷慨的产品。 Media Foundation 是一个预期的替代绘图,对它的兴趣非常有限。与 DirectShow 相比,它基本上没有提供太多功能,Microsoft 没有开发它来涵盖 DirectShow 的功能集——更新 API 通常期望的功能,不提供有用的开发人员工具。看起来 MF 是个新东西,应该自己卖,但最终还是没有成功:

... The miracle of DirectShow is that, even though it was written in 1995, that original code still supports the many wild and varied multimedia formats that have been developed since. The latest baseclasses update I'm aware of is from 2009, in the Windows 7 SDK, but even that has only minor modifications from the original release.

[...]

But remember, even 7 years ago, DirectShow was already 15 years old. The baseclasses were released in source form from the start. They've had more than 2 decades of attention paid by programmers who care. The problems were ironed out a long time ago.

[...]

Now, having said all that, it's true that the folks in Redmond consider DirectShow to be a dead technology. They've moved on to Media Foundation, for reasons that utterly escape me. I have YET to find a problem that Media Foundation solves better than DirectShow. Its inherent limitations mean that there are problems it simply cannot solve. I will never understand why they chose to start over, instead of patching whatever they didn't like in DShow. The fundamental concepts are absolutely identical, although the vocabulary is different. It's just a waste of resources.

2019 年 7 月更新

我要链接a comment from Microsoft's James Dailey关于 DirectShow 相关问题,它还简洁地概述了截至 2019 年 DirectShow 的整体状态:

Please keep in mind that while DirectShow is technically still supported we are in the process of deprecating this legacy technology. We ask that you please move to MediaFoundation as soon as possible.

关于video - DirectShow、Media Foundation、DXVA,什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38706914/

相关文章:

c# - 如何读取 IMediaSample 24 位 PCM 数据

javascript - 如何修改WebRTC MediaStream视频轨道的内容?

video - jwplayer 在缓冲时跳过视频

ios - Safari 检测视频何时播放完毕

facebook - 如何将YouTube视频嵌入到Facebook iframe应用中?

c++ - 如何使用 Direct3D 和 C++ 制作正方形?

directx - 如何判断系统DirectX是11还是11.1?

c++ - FFMPEG 帧到 DirectX 表面

c++ - 删除 DirectShow 过滤器(未调用析构函数)

c# - Directshow录制/预览问题