Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one find out whether a Windows Media Foundation sink writer needs bottom-up or top-down images?

Tags:

I'm using Windows Media Foundation to create a video file. I've got some code working based on the Using the Sink Writer to Encode Video tutorial.

When the input type in MFVideoFormat_RGB32, and the output type is MFVideoFormat_WMV3, and the sink writer is writing to a WMV file, and I provide the sink writer with top-down RGB32 data, I get the video that I'd expect.

When the output type is MFVideoFormat_H264, on the other hand - everything else the same - the bitmaps come out upside-down.

How can I find out at runtime what sort of bitmap data is needed?

like image 322
Tom Seddon Avatar asked Mar 25 '17 21:03

Tom Seddon


People also ask

What is a media sink?

A media sink is the destination for one or more media streams. Media sinks fall into two general categories: A renderer is a media sink that presents data for playback.

What is Media Foundation Windows 10?

Media Foundation is the next generation multimedia platform for Windows that enables developers, consumers, and content providers to embrace the new wave of premium content with enhanced robustness, unparalleled quality, and seamless interoperability.

What is Media Foundation data?

Media Foundation provides a Media Session object that can be used to set up the topologies, and facilitate a data flow, without the application doing it explicitly. It exists in the control layer, and exposes a Topology loader object.


1 Answers

RGB video media types might be given an optional MF_MT_DEFAULT_STRIDE attribute to specify row order:

Default surface stride, for an uncompressed video media type. Stride is the number of bytes needed to go from one row of pixels to the next. [...]

Stride is positive for top-down images, and negative for bottom-up images.

The attribute is optional and when omitted might lead to confusion as data consumer might apply different defaults. In general it is typical for RGB data to come in reversed row order for historical reasons, however most recent APIs tend to fix it and have data in normal row order.

like image 99
Roman R. Avatar answered Sep 21 '22 11:09

Roman R.