locked
Creating custom MPEG2 media type RRS feed

  • Question

  • I would like to modify BasicPlayback media foundation sample in order to be able to open MPEG2 files.

    I know that native MF does not support MPEG2 format.But it is possible to create custom media type of MPEG2.

    Could you provide me a sample code how should I do that?

    Thank you

    Thursday, February 8, 2007 11:36 AM

Answers

  • So if you wanted MF to be able to play back MPEG2 files, you would first need to write a Media Source for MPEG2, since Media Foundation doesn't natively provide one.  I'm sure you've noticed the wavsource sample in the SDK.  You would also need to write decoder(s) as MFT(s), for which the MFT_Grayscale sample might be useful. 

    You're correct that this MPEG2 Media Source would need to provide mediatypes to describe its streams.  It's definitely valid to do MFCreateMediaType() and then set the various MF_MT_XXX attributes that are relevant.  If it's easier, though, you might want to make use of MFCreateMediaTypeFromRepresentation, which gives you the option of starting with an AM_MEDIA_TYPE representation.

    Thursday, February 8, 2007 7:56 PM

All replies

  • So if you wanted MF to be able to play back MPEG2 files, you would first need to write a Media Source for MPEG2, since Media Foundation doesn't natively provide one.  I'm sure you've noticed the wavsource sample in the SDK.  You would also need to write decoder(s) as MFT(s), for which the MFT_Grayscale sample might be useful. 

    You're correct that this MPEG2 Media Source would need to provide mediatypes to describe its streams.  It's definitely valid to do MFCreateMediaType() and then set the various MF_MT_XXX attributes that are relevant.  If it's easier, though, you might want to make use of MFCreateMediaTypeFromRepresentation, which gives you the option of starting with an AM_MEDIA_TYPE representation.

    Thursday, February 8, 2007 7:56 PM
  • Hi Becky,

    If I want to write a custom source of my own based on the WavSource sample, what MF_MT_XXX attributes should be set up? Right now, I set up the followings -

        MF_MT_MAJOR_TYPE, MFMediaType_Video
        MF_MT_SUBTYPE, MFVideoFormat_MYOWN
        MF_MT_FRAME_SIZE, 352, 240
        MF_MT_FRAME_RATE, 30, 1
        MF_MT_PIXEL_ASPECT_RATIO, 1, 1
        MF_MT_AVG_BITRATE, 900000

    I'm not sure if they are appropriate, maybe I miss some ones or maybe some of them should not be set up in the source? Thanks a lot!

    HShu

    • Proposed as answer by Robcris Wednesday, February 15, 2012 11:57 AM
    Thursday, September 25, 2008 4:05 PM
  • Microsoft have really messed around with developers by the lack of dshow support in Win 7, and no mpeg2 in Media Foundation.  Microsoft are making 10´s thousands of developers suffer problems and to re-invent the "wheel" and it really is annoying!  Microsoft are unpopular for this behaviour.

    xyzzy

    Wednesday, February 15, 2012 11:59 AM