Search code examples
winapivideodirectshowmp4ms-media-foundation

Is there a MS API for writing media containers?


Does Microsoft have a good API for writing media containers (mp4, avi ...)? I have a H.264 video stream and also some timestamps that I want to be able to write to a file. I found this overview of media APIs (http://msdn.microsoft.com/en-us/library/windows/desktop/ee663260%28v=vs.85%29.aspx), but it's difficult to extract just what I need ...


Solution

    1. AVIFile API exists in all versions of Windows but can only create AVI files. They can contain any data format
    2. DirectShow - writes AVI, writes MP4 (as well as MKV, MOV etc) through third party components (worth mentioning: http://gdcl.co.uk/mpeg4), no support in Windows RT due to legacy status of the API
    3. Media Foundation - "successor" to DirectShow, limited availability in Windows versions before Windows 7

    All have open source wrappers for .NET

    Media Foundation MPEG-4 File Sink in particular:

    The MPEG-4 file sink creates MP4 files. For more information about the MP4 file format, refer to the following standards documents: