| MPEG, DirectShow, Windows Media and Filter Merit |
|
Windows Media Player uses DirectShow filters to perform playback and recording functions.
Windows Media Player (WMP) is typically reliable in playing back most basic types of formats,
through the support of specialized filter plug ins. However, this plug in architecture
can introduce problems, some of which can freeze in playback of MPEG files for many reasons.
Typical Problems with MPEG (i.e. MPEG1, MPEG2, DVD) Playback 1. hardware accelerated video playback, primarily with older video cards. The only way to fix this problem is to install a new video card. 2. In pseudo streaming mode (clicking on an internet link), there seems to be an issue with playing back VBR (variable bit rate) files, where the average bit rate of the mpeg files is higher or lower than indicated in the initial MPEG headers. This will show up as the file length being under or over-estimated, and frequently results in the video playback freezing part way through playback. This is a known issue with windows media player and the primary way to solve this is to re-encode the video content (which is often not an option). 3. Extremely long seeks, inaccurate seeks, or hanging on seeks on DVDs or MPEG2 files. MPEG2 has CBR (constant bit rate) and VBR (variable bit rate) streams. In a VBR stream it is difficult to predict where to seek to, and a particular filter may try to decode all of the frames in between two points. If these two points are extremely far from each other this process can take an extremely long time. Obviously, this is not ideal. Also, no directshow filters currently available are capable of performing frame accurate seeking, meaning that they are useless for any sort of video editing task natively. After doing seek testing on many products, I have found that Cyberlink PowerDVD, Intervideo WinDVD, and Sonic all handle DVDs and seeking well without crashing or hanging. Only Sonic has filters both for DVD and MPEG2 streams without DVD (annex J) information in them. However, Elecard MPEG2 is the best at handling MPEG2 streams, but cannot handle DVD properly. I have also had good experiences with MainConcept's MPEG2 encoder pack, but I have not performed seek testing on those filters. Unlike MainConcept's OEM'd filters (as described below) those purchased directly don't introduce problems with WMP. Note that most DVD products load specific filters and won't have any problems outside of WMP. However, WMP on it's own may load the wrong components and that will hamper playback. Sonic is the vendor that has this issue worked out to the greatest extent. The main way to handle this issue is to install a good DVD player and uninstall all other players. I recommend Sonic for DVD/MPEG2 playback. For MPEG1 playback, I recommend using the default drivers. I have also installed MPEG2 encoding filter packages from mainconcept downloaded from their site directly, without any ill effects. 4. Clicking on an Internet link to an MPEG1 causes the browser to freeze up. This is usually due to a non-default filter getting in the way. A number of third party applications install MPEG DirectShow filters that override the default mpeg filters. Filters known to cause this issue include: a. MainConcept MPEG file installed by a number of MPEG editing tools, including Adobe: mcdsmpeg.ax, mcspmpeg.ax b. XingMPEG Player: encwdm.ax c. Ligos is installed with ULead or DVDIt: mplapx.dll This problem can be diagnosed/fixed as follows: a. Reprioritize the filters. This is the best solution, as it addresses the actual problem. First, you need to find out which filters DirectShow will use, so you can identify which one is causing the problem. Right click and save as this utility to review the MPEG1, MPEG2 video/audio directshow filters. This is just a hack on the Mapper DirectShow program. Download the source code for the directshow mapper utility if you would rather compile it yourself. Basically, Directshow will select the filter with the highest merit, and so once you have completed a search you should be able to quickly see which filter will be used and is causing the problem. Once you have figured this out you can change the filter merit with this program from softella to MERIT_DO_NOT_USE. Programs that load those filters specifically will still be able to do so, and DirectShow will ignore them, thus making WMP work properly again. b. Unregister interfering filters using: "regsvr32 /u %path%\file.ax". You can always re-register them using: "regsvr32 %path%\file.ax". example: regsvr32 c:\encwdm.ax. This is annoying because it could cause other programs to randomly break. Upon reinstalling those programs, you will just have the same problem again. c. Uninstalling the software that installed the interfering filter, or reinstall WMP. This will fix most MPEG1 issues. However, DVD/MPEG2 filters are not installed by default on windows, so you may need to re-install some programs. Obviously, this is annoying and is not even guaranteed to work. Instructions for Mapper Utility (for #4.c. above) mapper utility mapper utility code The filter priority of Unlikely is essentially the minimum filter merit that is required for DSHOW to include a decoder in the auto discovery process, so I set that as the default- generally the filter selected will be of a higher merit. Otherwise, all you need to do is set the input pin major type- in this case audio and video are all that matter. As for the subtypes, both probably need to be searched- For example, for MPEG1 select "MPEG1 Audio Packet" in subtype dialog 1 and "MPEG1 Audio Payload" in subtype dialog 2 for audio, or "MPEG1 Video Packet" in subtype dialog 1 and "MPEG1 Video Payload" in subtype dialog 2 for video. Then click "Search" and a list of filters (names, locations, merits) will be listed. The filter with the largest merit wins. Technical Info on Filter Merit DirectShow filters are selected according to what media types they proclaim to support, and based on their merit values, which helps in the selection process relative to other similar filters. This filter information is packed into a binary format in the windows registry, and is primarly accessed using the EnumMatchingFilters() method. The IFilterMapper2 interface unpacks this data when it searches the registry for a filter. The pin media type (MajorType and SubType) parameters for input and output pins are passed in an array to the EnumMatchingFilters() method. A minimum merit of MERIT_DO_NOT_USE + 1 is required for EnumMatchingFilters() to include a filter in its search, and filters with a merit of MERIT_DO_NOT_USE or less are ignored. Filters are also grouped into categories (defined by GUID) each of which has a merit. EnumMatchingFilters() ignores any category with a merit of MERIT_DO_NOT_USE or less. In the code below, Category is the GUID of a filter category. Once the enumeration is retrieved, you can use the IAMFilterData interface to retrieve/set/re-set the information the filter was registered with, including the merit. IAMFilterData methods are CreateFilterData and ParseFilterData. This is important because improperly setting the MERIT of a filter is the cause of many DirectShow/Windows Media playback issues. MSDN Links guidelines for registering filters how to register filters layout of registry keys guidelines for registering filters ifiltermapper2
enum
{
MERIT_PREFERRED = 0x800000,
MERIT_NORMAL = 0x600000,
MERIT_UNLIKELY = 0x400000,
MERIT_DO_NOT_USE = 0x200000,
MERIT_SW_COMPRESSOR = 0x100000,
MERIT_HW_COMPRESSOR = 0x100050
};
HKEY_CLASSES_ROOT
CLSID
Category
Instance
Filter CLSID
REG_SZ: CLSID = Filter CLSID
REG_BINARY: FilterData = Filter information
REG_SZ: FriendlyName = Friendly name
HKEY_CLASSES_ROOT
CLSID
Category
Instance
Filter CLSID
REG_SZ: CLSID = Filter CLSID
REG_BINARY: FilterData = Filter information
REG_SZ: FriendlyName = Friendly name
HKEY_CLASSES_ROOT\CLSID\{DA4E3DA0-D07D-11d0-BD50-00A0C911CE86}\Instance
HRESULT IFilterMapper2::EnumMatchingFilters(
IEnumMoniker **ppEnum,
DWORD dwFlags,
BOOL bExactMatch,
DWORD dwMerit,
BOOL bInputNeeded,
DWORD cInputTypes,
const GUID *pInputTypes,
const REGPINMEDIUM *pMedIn,
const CLSID *pPinCategoryIn,
BOOL bRender,
BOOL bOutputNeeded,
DWORD cOutputTypes,
const GUID *pOutputTypes,
const REGPINMEDIUM *pMedOut,
const CLSID *pPinCategoryOut
);
---------------------------
MPEG-1 Audio Decoder Filter
---------------------------
Input Pin Media Types:
- MEDIATYPE_Audio
- FORMAT_WaveFormatEx
The following subtypes are valid:
- MEDIASUBTYPE_MPEG1Packet
- MEDIASUBTYPE_MPEG1Payload
- MEDIASUBTYPE_MPEG1AudioPayload
---------------------------
MPEG-1 Video Decoder Filter
---------------------------
Input Pin Media Types:
- MEDIATYPE_Video
- FORMAT_MPEGVideo
The following subtypes are valid:
- MEDIASUBTYPE_MPEG1Packet
- MEDIASUBTYPE_MPEG1Payload
---------------------------
|