本文介绍了如何更改 Media Foundation Transform 输出帧(视频)大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个转换并想更改帧和视频的输出大小.我检查了样本并找出了函数调用的顺序:

I am writing a transform and want to change the output size of the frame and video. I inspected the sample and found out the order of function calling:

SetInputType
SetOutputType
    GetInputCurrentType
    SetInputType
            UpdateFormatInfo
                GetOutputCurrentType
                SetOutputType
                        GetOutputStreamInfo
                            SetProperties
                                ProcessOutput (THROW NEED INPUT)
                                ProcessInput
                                ProcessOutput
                                ProcessOutput (THROW
                                ....
                                .... repeat until done

我需要在哪一步修改输出大小以及如何修改?

In which step do I need to modify the output size and how?

示例:输入一个 640x480 的视频,输出 480x480 的视频,没有拉伸.

Example: Input a 640x480 video, output 480x480 video, without stretching.

推荐答案

在 MFT 中更改输出大小"有 2 个步骤.

There are 2 steps to "changing the output size" in your MFT.

1) 您需要修改 SetOutputType 和 GetOutputAvailableType 例程:

1) You need to modify the SetOutputType and GetOutputAvailableType routines:

  • 如果 SetOutputType 当前检查维度以验证它们是否与输入相同(您可能会或可能不会这样做),那么您需要更新它.
  • 当要求枚举您通过 GetOutputAvailableType 支持的输出类型时(假设您支持枚举类型),您的输出媒体类型必须具有正确的大小.

2) 您需要修改 ProcessInput/ProcessOutput 中样本的处理以实际 DO 调整大小.仅更改媒体类型不会执行任何类型的自动调整大小.您如何更改尺寸取决于视频数据的实际格式(您未提供),以及您希望如何调整大小的详细信息.你只是想剪掉多余的线条吗?从顶部还是底部?是否也需要支持斩波宽度?

2) You need to modify the processing of the samples in ProcessInput/ProcessOutput to actually DO the resizing. Just changing the media types doesn't perform any kind of automatic resizing. How you change dimensions depends on the actual format of the video data (which you did not provide), and the details of how you want to do the resizing. Did you just want to chop off the extra lines? From the top or the bottom? Do you need to support chopping width too?

我有一个 C++ 类来处理创建 MFT 的所有开销,还有一些示例 MFT 展示了如何使用 http://www.LimeGreenSocks.com/MFT.在撰写本文时,它仍处于测试阶段,但它应该可以为您提供一些想法.

I have a c++ class that handles all the overhead of creating MFTs, along with a number of sample MFTs that show how to use that class available at http://www.LimeGreenSocks.com/MFT. It's still in beta as of this writing, but it should give you some ideas.

可能最接近您尝试做的样本是旋转.旋转时,800x600 的视频可以变成 600x800 的视频.Rotate 甚至允许在流式传输时更改旋转(请参阅 异步 MFT 下的格式更改).C++ 旋转 mft 是一个很好的注释,大约 350 行.

Probably the closest sample for what you are trying to do is the Rotate. When rotating, an 800x600 video can become a 600x800 video. The Rotate even allows the rotation to be changed while streaming (see Format Changes under Asynchronous MFTs). The c++ rotate mft is a well-commented ~350 lines long.

这篇关于如何更改 Media Foundation Transform 输出帧(视频)大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 22:50