Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

How to use SourceReader (for H.264 to RGB conversion)?

$
0
0
I'm trying to move from DirectShow land to Media Foundation and an trying to build around some existing code. Unfortunately I've run in some issues.

Basically what I want to do is take an MPEG4 video that is encoded in H.264 and be able to convert it to RGB or YUV. I can then take that raw YUV or RGB data so that I can make an OpenGL texture.

I've concluded that I need to use the SourceReader and have the IMFSourceReader::ReadSample method set up and returning samples. The problem is that I can't seem to be able to set the subtype to be MEDIASUBTYPE_UYVY or _RGB24 like I could in DirectShow.
Basically I get an MF_E_INVALIDMEDIATYPE error when I do IMFSourceReader::SetCurrentMediaType with my media type (of which I've only set MF_MT_MAJOR_TYPE and MF_MT_SUBTYPE)

Reading http://msdn.microsoft.com/en-us/library/dd797815%28VS.85%29.aspx gives me the impression that I can't even use those subtypes anyway. If that is the case, then is is possible to convert the H.264 to RGB?

Which leads me to my next question. Basically all I want is raw RGB (24bit) data so that I can create an OpenGL texture. Would I be best to:
- follow the instructions at the end of http://msdn.microsoft.com/en-us/library/dd389281%28VS.85%29.aspx#why_use_source_reader and set up the DirectX components then...
- ultimately receive IDirect3DSurface9 objects of which I can call GetDC on it and retrieve the raw RGB data which I can then pass to my OpenGL texture.

Is this even possible? I'm getting a little lost amongst all the documentation at the moment and just want to try and cut down what to focus on.

Thanks

- Edit
It occurred to me that trying to get OpenGL and DirectX to share the graphics card is not a good idea. Instead I'll just get the H.264 to output to MEDIASUBTYPE_YUY2 and convert it to RGB with an OpenGL shader (or something).

Am I right in thinking that MediaFoundation is still limited in video support i.e. it doesn't support MP4v?

Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>