4 Wrong frame rate displayed
Moritz Bunkus edited this page 2017-12-16 17:34:13 +01:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Why is the FPS/frame rate wrong?

The problem

The frame rate of a Matroska file is sometimes double the value I'm expecting, e.g. 50 FPS. Sometimes it's some weird value like 35.7FPS. What's wrong here?

The answer

The Matroska file format does not know a header field that contains the information you want. Several pieces of software try therefore to guess/derive that information from other header fields, but often fail. The information is simply not there simply because it is not needed for playback which can work just fine without that information.

First of all, the Matroska specifications do not know about a concept called "FPS" or "frame rate". What they do know is a concept called "default duration" which is often mistaken for the frame rate of a video track. This interpretation is often correct, but often enough it isn't.

Here's the deal. In Matroska each and every packet of a track has a duration. In order to save space the duration is often not encoded with each packet. Instead the header field "default duration" is set to a value that applies to all packets that do not override this value explicitly.

For progressive video content the reverse of this element 1 / default duration often matches the perceived frame rate.

However, there are several cases in which it simply does not match up and it is not supposed to. For example:

  • With interlaced content a single Matroska packet might not store a whole frame but only one of its two fields. In such cases the duration of a field is obviously only half of the duration of a full frame. Therefore the reverse 1 / default duration is more like double the value the user would expect as a frame rate.
  • With variable frame rate (e.g. if an external timecode file is used) video the default duration is calculated in a totally different way. mkvmerge calculates the duration for all frames according to the timecode file, counts how often each duration occurs and then uses the duration that occurs the most as the new default duration. This may be a value that doesn't even reverse to any of the often-used frame rates that people are used to.

Unfortunately there are a lot of tools out there that simply present this number 1 / default duration as the alleged frame rate even though Matroska doesn't provide that information (the frame rate). MediaInfo is one of them though this is due to a bug in the Matroska specs causing confusing among developers.

MediaInfo also provides an "original frame rate" for some video codecs, especially h.264. The information displayed there is also not provided by the Matroska container. Instead MediaInfo gets this directly from the h.264 bitstream. Matroska has nothing to do with it.

Note for nitpickers: Yes, the specs contain an element called FrameRate. However, this element is deprecated and not supported by any known player.

Categories: playback, metadata