2

I'm trying to change the tbn of a mkv file.

Here is the command I typed.

ffmpeg -i a.mkv -video_track_timescale 90000 -c copy a_9ktbn.mkv

But timebase didn't change

Input #0, matroska,webm, from 'a.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:00:41.64, start: 0.000000, bitrate: 4647 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      DURATION        : 00:00:41.640000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:41.600000000
Output #0, matroska, to 'a_9ktbn.mkv':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:00:41.640000000
    Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:41.600000000
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)

Below is the result of ffprobe

Input #0, matroska,webm, from 'a_9ktbn.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:00:41.64, start: 0.000000, bitrate: 4647 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      DURATION        : 00:00:41.639000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:41.600000000

tbn didn't change.

Also I found it weird that log of the ffmpeg command says tbc of output file is 1k, Whereas ffprobe say it is 120.

I tried same thing on a ts file, It didn't worked too.

Is it impossible to change the tbn of a mkv(+ts) file?

1 Answer 1

1

Although the Matroska format supports up to nanosecond precision timestamps, currently ffmpeg only seems to support milisecond timestamps, which is the default value. (There is a patch to fix this, but it doesn't appear to be merged)

Instead of ffmpeg, you can use the mkvmerge parameter --timestamp-scale to change the time base as nanoseconds. For example, for a tbn of 90000, use --timestamp-scale 11111, since 1000000ns / 90000 = 11111.111111ns. Note however that it's impossible to get exact precision timestamps with the mkv format when you have a timebase that is a multiple of 3 since you will have repeating decimals, but all timestamps are rounded to nanoseconds.

See https://mkvtoolnix.download/doc/mkvmerge.html for details about mkvmerge usage

See also TimestampScale in https://www.matroska.org/technical/notes.html about the format

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.