APPENDIX B - Guidelines for DirectShow configuration through K-Lite
As already mentioned inside the How to play video files through DirectShow tutorial, DirectShow includes by default a limited number of filters for decoding some common media file formats such as MPEG-1, MP3, Windows Media Audio, Windows Media Video, MIDI, media containers such as AVI, ASF, WAV, some splitters/demultiplexers, multiplexers, source and sink filters and some static image filters. However, DirectShow's standard format repertoire can be easily expanded by means of a variety of commercial and open source third-party filters. Such filters enable DirectShow to support virtually any container format and any audio or video codec.
One of the best packages containing most audio and video codecs for DirectShow is the K-Lite Codec Pack, a free collection of DirectShow filters, VFW/ACM codecs and tools available in both x86 and x64 versions. This package is updated quite frequently and really well supported and maintained. It can be downloaded for free from the following link.
Once installed, you can configure most aspects of DirectShow through a set of powerful but easy to use configuration tools. by default, the installation will create a menu item under the sequence "Start/All programs/K-Lite Codec Pack" (this sequence is for the English versions of Windows so it could look a bit different when using other languages); under this menu item you will find the following sub-items:
|•||Media Player Classic: this is a multimedia application and a valid open source alternative to Microsoft's Windows Media Player|
|•||Configuration: this sub-item is the starting point to configure DirectShow codecs installed by K-Lite: this tutorial will most deal with it.|
|•||Help: contains K-Lite documentation|
|•||Tools: this sub-item contains a set of tools that can be useful when dealing with DirectShow.|
|•||Uninstall: allows uninstalling K-Lite and all related codecs, filters and tools from the system|
IMPORTANT NOTE ABOUT X86 AND X64 VERSIONS OF WINDOWS: K-Lite Codec Pack comes with both x86 and x64 versions of its codecs and configuration tools so, when running on a x64 version of Windows, it's very important being sure that the x64 version is installed and that the configuration is performed using the x64 version of the configuration tools. It's also important to note that the availability of the x86 version of K-Lite could be still needed in case the container application should be compiled specifically for "x86" and run on a x64 version of Windows.
Configuration of video codecs
If FFDSHOW, a portion of the K-Lite Codec pack, is installed inside the system (you can know if FFDSHOW is installed by querying the VideoFiltersFfdShowIsAvailable method), the configuration of video codecs becomes probably the most important aspect of video playback because it allows deciding the transform filter used to decode and render the video stream of supported video formats; configuration can be managed in two ways:
|•||programmatically through the usage of the VideoFiltersFfdShowDecoderGet and VideoFiltersFfdShowDecoderSet methods.|
|•||manually through the "ffdshow video decoder" tool installed by K-Lite: this tool can be launched through the Windows menu "Start/All programs/K-Lite Codec Pack/Configuration/ffdshow video decoder" and its user interface will appear like this:|
As already mentioned, by default Windows comes with a set of codecs/decoders, mostly contained inside the Quartz.dll library installed by DirectShow or inside Windows Media components. When a video decoder is not available by default in Windows, ffdshow will try using its own decoder while, when a decoder for a certain format is already installed, the ffdshow decoder will result "disabled" as seen on the screenshot above for the MPEG1 and MPEG2 formats.
In order to enable the ffdshow decoder for a specific format, you will simply have to click the corresponding "Decoder" column on the format specific row and choose one of the available decoders installed by ffdshow as seen on the screenshot below for the MPEG2 format:
When dealing with Windows 7, it's strongly recommended that you set "libavcodec" decoder for both MPEG1 and MPEG2 formats. Windows 7 default decoders, like "MPEG VIDEO DECODER" for MPEG1 and "Microsoft DTV-DVD Video Decoder" for MPEG2, are not compatible with certain features of our component like adding the clip to a video mixer or loading a video clip from a memory buffer: for this reason these system default codecs are automatically blacklisted by our component: in case of need, you can disable this blacklist by using the VideoFiltersBlacklistDisable method.
The mentioned black-list can be expanded programmatically by adding other filters that you don't want to be used when generating the filters graph: this can be achieved through the VideoFiltersBlacklistItemAdd method; items in black-list can be removed at any time through the VideoFiltersBlacklistItemRemove method; the list can be reset through the VideoFiltersBlacklistReset method.