none
Mapping MPEG-2 decoder filters

    Question

  • Hi,

    I am building a filter graph programmatically with a HDV capture source (MPEG-2) and a MPEG-2 Demux. I am able to render a preview using the Render() command, but I need to do image processing for each frame so I want to use the sample grabber.

    Now I need the program to select the available MPEG-2 decoder filter that is available on the user's system. I know how to enumerate the filters by category using the filter mapper, but that does not filter by MPEG-2 types, as far as I know. I have checked all possibilities for the media subtype in uuids.h but I can't find a suitable one.

    Does anyone know how I can map MPEG-2 decoder fitlers?

    Thanks in advance.
    Wednesday, October 01, 2008 5:28 PM

Answers

  • OMG! I think I have a usable function now

    I have set the exact match to 'true' and the minimum merit to MERIT_NORMAL.  didn't even know what "merit" means until I looked it up in the dictionary... Now I understand.
    Now it gives this list:

    Cyberlink Video/SP Decoder
    Elecard MPEG-2 Video Decoder HD
    Nero DVD Decoder
    Nero Video Decoder

    Those are all usable. If I set the minimum merit to MERIT_UNLIKELY I get a few more filters. The ffdshow filter is left out all the time, but maybe I should not worry about that one.

    I think I can use the code as it is now. Many thanks for all the help!
    Monday, October 06, 2008 7:16 PM

All replies

  • I'm still puzzling on this one. I thought I had an idea to get it working; for each filter found, bind it to a temporary IBaseFilter and check if one of the input pins supports major type Video and subtype MPEG2_VIDEO. Then I found out most filters don't have these types specified before they are actually connected... I have three working MEP2 decoder filters on my system. I looked up their pin properties in GraphEdit and noticed two of them did have pins supporting major type Video and subtype MPEG2_VIDEO, but one of them does not - and it still is capable of decoding the MPEG2 data. So if even my idea above would work, it would still not show all filters that are available.

    Maybe I am missing something, I have searched the net for a long time and can not find any good info on how to do this.
    I have one other idea that I could try, but that is more a workaround that I'd rather not use because I think it's a bit sloppy: Just list all the filters and one by one try to connect them to the demux. If one succeeds it is suitable.
    Would that be a good or a bad idea? If anyone knows a better method or a link to more info about this subject I'd really like to hear it.

    Thanks
    Sunday, October 05, 2008 1:59 PM
  • Hi,

     

    0 - Create graph.

    1 - Add all filter to graph and connect it from source to demux.

    2 - Get input pin of mpeg-2 decoder.

    3 - Create outputpin on demux

    4 - Connect output pin of demux with input pin of decoder.

    5 - Associate a stream with demux output pin

     

    Arnaud

    Monday, October 06, 2008 5:06 PM
  • Thanks for your reply Arnoud. But this shows me how to map the pin of the demux, which I have already done. (Also with MEDIA_ELEMENTARY_STREAM). This part is not the problem, what I'm after is getting the MPEG2 decoder filters so I can connect to one of them. Maybe that's what you meant with the note, but I'm not sure what you mean by that. (like you said, it's another story...)

    Thanks for your time.
    Monday, October 06, 2008 5:49 PM
  • Yes, I don't undestand your problem......

     

    Is your problem is to found on your system an Mpeg2 decoder or instanciate it ?

    or found the video stream and select it ?

     

    Arnaud

     

     

    Monday, October 06, 2008 6:02 PM
  • I need to find them. Once I have found them I can instanciate them. I just don't know a good way to find the filters I need. I know there are 3 MPEG2 decoders on my system. Using the EnumMatchingFilters gets me close, but I get more filters than just the one I need. If only there was an option to make it narrow down the list to only the MPEG2 decoders...
    Monday, October 06, 2008 6:07 PM
  • I don't know how choose the best filter so i let user to choose......

     

    For enumeration i filter the filter list using MEDIATYPE_Video and MEDIASUBTYPE_MPEG2_VIDEO...

     

    ....

     

    Arnaud

    Monday, October 06, 2008 6:27 PM
  • That's almost what I have now. When I use EnumMatchingFilters with MEDIATYPE_Video and MEDIASUBTYPE_MPEG2_VIDEO I get this list:

    AVI Decompressor
    Cyberlink MPEG Video decoder
    Cyberlink Video/SP decoder
    DivXAntiFreeze
    Elecard MPEG Demultiplexer
    Elecard MPEG-2 Video decoder HD
    Elecard Stream Parser
    ffdshow MPEG-4 Video decoder
    MainConcept (AdobeEncore) MPEG Video Decoder
    Nero DVD deocoder
    Nore Video Decoder
    Overlay Mixer2

    from this list only the
    "Elecard MPEG-2 Video decoder HD", "ffdshow MPEG-4 Video decoder" and "MainConcept (AdobeEncore) MPEG Video Decoder" are suitable decoder filters.

    Here's what the enumerator looks like now:

    Code Snippet

    GUID arrayInTypes[2];
    arrayInTypes[0] = MEDIATYPE_Video;
    arrayInTypes[1] = MEDIASUBTYPE_MPEG2_VIDEO;//GUID_NULL;//MEDIASUBTYPE_DVSD; //dvsd
    GUID arrayOutTypes[2];
    arrayOutTypes[0] = MEDIATYPE_Video;
    arrayOutTypes[1] = GUID_NULL;//MEDIASUBTYPE_YV12;

    hr = pMapper->EnumMatchingFilters(
    &pEnum,
    0, // Reserved.
    FALSE,//TRUE, // Use exact match?
    MERIT_DO_NOT_USE+1, // Minimum merit.
    TRUE, // At least one input pin?
    1, // Number of major type/subtype pairs for input.
    arrayInTypes, // Array of major type/subtype pairs for input.
    NULL, // Input medium.
    NULL, // Input pin category.
    FALSE, // Must be a renderer?
    TRUE, // At least one output pin?
    0, // Number of major type/subtype pairs for output.
    arrayOutTypes, // Array of major type/subtype pairs for output.
    NULL, // Output medium.
    NULL); // Output pin category.


    I have set "use exact match" to 'false' because if that one is true it does not list the ffdshow filter (but still shows too many filters....
    I'm close, but no cigar yet...

    EDIT: I've just found out that the Cyberlink MPEG Video decoder and the Cyberlink Video/SP decoder work as well. So I'm even closer, still one missing and two too many...
    Monday, October 06, 2008 6:53 PM
  • Strange, on my conputer i have only filter that support MPEG2...

     

    for example "Overlay Mixer2" and "AVI Decompressor" is not on my combo ? 

     

    On my code there's two part the part with GUID_NULL and the other, do you use the second ?

     

    I see in your code that you try to found decoder with in and out pin, on my code, i try to found only input pin that match...

     

     

    Ps: I post a question about MPEG-4 decoding with Microsoft Demux, the decoding is not complete, if you have some time to look at it thanks...

    Monday, October 06, 2008 7:12 PM
  • OMG! I think I have a usable function now

    I have set the exact match to 'true' and the minimum merit to MERIT_NORMAL.  didn't even know what "merit" means until I looked it up in the dictionary... Now I understand.
    Now it gives this list:

    Cyberlink Video/SP Decoder
    Elecard MPEG-2 Video Decoder HD
    Nero DVD Decoder
    Nero Video Decoder

    Those are all usable. If I set the minimum merit to MERIT_UNLIKELY I get a few more filters. The ffdshow filter is left out all the time, but maybe I should not worry about that one.

    I think I can use the code as it is now. Many thanks for all the help!
    Monday, October 06, 2008 7:16 PM
  •  AChainard wrote:

    Strange, on my conputer i have only filter that support MPEG2...

     

    for example "Overlay Mixer2" and "AVI Decompressor" is not on my combo ? 

     

    On my code there's two part the part with GUID_NULL and the other, do you use the second ?

     

    I see in your code that you try to found decoder with in and out pin, on my code, i try to found only input pin that match...

     

     

    Ps: I post a question about MPEG-4 decoding with Microsoft Demux, the decoding is not complete, if you have some time to look at it thanks...



    You where replying at the same time as I did These two other mixers showed up when I set "use exact match" to false. I did this because otherwise it didn't list the ffdshow filter. I have set it to true now, so it doesn't show the other filters as well.


    I have already looked at your other question and I want to help you, but I don't have the Microsoft Demux on this computer (running XP) I wanted to check it out on one of my other computers that does run Vista (I assume you're on Vista) but if I open the filter selection dialog in GraphEdit, it crashes... if you know how I can make this program stop chrashing I might be able to help you out
    Monday, October 06, 2008 7:22 PM
  • I work on WinXp SP2...

     

    If don't know, don't worry... may be some one else ......

     

    Bye...
    Monday, October 06, 2008 7:28 PM
  • How about querying the list of filters for the IAMDecoderCaps interface?

    http://msdn.microsoft.com/en-us/library/ms783862(VS.85).aspx


    The IAMDecoderCaps interface returns capabilities information from an MPEG decoder filter. Some DirectShow components, such as the DVD Graph Builder, use this interface to determine the correct filter graph to build. Applications might use this interface to query the decoder's capabilities.


    The IAMDecoderCaps::GetDecoderCaps method queries the decoder for its capabilities.


    But this assumes that all MPEG2 decoders implement IAMDecoderCaps::GetDecoderCaps

    If they do, then you could progressively narrow down the list by:
    1. Use EnumMatchingFilter to find filters that accept MPEG2 as input
    2. Then query the filters for IAMDecoderCaps (discard those which do not have this interface)
    3. Then maybe use GetDecoderCaps to query for AM_QUERY_DECODER_DVD_SUPPORT capability?

    ... or perhaps other capabilities are more suitable to check for - e.g. VMR or VMR9 support on the assumption that a decoder should be able to feed a renderer.

    I haven't tried this, but it might be worth looking into.


    Wednesday, October 15, 2008 12:33 PM
  • Thank you Tiresias,

    That might be very good advise. I wasn't totally sure if my method (which did work now) would give the correct decoder filter on every machine. Using this code should make sure it does I guess.

    Thanks!
    Wednesday, October 15, 2008 5:11 PM
  • Or maybe not .... I just checked ffdshow and it doesn't seem to have a IAMDecoderCaps interface. Sad

    Wednesday, October 15, 2008 6:03 PM
  • I'm not concerned about the ffdshow decoder. It was filtered out by the other method already, and because it is not likely to be the defautl decoder on the user's systems I don't hink I have to worry about that one. It seems all standard decoders are listed nicely. In the worst case I could make my program look for other decoders like ffdshow if no better ones are found.
    Wednesday, October 15, 2008 6:08 PM
  • I'm not concerned about the ffdshow decoder. It was filtered out by the other method already.

    I have set "use exact match" to 'false' because if that one is true it does not list the ffdshow filter.


    Are you using the latest version of ffdshow? The mpeg2 decoder shows up fine when I do "use exact match" set to true.

    Thursday, October 16, 2008 11:35 AM
  •  tiresias wrote:

    Are you using the latest version of ffdshow? The mpeg2 decoder shows up fine when I do "use exact match" set to true.


    That could be the problem. I thought mine should be up to date because I recently installed it. I've just checked it, and it appears to be a 2004 version.
    Thursday, October 16, 2008 3:56 PM