Difference between revisions of "DirectShow Playback Guide"
|Line 218:||Line 218:|
[[http://wiki.jrmediacenter.com/index.php/DTS_WAV Be sure to read this FAQ]] if you are interested in full support for [http://en.wikipedia.org/wiki/Digital_Theater_System DTS WAV] playback.
[[http://wiki.jrmediacenter.com/index.php/DTS_WAV Be sure to read this FAQ]] if you are interested in full support for [http://en.wikipedia.org/wiki/Digital_Theater_System DTS WAV] playback.
==== MPEG-4 Container Family mp4 / m4a / m4v ====
==== MPEG-4 Container Family mp4 / m4a / m4v ====
Revision as of 17:57, 16 May 2007
- 1 Introduction
- 2 1. What is DirectShow? What is a DirectShow filter?
- 3 2. What version of DirectX do I need?
- 4 3. Why do I need to get DirectShow filters?
- 5 4. How do I install DirectShow filters?
- 6 5. What filters do I need and where do I get them?
- 6.1 CCCP - Combined Community Codec Pack
- 6.2 Additional Filters
- 6.3 Alternative Filters
Native DirectShow filter support was added to MC11.1 in December 2005 and has been improved drastically with MC12. DirectShow is a multimedia API released by Microsoft which became a standard component of Windows with Windows 98. It is essentially a replacement for the earlier Video for Windows technology. In Windows Vista this technology has evolved into the Windows Media Foundation, which performs similar services. It provides developers with a unified interface across different programming languages to allow their applications to render or record media files, using a filter based framework.
1. What is DirectShow? What is a DirectShow filter?
Media Center plays many media formats in DirectShow. This includes DVD and many video and audio files. DirectShow is a Microsoft technology for playing audio/video media on Windows computer.
DirectShow uses the concept of “Filter Graph”. A filter graph is built with individual “Filters”. A filter is a software component in DirectShow that will work with other components to render a media file, each filter processes audio/video data in a specific way to facilitate the playing of the media files. Filters have “pins” - points of connection between filters, both input pins and output pins. Pins are the means by which media data is passed from one filter to another filter. For example, the Input pin of the Haali Media Splitter will receive the data from the file, split it to it's component parts and then output those "streams" via it's output pins. FFDSHOW will then connect it's input pins to Haali's output pins and decode the video stream.
You can use the free GraphEdit utility from Microsoft to manually build filter graphs if you want to play around with how this works.
Generally speaking, there are three types of filters in terms of functionality: Source filters, transform filters, and renderer filters.
With most media files, it is important to understand the distinction between the file container format and the individual media stream formats (sometimes referred to as the codec of the file) "contained" inside the file. The container format is essentially the file you see on your hard drive (the AVI, MKV, MP4, OGM, or whatever) which is used to identify and interleave the different "stream" types that make up the actual media, including metadata tags, video streams, audio streams, subtitles, and other information.
A Source Filter is a component that loads a media file for playback used to decode the container file format and extract the actual audio, video, metadata, and subtitle streams (among other information). The simplest source filter simply loads a file and passes the stream contained in the file to downstream filters for further processing, but some source filter would act as a “splitter”, by parsing the data into separate audio and video streams and then pass them down to other filters. Examples of source filters are “File Source” which reads data from a file, “TV tuner filter” which tunes to a TV channel, and “DVD navigator filter” which reads data from a DVD disk. Another example is the Haali Media Splitter, which can decode MP4, AAC, and MKV files (among others).
A transform filter is a filter that accepts media data from an upstream filter, process the data, and passes the data to a downstream filter. Therefore a transform filter must have both input and output pins (there may be more than one set of input and output pins on a given filter). An input pin connects to the output pin of an upstream filter (such as a source filter, which generally has only output pins). An output pin on a transform filter connects to an input pin of a downstream filter , such as a renderer filter, which has only input pins, or another transform filter. A decoder filter is a typical example of a transform filter.
A renderer filter is a component that renders a media stream, and is thus the last stage in DirectShow filter graph. For example an audio renderer is one that sends audio data to a sound card. A video renderer displays video to your computer screen.
To play back a file properly via DirectShow you need both a Source Filter, specific to the file container type (which gives you access to the individual streams), and a Decoder Filter which actually decodes the video stream that the splitter hands it. Generally the Decoder Filters are categorized as Renderer Filters, but sometimes they are Transform Filters which pass data to more general purpose renderers. Generally you'll need one Decoder filter to process each "stream type" that comes out of the Source Filter (though many handle more than one type of stream, like FFDSHOW). Examples of these are the FFDSHOW MPEG-4 Video Decoder (ffdshow.ax), XviD Video Decoder (xvid.ax), the Microsoft MPEG Audio Decoder (quartz.dll), and DirectVobSub (VSFilter.dll).
Sometimes these lines blur, when a particular filter can act as both a splitter and a decoder filter (such as FFDSHOW).
How DirectShow Playback Works in MC
MC supports a number of audio file types natively. When you play back a MP3 file, for example, MC uses it's own internal high-quality filters to split and decode the file and send it to the appropriate output device (sound card). When you attempt to play a file back in MC that it doesn't support natively, MC tries a number of different things to get the file to play. The first step is to attempt to render the file using DirectShow.
By default, if you haven't modified the DirectShow playback configuration options in MC, and you play a file back, it simply asks Windows to build the regular DirectShow graph. This works the same as Windows Media Player and any other DirectShow player does when playing back a file.
The default graph is built based on two factors: a) each individual filter "tells" DirectShow what kinds of media streams it is able to render, and b) DirectShow assigns (or more precisely, the filters assign to themselves when you install them) a priority number called its "merit score".
When you play a file, DirectShow attempts to build a chain of filters capable of decoding the content based on these two pieces of information. It tries filters matching the stream type, in the order of which filter has the highest priority first. If the "render" fails, then it tries the next highest priority set, and so on and so forth until it runs out of options or succeeds. Just because it "works" doesn't mean it's necessarily finding the "best" filter graph. It just uses whichever one it "bumbles" into that works first.
MC's DirectShow Playback settings dialog overrides the priority part of this sequence of events. If you select one or more of those filters, it overrides the normal merit score system (perhaps by temporarily elevating them to the highest possible Merit -- I'm not sure of the details of this mechanism). So, you can force it to "try" to use a different filter to play a file back, but you can't force it to use one or fail outright. If that graph fails (the output pins can't connect to the input pins to build a complete render graph) then it either ignores certain selected filters, or it fails over completely to the default graph. (MC's DirectShow Playback Settings dialog provides essentially identical functionality to ZoomPlayer's "Smart Play" feature.)
I've simplified this a bit for the sake of explanation, but that's the general idea of what happens when you try to play a file back via DirectShow.
2. What version of DirectX do I need?
In order to play media using DirectShow, you must have Microsoft DirectX installed. We recommend DirectX 9.0c to take advantage of features that are available only in late versions. While technically DirectShow itself was removed from the larger DirectX package in April 2005 (and moved to the Microsoft Platform SDK instead), MC still makes use of many DirectX features and it is still critical to ensure that you have installed the most current version of DirectX on your system.
DirectX 9.0c is included as part of the Windows XP Service Pack 2 update, so if you are running Windows XP SP2 it is likely that version is already installed on your computer, and you do not need to do anything in most cases. For earlier versions of Windows operating system, we recommend you download it from Microsoft website and install it.
Windows Vista ships with DirectX 10, which Microsoft says will not be made available for older versions of Windows. DirectX 10 has been completely overhauled from earlier versions. Like all versions of DirectX, it is completely backwards compatible with older versions of DirectX. If you are running Windows Vista, DirectX 10 is what you want to have!
To check which version of DirectX is installed on your computer using the dxdiag tool, please refer to Microsoft KB Article 157730.
3. Why do I need to get DirectShow filters?
In order to play media files in DirectShow, one must have DirectShow filters that can handle the media types to be played. DirectShow comes with some of the filters that are needed, for example video and audio renderers. DirectShow, however, does not include all filters that are needed. You must make sure you have needed filters for the file types you want to play. DirectShow filters come from a variety of sources. We do not, and can not, include all filters that are needed in Media Center‘s installation. In most cases you will need to install decoder filters from other sources. For example in order to play DVD on your computer you must have DVD capable MPEG-2 video decoder, and audio decoder(s) that are capable of decoding MPEG-2 audio and/or AC3 audio formats.
Some computers do come with certain filters installed by the computer vendor. However, the filters preinstalled may not be top-notch filters. In such case it is to your advantage to find and install better filters..
4. How do I install DirectShow filters?
It depends on the filter. Some filters come with an installation program. You just need to execute the program, and the installation wizard will guide you through the process. Most filter packs are installed this way.
Not all filters come with an installation wizard. Instead they are just one or more files with file extension .ax or .dll, often contained in an archival file (ZIP or RAR). In such a case, you can first extract the file(s) into a folder (any folder is fine, for example “C:\Program Files\DirectShow Filters\“ would be a good choice). Then register the filter using Windows program Regsvr32.exe. This program exists on every Windows computer. For example, if you downloaded a filter whose file name is NewFilter.ax, and you place the file in “C:\Program Files\DirectShow Filters\“, you can register it by clicking Start button and choose “Run…” command and enter the following line (including quotes):
regsvr32.exe "C:\Program Files\DirectShow Filters\newfilter.ax"
and click OK. A dialog box should pop up saying "DLLRegisterServer in C:\Program Files\DirectShow Filters\newfilter.ax succeeded", indicating that the filter is now registered with the system.
Some filters may come with two versions of them, a Unicode version and a non-Unicode verion. You should register the Unicode version as Media Center supports Unicode.
You can also unregister a filter, in case you decide you no longer need the filter, by using the command line parameter /U. For example to unregister the filter registered in the above example, you issue this command:
regsvr32.exe /U "C:\Program Files\DirectShow Filters\newfilter.ax"
You will also get a confirmation saying “DllUnRegisterServer in C:\Program Files\DirectShow Filters\newfilter.ax succeeded.”
5. What filters do I need and where do I get them?
The answer depends on what media format you want to play. In general you will need decoder filters and, in many cases, you will also need splitter filters. You can obtain commercial filters from various vendors. You can also get free, open source, filters. In this guide we will tell you about some free filters.
Before getting to individual media formats, it is a good idea to introduce/recommend CCCP, a multi-filter and multi-format decoder package. If all you want is for your video and audio files to work reliably, with a minimum of effort (and no money), then CCCP is probably the way to go.
CCCP - Combined Community Codec Pack
This is a great multiple-filter pack that provides filters for playback of most media formats, including DVD. At the heart of CCCP is FFDSHOW, which is a general purpose DirectShow filter that can be used to decode a large number of media formats. CCCP also includes quite a few other major components, including: MPV video decoder (decodes DVD and other MPEG-2 video), and Haali Media Splitter (handles decoding MP4, MKV, M4A, and a number of other container formats).
This "pack" is probably the single simplest method to get the vast majority of file types to play back properly and reliably. There are a few file types that CCCP does not support out of the box, including Quicktime, RealMedia, and FLV video (though it tries at FLV). Adding support for these file types is described below, though the CCCP Project site has much more information on this topic.
Make sure you read the instructions before installing CCCP. As a general rule, you should uninstall any previously installed codec packs, as different codec packs often conflict with each other. You should also uninstall previously installed individual filters that CCCP includes, such as FFDShow, Haali Media Splitter. This way you will be sure that CCCP can install and configure the filters properly.
Additionally, when installing CCCP, make sure you uncheck the option to install FLV Splitter. The version of FLV splitter included with CCCP does not work well. See "FLV" below.
As mentioned above, CCCP does not include each and every filter you could possibly need to have in order to support your media. The best place to look for more information is on the CCCP Wiki page describing Unsupported Formats. However, here are a few of the big ones:
RealAlternative is a free, open source implementation of the Real playback engine, which handle Real Media file types without having to install the "real" RealPlayer. It is essentially a set of DirectShow filters that allows DirectShow to natively handle RealMedia files. Please note: When installing RealAlternative, you don't need to install MPC again as it's included as part of CCCP (so you can deselect that option during the install).
MC uses Quicktime as its "fallback" rendering engine if DirectShow playback fails. So, it's a good idea to have Quicktime installed even if you don't use any Quicktime Media. Quicktime Player is available for free from Apple. You do not need to choose the version that includes iTunes -- there is still a standalone player version available.
If you choose to install the "real" Quicktime, make sure to manually de-select all the file type Associations possible during the install so it doesn't take over your media files. You can also disable the task tray icon under Edit --> Preferences --> Quicktime Preferences --> Advanced tab --> Install QuickTime icon in system tray from inside Quicktime.
Similar to RealAlternative You can also choose to install QuicktimeAlternative instead of the "real" Quicktime. This will allow Quicktime MOV files to play back via DirectShow. If you choose the Alternative, same as RealAlternative, you don't need to install MPC, as it's included in CCCP.
FLV, flash video, is a format widely used for streaming. For example Google video and YouTube use this format. This format should play correctly in Media Center without user actions. However, if you do have problem playing them, you need to make sure the following filters are properly installed and configured.
To decode the Flash Video Codec: FFDSHOW
You need to configure it so it will decode FLV video. Media Center should configure it for you automatically, but here is how you can do it manually:
Start -> All Programs -> FFDShow (or Combined Community Codec Pack) -> FFDShow Video Decoder Configuration. Choose "Codecs" from the top of the left panel. On the right panel, find FLV1 in the first column ("Format"), and change the value in the second column ("Decoder") from "disabled" to "libavcodec". Click OK.
To install the FLV Splitter: Download and unzip it. Then Register it.
Note: The latest CCCP also includes a version of FLVsplitter that does not work with Google/YouTube videos. You should use the version linked here (built by Celtic Druid), which, in addition to being able to play FLV1 videos from Google/YouTube when used with FFDShow, also includes an FLV Video Decoder filter which decodes FLV4 format (FFDShow decodes FLV1).
While CCCP is the easiest way to get your system working, there are alternatives of course. Below is a list of some of the big alternatives. Many of these are actually components of CCCP, but can all be obtained and used separately. The list below contains both Splitter Filters and Decoder Filters.
FFDShow is a Multi-Format Decoder filter with major Post Processing capabilities. It is essentially a windows DirectShow Filter version of the FFMPEG Codec Project libraries, which are used to support MPEG-2/4 video and audio decoding by many non-DirectShow, cross-platform, applications (such as VLC). Installing FFDSHOW on your system gives you all the power of the FFMPEG codecs in all of the DirectShow player applications installed on your system (including MC of course)!
FFDSHOW acts as a sort of "Swiss Army Knife" filter. It acts as both a Splitter Filter and a Decoder Filter (both Audio and Video). It can be used to decode many video and audio formats beyond it's "original" focus of MPEG-2/4 file types, including: MPEG-4 ASP (Xvid, 3ivX, and DivX) and AVC (H264 and VC1), MPEG-2 (DVD), MPEG-1, H263, VP6 (Flash Video), MP3, AAC, Dolby AC3, FLAC, WMA, and Vorbis among many others. It can also be used to route certain video types through other filters (such as DScaler) for post-processing, and perform many post processing effects itself (de-interlacing, grain removal, noise reduction, sharpening, etc).
CCCP includes FFDShow (so there is no need to install it separately if you use CCCP). If you choose not to install CCCP, you should consider installing FFDShow.
It can be difficult for users to find a good version as there are too many different versions/builds out there.
A fairly stable but older version can be found here (ffdshow-20051129.exe)
People have had good experience with Celtic Druid's builds, which you can find here.
Even newer versions can be found at FFDShow tryouts.
Very good FFDshow primer on AVS: AVS FFDshow Config Primer
Starting with MC 12.0.266, MC now supports using FFDSHOW as a post processing filter for DVD and TV Tuner playback, which provides some very exciting possibilities.
Other MPEG-4 Software Decoders
While FFDSHOW is probably the best choice for the vast majority of people, there are certainly lots of other MPEG-4 Software Decoders available. A few of these can be handy in a few specific instances where FFDSHOW isn't optimal. I am not going to include an exhaustive list of all possibilities, but if you're interested, there is a nice list compiled over at Doom9's forums.
CoreAVC is widely regarded as the fastest MPEG-4 AVC (also known as MPEG-4, Part 10 or H264) software decoder. MPEG-4 AVC video is a newer method of compressing video compared to older MPEG-2 (DVD format) and MPEG-4 ASP (XviD/DivX style) codecs. It has a number of great features, but the primary ability of AVC codecs is to provide much higher quality and fewer artifacts at much lower bitrates (filesizes) than the older codecs allowed. So, essentially, AVC codecs allow you to squeeze those files even smaller without loosing any apparent quality from the original.
MPEG-4 AVC codecs are slowly becoming more and more prevalent. A few common AVC codecs you may encounter are: Nero Digital AVC, Microsoft's VC1 (used on HD-DVDs and BluRay discs), and the open-source x264. AVC codecs are often used for compressing HD content as the better compression algorithms allow the compressionist to squish the very data "heavy" HD content into a much smaller file size without sacrificing quality. If you tried to compress HD content using older MPEG-2 or MPEG-4 ASP codecs, you'd end up with either extremely large files or files with bad visual artifacting.
The downside to these codecs are that they require much more from the host CPU to decode the content. In fact, decoding AVC content is often so demanding that a Pentium 3 CPU will not be able to keep up with decoding even Standard Definition content. High Definition 1080p content heavily compressed using x264 or VC-1 can bring even brand new computers to their knees.
If your computer is struggling to decode AVC compressed content, often using CoreAVC as the decoder instead of FFDSHOW can improve performance dramatically. Unfortunately it is a commercial product and is not free, but it does have very good results and is well supported by the community. More information on the CoreAVC decoder products can be found in the Doom9 thread on the subject.
AMD/ATI Avivo H.264
AMD now provides it's own MPEG-4 decoder with AVC support. If you have an AMD/ATI x1300 series video card or better, you may get the best results using the ATI-supported CyberLink H.264 codec, which enables the hardware acceleration features of your AVIVO video card.
The AMD X2000 series of video cards released in May 2007 further improves upon the H264 hardware assisting technology, though information on the software required to enable this new technology is not yet available at the time of this writing (it is likely that it would be via the same CyberLink codec mentioned above). Apparently the new AVIVO engine in all of the X2000 series cards can offload 100% of the AVC decoding process from the CPU to the video card's harware.
Similar to what ATI/AMD did with their AVIVO initiative, Nvidia included H264 decoding support in hardware in their new midrange GeForce 8500 and 8600 series of video cards, which were released in May 2007. Unfortunately, they have thus far not updated their high-end video cards (including the GeForce 8800 Ultra) to include this technology. You may purchase Nvidia's PureVideo decoders for all supported Nvidia GeForce video cards directly from Nvidia here: .
For DVD playback, you need DVD capable MPEG-2 video decoder and MPEG-2 / AC3 audio decoder. These filters may or may not already exist on your computer. Some computers come with filters for DVD; some do not. Filters may also come with installation of some third-party software. If you do not already have the needed filters, you may need to install them. Commercial decoders are available from various vendors. Free decoders are available and described below.
CCCP can be used for DVD playback (see above).
Alternatively you can try these filters:
DScaler 5. This is still in alpha. Therefore expect to have some problems with it. I have had only one problem though. It is related to DVD menus. I experience menu problem only with one of several DVD movies I played.
Generally DScaler can be used for vastly improved deinterlacing and resizing support, and it's quality is "considered" the best. It can be difficult to get it set up properly.
Gabest Universal Open Source MPEG Video Decoder
Older versions of FFDShow video decoder do not work well with DVD (even though it has user interface to turn on DVD decoding capability). Newer versions maybe able to decode DVD properly. However, because there are still some (relatively minor) issues with DVD decode support in FFDSHOW, CCCP still uses the Gabest Decoders instead, which work quite reliably.
FFDShow Audio decoder works well with DVD.
DScaler 5 (DScaler 5 includes both an audio decoder and a video decoder).
AC3Filter is another good option for decoding AC3 and DTS tracks.
[Be sure to read this FAQ] if you are interested in full support for DTS WAV playback.
Hardware Accelerated Decoders
Both the AMD AVIVO technology and the Nvidia PureVideo technology mentioned above include MPEG-2 decoding support in addition to MPEG-4 support. Both decoders are very high quality and extremely fast, though with modern computer processors the necessity of offloading the relatively simple task of MPEG-2 decoding to the video card is of limited benefit.
AMD's AVIVO decoder in particular has been rated among the highest quality decoders available in independent quality comparisons. AMD's MPEG-2 decoder is available free of charge with many of their video cards (updates are available at AMD's web site). Nvidia's PureVideo product is available for a small fee from their PureVideo site.
MPEG-4 Container Family mp4 / m4a / m4v
In order to play these types of files in DirectShow engine, you will need not only decoder filters but also splitter filters. Generally FFDSHOW would be the best decoder filter for most MPEG-4 video stream types, but you do need a separate application to "split" the MP4 container format to feed FFDSHOW the stream data.
You can use Haali Splitter (which is used in CCCP), or MP4 splitter.
3ivx has a filter pack that includes all filters (splitter and decoders) needed for mp4 type. It is however not free.
Matroska is a modern, extensible open standard A/V container. Matroska is typically found as .MKV files (matroska video) or .MKA files (matroska audio). CCCP is the official codec set for Matroska files, and it is the recommended way to handle these file types.
There are other options of course, Haali Splitter will handle decoding MKV files on it's own.