0

I changed my video container with:
ffmpeg -hide_banner -y -i in.mkv -c copy -video_track_timescale 1k out.mp4
But video_track_timescale only changes video tbn, not audio tbn.

To check it:
ffprobe -hide_banner .\in.mkv -read_intervals %+0.3 -show_entries frame=media_type,key_frame,pts,pts_time,pkt_duration,pkt_size -print_format compact

frame|media_type=video|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=16|pkt_size=203501|side_data|
side_data|

frame|media_type=audio|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=N/A|pkt_size=622
frame|media_type=video|key_frame=0|pts=17|pts_time=0.017000|pkt_duration=16|pkt_size=5333
frame|media_type=audio|key_frame=1|pts=21|pts_time=0.021000|pkt_duration=21|pkt_size=551
frame|media_type=video|key_frame=0|pts=33|pts_time=0.033000|pkt_duration=16|pkt_size=1221
frame|media_type=audio|key_frame=1|pts=43|pts_time=0.043000|pkt_duration=21|pkt_size=538
frame|media_type=video|key_frame=0|pts=50|pts_time=0.050000|pkt_duration=16|pkt_size=12132
frame|media_type=audio|key_frame=1|pts=64|pts_time=0.064000|pkt_duration=21|pkt_size=662

ffprobe -hide_banner .\out.mp4 -read_intervals %+0.3 -show_entries frame=media_type,key_frame,pts,pts_time,pkt_duration,pkt_size -print_format compact

frame|media_type=video|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=16|pkt_size=203501|side_data|
side_data|

frame|media_type=audio|key_frame=1|pts=0|pts_time=0.000000|pkt_duration=1024|pkt_size=622
frame|media_type=video|key_frame=0|pts=17|pts_time=0.017000|pkt_duration=16|pkt_size=5333
frame|media_type=audio|key_frame=1|pts=1024|pts_time=0.021333|pkt_duration=1024|pkt_size=551
frame|media_type=video|key_frame=0|pts=33|pts_time=0.033000|pkt_duration=16|pkt_size=1221
frame|media_type=audio|key_frame=1|pts=2048|pts_time=0.042667|pkt_duration=1024|pkt_size=538
frame|media_type=video|key_frame=0|pts=50|pts_time=0.050000|pkt_duration=16|pkt_size=12132
frame|media_type=audio|key_frame=1|pts=3072|pts_time=0.064000|pkt_duration=1024|pkt_size=662

As we can see, in in.mkv, tbn is same for both audio/video aka 1k. But in out.mp4, tbn is different. Video has 1k tbn because I set it with -video_track_timescale, but where's the similar option for audio?

1 Answer 1

1

There's no such option for audio in MP4. MKV uses a fixed timescale of 1000 which is why audio has that tbn. In MP4, ffmpeg will set it to the sample rate.

The latter is precise. Notice the timestamps for audio in MKV are not evenly spaced:

pts=0|pts_time=0.000000
pts=21|pts_time=0.021000
pts=43|pts_time=0.043000
pts=64|pts_time=0.064000

Compare with MP4, which are:

pts=0|pts_time=0.000000
pts=1024|pts_time=0.021333
pts=2048|pts_time=0.042667
pts=3072|pts_time=0.064000
1
  • Note that even though you said There's no such option for audio in MP4, it can be done. It's just that it's not implemented.
    – kwjsksai
    May 11, 2023 at 18:08

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.