[FFmpeg-user] concat demuxer and 'strange' mp4s with wrong TBN

Gyan Doshi gyandoshi at gmail.com
Wed Aug 22 10:34:45 EEST 2018


On 22-08-2018 12:51 PM, Gabriele Greco wrote:

> 
> file1.mp4 has the following video track:
>      Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D),
> yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5000 kb/s, 30 fps, 30 tbr, 600 tbn,
> 30 tbc (default)
> 
> file2.mp4 has the following video track:
>      Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D),
> yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 4979 kb/s, 30 fps, 30 tbr, 15360 tbn,
> 30 tbc (default)
> 
> As you can see TBN for the second file is wrong, don't ask me why, we get
> videos of every format from our customers...


> usual call:
> ffmpeg -f concat -safe 0 -i inputs.txt -c copy test.mp4


The TBN of the 2nd file isn't wrong. It's likely been muxed with ffmpeg 
which will set a timebase > 10000 when the caller doesn't set one manually.

The concat demuxer's behaviour shouldn't be changed since the stream may 
be variable frame rate in which case using tbr will destroy the variable 
timing, leading to possible desync with the audio.

The workaround is to rescale all inputs to the concat demuxer to the 
same timebase,

     ffmpeg -i in.mp4 -map 0 -c copy -video_track_timescale X out.mp4

where X is the same value used for all files, and ideally the highest 
found among all inputs.


Gyan


More information about the ffmpeg-user mailing list