Mkvmerge does not produce precise PTS values for nanoseconds

I was trying to set the –timestamp-scale so the precision of my MKV would be in nanoseconds. I used the following command:

mkvmerge --output "mkv_timescale_ns.mkv" --timestamp-scale 1 --default-duration 0:24000/1001p "test_video.mkv"

I used ffprobe to inspect the frame:

ffprobe -select_streams 0 -show_entries frame=pts:stream=time_base -print_format json "mkv_timescale_ns.mkv"

First of all, I was surprised that the PTS of frame 3 is 125124999. It should be 125125000. The same issue occurs with 166833332, which should be 166833333.

I used the following equation to calculate the theoretical time:

\text{time (in ns)} = \text{frame} \times {1 \over {24000 \over 1001}} \times 10^9

Secondly, I wanted to extract the timestamps with mkvextract:

mkvextract "mkv_timescale_ns.mkv" timestamps_v2 0:time.txt

It produced the following output:

# timestamp format v2
0
41.708333
83.416666
125.124999
166.833332
208.541665
...

I was surprised because the precision is in microseconds, not nanoseconds, resulting in some loss of information.

So, is it a bug or simply a limitation and the maximum precision I should use for a mkv file is microseconds?

Edit: Here is the video: 450.9 KB file on MEGA

@mbunkus Hi, I was wondering if you have missed my question and/or this is a trivial case that isn’t a priority?

The other way around; this is a rather complex topic that I simply am not motivated to spend time on.

1 Like