通过编码器将 MFVideoFormat 从 RGB24 转换为任何其他支持的格式

Transfer MFVideoFormat from RGB24 to any other supported format by encoder

我需要使用 encoder H264 但问题是编码器不接受除了 MFVideoFormat 列表。

MFVideoFormat_I420

MFVideoFormat_IYUV

MFVideoFormat_NV12

MFVideoFormat_YUY2

MFVideoFormat_YV12

问题是我相机的样本是 RGB24 我该怎么办?

您(至少)有两个选择:

  1. 在将 RGB24 样本(位图)传递给编码器之前(自行)将它们转换为 NV12(或其他)样本。这并不难。有例子:https://www.google.bg/search?q=RGB+to+NV12

  2. 您可以创建一个 Color Converter DSP 实例 (https://msdn.microsoft.com/en-us/library/windows/desktop/ff819079%28v=vs.85%29.aspx) 并将其配置为接收 RGB24 样本的输入,并将其输出为所需的颜色 space。然后调用 ProcessInput() 和 ProcessOutput() 进行转换。