DirectShow、Media Foundation、DXVA,什么?

DirectShow, Media Foundation, DXVA, what?

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

因为我有游戏背景,所以我想我应该这样处理。在使用不同的技术制作了一堆原型之后,我非常确定我可以提取 video-to-texture 渲染并使用 DirectX 来满足所有客户的要求。

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

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

Media Foundation 已随 Windows Vista 引入,并且在 Windows 8 之前有一个名为 "Media Session" 的东西,之后他们引入了 "Media Engine"。 如果我没记错的话,编解码器称为 MFT?是否真的有像 free-codecs.com 这样的网站?

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

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

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

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

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

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

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

MFT 是媒体基础的基础组件:编码器、解码器、效果器、缩放器、视频捕获设备 - 所有内部都有 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 是 APIDXVA 2.0 系列的一部分,涵盖硬件加速视频处理。作为 public 低级接口提供,它还集成在 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 月更新

我想 link 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.