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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. Can I choose what codec to use when rendering a video files? If
yes...how? I'm using DirectShow .NET and C#.
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.
You can use "FindFilterByName" as a quick example...
i.e.
IGraphBuilder graphBuilder;
IBaseFilter baseFilter;
graphBuilder.FindFilterByName("WMAudio Decoder DMO", out baseFilter);
DMAN
graphBuilder.FindFilterByName("WMAudio Decoder DMO", out baseFilter); - I
tried it and it return null
(new) BlackList sample - where can I find it?
Thanks!
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
I found it the sample. it the new version package
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.
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