FFmpeg preserving CFR during TS to MP4 conversion
|Reported by:||zer0z||Owned by:|
|Cc:||firstname.lastname@example.org, email@example.com||Blocked By:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
Summary of the bug: Problem due to technical limitation of TS format, duration are rounded and this rounding is not detected during TS to MP4 (not a bug, only a lack of feature). Instead FFmpeg should detect the CFR in TS to MP4 conversion and create a CFR stts atom. Instead of the actual stts (time table) atom which takes lot of space and which is not CFR stricly speaking.
I convert MP4 to TS, which has a hard coded (spec) frequency of 90 000 Hz. ffmpeg converts it as it can, with some rounding (in my time time line: sometime 3754, sometime 3753, but the real duration should be 3753.75, and Ts accepts no decimal).
Then I convert it back to MP4, and ffmpeg does not understand it is CFR, so it provides the same rounding. Resultant file ends up as VFR.
How to reproduce:
From ffmpeg wiki:
If you have MP4 files, these could be losslessly concatenated by first transcoding them to mpeg transport streams. With h.264 video and AAC audio, the following can be used:
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
I convert 1.mp4, 2.mp4, 3.mp4 (all encoded at CFR) with above method to .ts. Then issue:
ffmpeg -i "concat:1.ts|2.ts|3.ts" -c copy -bsf:a aac_adtstoasc merged.mp4
Due to the above issue the result from concat will be VFR:
Frame rate mode : Variable
Frame rate : 23.976 fps
Minimum frame rate : 23.968 fps
Maximum frame rate : 23.981 fps
If this can be looked into and hopefully resolved to preserve the Constant frame rate I would really appreciate it.
Change History (21)
comment:2 by , 6 years ago
|Component:||ffmpeg → undetermined|
|Priority:||normal → wish|
|Version:||1.0.10 → unspecified|