I have a Matroska (.mkv) file with the following tracks (data streams):
Tracks : 2
Track 1 : Video
- Codec : (V_MPEG4/ISO/AVC)
Track 2 : Audio
- Codec : MPEG Audio 1, 2, 2.5 Layer III (A_MPEG/L3)
Nothing particularly special there; I have the following relevant DirectX Media Objects (DMOs), DirectShow and Media Foundation codecs installed:
-
Haali Media Splitter: a DirectShow splitter filter for Matroska files, among other container formats (analogous to the AVI Splitter for .avi and others).
-
ffdshow: a DirectShow decoder filter for just about anything, including MPEG-4 Video and MPEG-1 Audio Layer 3 (MP3).
-
Windows 7's in-box DMOs decoder filters for MPEG-4 Video and MP3. These can be used by both DirectShow and Media Foundation.
Question: What happens if this Matroska file is played in Windows Media Player or Windows Media Center?
Answer: No video and audio stutters a lot.
Question: Why?
Answer: Both will try to use Media Foundation first and DirectShow second. As Media Foundation has no preferred splitter for Matroska files (either in-box or that I've installed), it hunts for a supported transform (similar to DirectShow's filters) with which to play the file; the MP3 transform duly indicates that it can play the file.
I believe this is because the MP3 decoder ignores the data at the start of the file which it doesn't understand (to allow for ID3 tags) and then picks up the first frame of the audio stream inside the file. The stuttering is most likely it attempting to play back the video frames of data (the two data streams are interleaved within the container).
The solution: Amazingly simple; the only thing that matters is that they're trying to use Media Foundation first, so set one registry key to indicate .mkv files prefer to be handled by DirectShow and it works great in both players.
HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\Extensions\.mkv
Runtime REG_DWORD 0x7
Done.
10:27PM on Sunday, 13 June, 2010
10:27PM on Sunday, 13 June, 2010
Media Foundation, Matroska and MP3
2010-06-13T22:27:12Z
2010-06-13T22:27:12Z
2010-06-13T22:27:12Z