Menu

Can I choose exactly which codec to use?

2010-02-25
2012-10-29
  • Johnny Alex

    Johnny Alex - 2010-02-25

    Hello. Can I choose what codec to use when rendering a video files? If
    yes...how? I'm using DirectShow .NET and C#.

     
  • snarfle

    snarfle - 2010-02-26

    If you build the graph manually, you can add whatever filters you want. You
    might also look at the (new) BlackList sample. Perhaps that will give you what
    you need.

     
  • DMAN

    DMAN - 2010-02-26

    You can use "FindFilterByName" as a quick example...

    i.e.

    IGraphBuilder graphBuilder;
    IBaseFilter baseFilter;
    graphBuilder.FindFilterByName("WMAudio Decoder DMO", out baseFilter);

    DMAN

     
  • Johnny Alex

    Johnny Alex - 2010-02-27

    graphBuilder.FindFilterByName("WMAudio Decoder DMO", out baseFilter); - I
    tried it and it return null

    (new) BlackList sample - where can I find it?

    Thanks!

     
  • DMAN

    DMAN - 2010-02-27

    It shouldnt be null unless the filter isn't on your PC.
    Replace the filter name in the quotes with the specific filter you want to add
    to the graph.

    DMAN

     
  • Johnny Alex

    Johnny Alex - 2010-02-27

    I found it the sample. it the new version package

     
  • Johnny Alex

    Johnny Alex - 2010-02-27

    dman_lfc:

    I want to explain myself again...cause i'm not so good at directshow. Let's
    the say I have a list with the best codecs to use on some video files. How can
    I set programmaticaly what codec to use? I have "Video Render" filter in my PC
    for sure and FindFilterByName return null.

     
  • DMAN

    DMAN - 2010-02-27

    All depends on how you want to go about assigning filters to playback files.
    You can do it varying ways.

    i.e.

    By File Extension: Assumption of the codecs used for that container format and
    manually add them & render accordingly.
    By Decoding Capabilities: MPEG-2, H.264, AAC etc. Add pre-defined filters and
    render. Disposing of non connected codecs.
    By CLSID: As above but working with the demuxer or MediaInfo library to
    determine the codecs required to add to the graph and render or manually
    connect.

    For example if you wanted to find all H.264 capable decoders on your PC and
    provide the list to yhe use you could do something like this:

    ArrayList availableH264VideoFilters = FilterHelper.GetFilters(MediaType.Video,
    MediaSubType.H264); // provides a list of capable decoders to leverage in a
    windows form.

    Let the user choose their prefered codec and save to to a configuration xml
    file.

    xmlwriter.SetValue("videoplayer", "h264videocodec",
    h264videoCodecComboBox.Text); // saves defined codec setting as per windows
    form combo box selection.

    And then manually add that filter to the graph when required depending on the
    player class.

    i.e.
    strH264VideoCodec = xmlreader.GetValueAsString("videoplayer",
    "h264videocodec", ""); // reads the user defined codec from the xml file
    DirectShowUtil.AddFilterToGraph(_graphBuilder, strH264VideoCodec); // adds the
    defined codec to the graph.

    DMAN

     

Log in to post a comment.