[FFmpeg-user] Respect to tbr causes inferior quality and increased file size

Ulf Zibis Ulf.Zibis at CoSoCo.de
Thu Aug 26 00:02:12 EEST 2021


Hi,

I have learned, that ffmpeg respects a given tbr value as output frame rate.

Now I'm questioning the advantage of that behaviour. Can someone tell me?

I only see disadvantages:
- the video becomes encoded with lower quality, i.g. q=33.0 instead q=29.0
- the video size is 13 % bigger, e.g. 52253kB instead 46361kB
- each frame is quadrupled to the output

Below see my examples ...

$ ffmpeg -t 7:30 -i "Original 14.mp4" -vf crop=640:320:640:176 -c:a copy -movflags faststart "output 7_30_crop.mp4"
ffmpeg version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2021 the FFmpeg developers
   built with gcc 8 (Debian 8.3.0-6)
   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Original 14.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Duration: 00:14:00.03, start: 0.000000, bitrate: 2413 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 2342 kb/s, 29.98 fps, 120 tbr, 90k tbn, 2k tbc (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
   Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x605a700] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 0x605a700] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x605a700] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: 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=3 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
Output #0, mp4, to 'output 7_30_crop.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 640x320, q=2-31, 120 fps, 15360 tbn (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
       encoder         : Lavc58.134.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
frame=    1 fps=0.0 q=0.0 size=       0kB time=00:00:00.07 bitrate=   4.8kbits/s
frame=   69 fps=0.0 q=33.0 size=       0kB time=00:00:00.65 bitrate=   0.6kbits/
frame=  109 fps= 88 q=33.0 size=       0kB time=00:00:00.99 bitrate=   0.4kbits/
frame=  153 fps= 85 q=33.0 size=       0kB time=00:00:01.35 bitrate=   0.3kbits/
frame=  189 fps= 81 q=33.0 size=       0kB time=00:00:01.65 bitrate=   0.2kbits/
frame=  225 fps= 78 q=33.0 size=       0kB time=00:00:01.95 bitrate=   0.2kbits/
[.......]
[mp4 @ 0x602ad80] Starting second pass: moving the moov atom to the beginning of the file
frame=54003 fps= 63 q=-1.0 Lsize=   56837kB time=00:07:30.00 bitrate=1034.7kbits/s dup=40512 drop=0 speed=0.523x
video:52253kB audio:3468kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.002371%
[libx264 @ 0x605a700] frame I:224   Avg QP:24.11  size: 43287
[libx264 @ 0x605a700] frame P:13845 Avg QP:27.39  size:  2956
[libx264 @ 0x605a700] frame B:39934 Avg QP:34.70  size:    72
[libx264 @ 0x605a700] consecutive B-frames:  0.8%  1.5%  0.8% 96.9%
[libx264 @ 0x605a700] mb I  I16..4:  1.0% 47.3% 51.7%
[libx264 @ 0x605a700] mb P  I16..4:  0.2%  1.0%  0.2%  P16..4: 24.7% 11.7%  9.8%  0.0%  0.0%    skip:52.5%
[libx264 @ 0x605a700] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 8.5%  0.1%  0.0%  direct: 0.0%  skip:91.3%  L0:48.1% L1:49.9% BI: 2.1%
[libx264 @ 0x605a700] 8x8 transform intra:58.5% inter:52.5%
[libx264 @ 0x605a700] coded y,uvDC,uvAC intra: 82.9% 78.0% 40.6% inter: 4.8% 2.3% 0.1%
[libx264 @ 0x605a700] i16 v,h,dc,p: 25% 31%  8% 36%
[libx264 @ 0x605a700] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 20% 12% 6%  6%  7%  8% 10% 10%
[libx264 @ 0x605a700] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 10% 6%  8%  9%  8%  8%  9%
[libx264 @ 0x605a700] i8c dc,h,v,p: 50% 21% 19%  9%
[libx264 @ 0x605a700] Weighted P-Frames: Y:4.2% UV:0.9%
[libx264 @ 0x605a700] ref P L0: 76.1% 12.0%  8.4%  2.9%  0.5%
[libx264 @ 0x605a700] ref B L0: 92.6%  6.7%  0.7%
[libx264 @ 0x605a700] ref B L1: 94.4%  5.6%
[libx264 @ 0x605a700] kb/s:951.17

$ ffprobe "output 7_30_crop.mp4"
ffprobe version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2021 the FFmpeg developers
   built with gcc 8 (Debian 8.3.0-6)
   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output 7_30_crop.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Duration: 00:07:30.03, start: 0.000000, bitrate: 1034 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x320, 951 kb/s, 120 fps, 120 tbr, 15360 tbn, 240 tbc (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]

$ ffmpeg -t 7:30 -i "Original 14.mp4" -vf crop=640:320:640:176 -r 29.98 -c:a copy -movflags faststart "output 7_30_crop_29_98.mp4"
ffmpeg version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2021 the FFmpeg developers
   built with gcc 8 (Debian 8.3.0-6)
   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Original 14.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Duration: 00:14:00.03, start: 0.000000, bitrate: 2413 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 2342 kb/s, 29.98 fps, 120 tbr, 90k tbn, 2k tbc (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
File 'output 7_30_crop_29_98.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
   Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x6876f00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 0x6876f00] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 0x6876f00] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: 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=3 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
Output #0, mp4, to 'output 7_30_crop_29_98.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 640x320, q=2-31, 29.98 fps, 11992 tbn (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
       encoder         : Lavc58.134.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
frame=    1 fps=0.0 q=0.0 size=       0kB time=00:00:00.07 bitrate=   4.8kbits/s
frame=   57 fps=0.0 q=29.0 size=       0kB time=00:00:01.99 bitrate=   0.2kbits/
frame=   80 fps= 65 q=29.0 size=       0kB time=00:00:02.76 bitrate=   0.1kbits/
frame=  108 fps= 62 q=29.0 size=     256kB time=00:00:03.70 bitrate= 566.0kbits/
frame=  133 fps= 59 q=29.0 size=     256kB time=00:00:04.47 bitrate= 468.8kbits/
[.......]
[mp4 @ 0x685e100] Starting second pass: moving the moov atom to the beginning of the file
frame=13491 fps= 54 q=-1.0 Lsize=   50283kB time=00:07:29.99 bitrate= 915.4kbits/s dup=345 drop=345 speed=1.81x
video:46361kB audio:3468kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.909383%
[libx264 @ 0x6876f00] frame I:63    Avg QP:22.04  size: 45591
[libx264 @ 0x6876f00] frame P:8991  Avg QP:24.68  size:  4402
[libx264 @ 0x6876f00] frame B:4437  Avg QP:31.12  size:  1133
[libx264 @ 0x6876f00] consecutive B-frames: 51.3% 12.8%  5.6% 30.3%
[libx264 @ 0x6876f00] mb I  I16..4:  1.8% 48.5% 49.7%
[libx264 @ 0x6876f00] mb P  I16..4:  0.1%  1.4%  0.4%  P16..4: 24.5% 12.3% 12.4%  0.0%  0.0%    skip:48.9%
[libx264 @ 0x6876f00] mb B  I16..4:  0.1%  0.6%  0.1%  B16..8: 33.0%  6.9%  1.5%  direct: 2.1%  skip:55.7%  L0:41.4% L1:45.8% BI:12.8%
[libx264 @ 0x6876f00] 8x8 transform intra:66.7% inter:49.7%
[libx264 @ 0x6876f00] coded y,uvDC,uvAC intra: 78.4% 71.3% 29.5% inter: 17.9% 8.7% 0.6%
[libx264 @ 0x6876f00] i16 v,h,dc,p: 25% 30%  7% 38%
[libx264 @ 0x6876f00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 21% 12% 6%  6%  7%  8% 10%  9%
[libx264 @ 0x6876f00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 12% 6%  7%  8%  8%  8%  8%
[libx264 @ 0x6876f00] i8c dc,h,v,p: 53% 19% 19%  8%
[libx264 @ 0x6876f00] Weighted P-Frames: Y:1.5% UV:0.6%
[libx264 @ 0x6876f00] ref P L0: 83.1% 10.8%  5.2%  0.8%  0.1%
[libx264 @ 0x6876f00] ref B L0: 92.6%  6.5%  0.9%
[libx264 @ 0x6876f00] ref B L1: 98.4%  1.6%
[libx264 @ 0x6876f00] kb/s:843.97

$ ffprobe "output 7_30_crop_29_98.mp4"
ffprobe version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2021 the FFmpeg developers
   built with gcc 8 (Debian 8.3.0-6)
   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output 7_30_crop_29_98.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.76.100
   Duration: 00:07:30.02, start: 0.000000, bitrate: 915 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x320, 843 kb/s, 29.98 fps, 29.98 tbr, 11992 tbn, 59.96 tbc (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]
   Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 63 kb/s (default)
     Metadata:
       handler_name    : VideoHandler
       vendor_id       : [0][0][0][0]

-Ulf



More information about the ffmpeg-user mailing list