Answers.Body: <p>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 href="https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2021-May/280460.html" rel="nofollow noreferrer">a patch</a> to fix this, but it doesn't appear to be merged)</p>
  <p>Instead of ffmpeg, you can use the <code>mkvmerge</code> parameter <code>--timestamp-scale</code> to change the time base as nanoseconds. For example, for a tbn of 90000, use <code>--timestamp-scale 11111</code>, 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.</p>
  <p>See <a href="https://mkvtoolnix.download/doc/mkvmerge.html" rel="nofollow noreferrer">https://mkvtoolnix.download/doc/mkvmerge.html</a> for details about <code>mkvmerge</code> usage</p>
  <p>See also <code>TimestampScale</code> in <a href="https://www.matroska.org/technical/notes.html" rel="nofollow noreferrer">https://www.matroska.org/technical/notes.html</a> about the format</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-01T14:31:15.117Z
Answers.LastActivityDate: 2023-05-01T14:31:15.117Z
Answers.UserDisplayName: goweon
Body: <p>I'm trying to change the tbn of a mkv file.</p>
  <p>Here is the command I typed.</p>
  <blockquote>
  <p>ffmpeg -i a.mkv -video_track_timescale 90000 -c copy a_9ktbn.mkv</p>
  </blockquote>
  <p>But timebase didn't change</p>
  <pre><code>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 -&gt; #0:0 (copy)
    Stream #0:1 -&gt; #0:1 (copy)
  </code></pre>
  <p>Below is the result of ffprobe</p>
  <pre><code>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
  </code></pre>
  <p>tbn didn't change.</p>
  <p>Also I found it weird that log of the ffmpeg command says tbc of output file is 1k, Whereas ffprobe say it is 120.</p>
  <p>I tried same thing on a ts file, It didn't worked too.</p>
  <p>Is it impossible to change the tbn of a mkv(+ts) file?</p>
  
Tags: <ffmpeg>
Title: changing timebase of mkv file
UserDisplayName: helming
ThreadText: # changing timebase of mkv file
  
  (Asked by: username_0 on 2021-12-27)
  
  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?
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-01. Score: 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](https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2021-May/280460.html) 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
  
  
  ---
  
  