Media Foundation: Decoding and displaying H264 frames without a container
-
29-10-2019 - |
Question
The scenario is this: My Windows client app gets H264-encoded frames from a network source, without a container, in a custom way (proprietary protocol). The format of the frames is known. I need to decode the frames and display the video. It is required that the playback will be flawless during HD streaming, but have an option for low-latency for other scenarios.
Currently, I use ffmpeg's libavcodec to decode the frames, then manually display them on the screen with StretchBlt. We're considering a move to Media Foundation, but it's not clear to me - is it possible to have a source that does not use a container? if so, do I need to create a custom one?
Alternatives to using Media Foundation are also welcome. My main issue with the method that I currently use is that the performance is not good enough, especially for HD video.
Solution
I don't see you mention that you specifically need or what Media Foundation
API, so I would suggest DirectShow
, which you can do it with:
- custom source, see Push Source Filters Sample
- H.264 decoder, stock with Windows 7 (similar to Media Foundation) or third party (choice between a few)
- video renderer such as EVR (shared with Media Foundation) or older versions