简体   繁体   English

如何更改Media Foundation Transform输出帧(视频)的大小?

[英]How to change Media Foundation Transform output frame(video) size?

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? 我需要在哪一步中修改输出大小以及如何修改?

Example: Input a 640x480 video, output 480x480 video, without stretching. 示例:输入640x480视频,输出480x480视频,不进行拉伸。

There are 2 steps to "changing the output size" in your MFT. 在MFT中,有2个步骤可以“更改输出大小”。

1) You need to modify the SetOutputType and GetOutputAvailableType routines: 1)您需要修改SetOutputType和GetOutputAvailableType例程:

  • If SetOutputType currently checks the dimensions to validate that they are the same as the input (which you may or may not be doing), then you need to update that. 如果SetOutputType当前检查尺寸以验证它们是否与输入相同(您可能会或可能不会这样做),那么您需要对其进行更新。
  • When asked to enumerate the output types you support via GetOutputAvailableType (assuming you support enumerating types), your output media type must have the correct sizes. 当要求通过GetOutputAvailableType枚举您支持的输出类型(假设您支持枚举类型)时,您的输出媒体类型必须具有正确的大小。

2) You need to modify the processing of the samples in ProcessInput/ProcessOutput to actually DO the resizing. 2)您需要修改ProcessInput / ProcessOutput样品的处理,以实际调整大小。 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? 您还需要支持裁切宽度吗?

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 . 我有一个c ++类,该类处理创建MFT的所有开销,以及许多示例MFT,这些示例MFT显示了如何使用该类, 网址http://www.LimeGreenSocks.com/MFT It's still in beta as of this writing, but it should give you some ideas. 在撰写本文时,它仍处于测试阶段,但应该可以给您一些想法。

Probably the closest sample for what you are trying to do is the Rotate. 您尝试做的最接近的样本可能是“旋转”。 When rotating, an 800x600 video can become a 600x800 video. 旋转时,800x600视频可以变成600x800视频。 The Rotate even allows the rotation to be changed while streaming (see Format Changes under Asynchronous MFTs). 旋转甚至允许在流传输时更改旋转(请参见异步MFT下的格式更改 )。 The c++ rotate mft is a well-commented ~350 lines long. c ++旋转mft的注释很长,大约为350行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Media Foundation - 如何在MFT中更改帧大小(Media Foundation Transform) - Media Foundation - How to change frame-size in MFT (Media Foundation Transform) Directshow:如何更改视频的大小和帧速率? - Directshow : How to change Size and frame rate of video? 使用DirectX视频加速(DXVA)实施媒体基础转换(MFT) - Implementing a Media Foundation Transform (MFT) with DirectX Video Acceleration (DXVA) Media Foundation使用PROPVARIANT结构设置视频捕获帧速率 - Media Foundation set video capture frame rate using PROPVARIANT structure 媒体基金会的视频合成 - Video composition with Media Foundation 如何使用 Media Foundation 或 DirectShow 等 Windows 媒体 API 检测相机帧丢失? - How to detect camera frame loss using Windows media API like Media Foundation or DirectShow? Windows Media Foundation:当前媒体类型更改 - Windows Media Foundation: current media type change 当应用程序是视频源并通过网络流式传输视频时,如何使用Media Foundation? - How to use Media Foundation when application is video source and streams video via network? Media Foundation捕获的视频是垂直镜像的 - Video captured by Media Foundation is vertical mirrorred 使用Media Foundation进行无缝视频播放 - Seamless Video Playback Using Media Foundation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM