4

Edit: This question might also have been phrased: Why do I get a constant frame rate using ffmpeg 3.4 when ffmpeg 8 gives a variable frame rate, using the same command?

I have a short test input file with video specs as follows:

Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 13 s 840 ms Bit rate mode : Variable Bit rate : 5 652 kb/s Maximum bit rate : 7 605 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 50.145 FPS Minimum frame rate : 16.667 FPS Maximum frame rate : 90 000.000 FPS Original frame rate : 50.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.122 Stream size : 9.32 MiB (98%) Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Codec configuration box : avcC 

Note: Variable frame rate.

Using FFmpeg version 3.4.11-0ubuntu0.1+esm9 with a command :

ffmpeg -i input.mp4 -c:v libx264 -crf 23 out.mp4 

Gives a (good) output file with this mediainfo and no dropped frames:

Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 10 s 20 ms Bit rate : 5 279 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 50.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.115 Stream size : 6.31 MiB (97%) Writing library : x264 core 152 r2854 e9a5903 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Codec configuration box : avcC 

Note: FFmpeg 3.4.11 Constant frame rate, smooth video, good result.

However, using FFmpeg version 8.0, with the same input file and command line, duplicates no frames, drops 186 frames and produces a (bad) jerky file with this mediainfo:

Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 9 s 980 ms Source duration : 10 s 20 ms Bit rate : 4 558 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 31.238 FPS Minimum frame rate : 16.667 FPS Maximum frame rate : 50.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.158 Stream size : 5.43 MiB (97%) Source stream size : 5.44 MiB (97%) Writing library : x264 core 165 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 mdhd_Duration : 9980 Codec configuration box : avcC 

Note: FFmpeg 8.0 variable frame rate, no duplicate frames, 186 dropped frames and jerky video. Bad result.

Adding fps_mode to the command line:

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -fps_mode cfr out.mp4 

Gives a file with 187 duplicate frames, 186 dropped frames, and a jerky video:

Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 10 s 0 ms Bit rate : 4 611 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 50.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.100 Stream size : 5.50 MiB (97%) Writing library : x264 core 165 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Codec configuration box : avcC 

Note: FFmpeg 8.0 Constant frame rate, jerky video. Bad result.

The question is: How do I get the same result with FFmpeg 8.0 as I was getting with FFmpeg 3.4.11?


Update 1: For completeness I also ran with -fps_mode passthrough:

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -fps_mode passthrough out.mp4 

Which gave a lot of errors of this type:

Non-monotonic DTS; previous: 1024, current: 1024; changing to 1025. This may result in incorrect timestamps in the output file. 

And a variable rate output file with jerky video.

Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 9 s 960 ms Source duration : 10 s 20 ms Bit rate : 5 594 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 49.800 FPS Minimum frame rate : 16.667 FPS Maximum frame rate : 12 800.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.122 Stream size : 6.65 MiB (97%) Source stream size : 6.68 MiB (97%) Writing library : x264 core 165 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 mdhd_Duration : 10020 Codec configuration box : avcC 

Update 2: Added the output of ffmpeg -i input.mp4 as requested:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf62.3.100 Duration: 00:00:10.04, start: 0.000000, bitrate: 5656 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 5513 kb/s, 50 fps, 50 tbr, 90k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] At least one output file must be specified 
12
  • 1
    Generally the output of ffmpeg -i FILE is more useful when debugging ffmpeg operations. Commented Oct 16 at 4:31
  • Thank you for the interest. I've added this as an edit. I hope it's useful. Commented Oct 17 at 3:17
  • Try ffmpeg -i input.mp4 -c:v libx264 -crf 23 -enc_time_base -1 -fps_mode passthrough out.mp4 Commented Oct 17 at 4:29
  • 1
    2) I've found that I can get the same output using V8 with this command: ffmpeg -r50 -i input.mp4 -c:v libx264 -crf 23 out.mp4. Wondering why/when it changed. Commented Oct 26 at 9:13
  • 1
    @1NN I just cut the last 2 minutes of the actual file to use as a test, and that's what came out. No idea why the max frame rate is that, but it seems to happen every time. You're right, changing the container to mkv before transcoding gives the desired constant FR . Thank you. Commented Nov 4 at 5:35

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.