[FFmpeg-user] Encoding CBR with libx264

Sareyka, Julian Julian.Sareyka at br.de
Thu Feb 5 19:18:33 CET 2015


Hello all,

I am trying to encode video for adaptive streaming and need CBR for that. So I use the -b:v, -minrate, -maxrate, -bufsize settings.
But in the end I get a lower video bitrate as configured. With this command I end up with 3200 kb/s instead of 3500 kb/s:

ffmpeg -y -i 14d7077e-0822-4ab4-ba7f-822df1874936.mp4 -vf scale=1280:720  -pix_fmt yuv420p -c:v libx264 -aspect 16:9 -profile:v high -level 3.2 -r 25 -g 50 -keyint_min 50 -sc_threshold 0 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 7000k -c:a libfdk_aac -b:a 192k -ar 48k -ac 2 test.mp4

I get the same result with different source videos. When looking at the x264 options there is no minrate setting at all. Could it be that x264 does not support a minimum bitrate tolerance at all? Is there another way to archive CBR?

Greetings, Julian


ffmpeg version N-62016-g8790720 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr  1 2014 11:31:16 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
  configuration: --prefix=/var/lib/jenkins/jobs/ffmpeg/workspace/ffmpeg_build --extra-cflags=-I/var/lib/jenkins/jobs/ffmpeg/workspace/ffmpeg_build/include --extra-ldflags=-L/var/lib/jenkins/jobs/ffmpeg/workspace/ffmpeg_build/lib --bindir=/var/lib/jenkins/jobs/ffmpeg/workspace/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libx264
  libavutil      52. 70.100 / 52. 70.100
  libavcodec     55. 55.107 / 55. 55.107
  libavformat    55. 36.100 / 55. 36.100
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '14d7077e-0822-4ab4-ba7f-822df1874936.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isom
    creation_time   : 2014-03-24 14:20:02
  Duration: 00:29:12.19, start: 0.000000, bitrate: 6320 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5999 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2014-03-24 14:20:02
      handler_name    : MP4 Video Media Handler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
    Metadata:
      creation_time   : 2014-03-24 14:20:02
      handler_name    : MP4 Sound Media Handler
[libx264 @ 0x1fa0400] using SAR=1/1
[libx264 @ 0x1fa0400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x1fa0400] profile High, level 3.2
[libx264 @ 0x1fa0400] 264 - core 142 r2409 d6b4e63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=36 lookahead_threads=5 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=50 keyint_min=26 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=3500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=3500 vbv_bufsize=7000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'test.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isom
    encoder         : Lavf55.36.100
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 3500 kb/s, 12800 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2014-03-24 14:20:02
      handler_name    : MP4 Video Media Handler
    Stream #0:1(eng): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 192 kb/s (default)
    Metadata:
      creation_time   : 2014-03-24 14:20:02
      handler_name    : MP4 Sound Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> libfdk_aac)
Press [q] to stop, [?] for help
frame=43805 fps= 93 q=-1.0 Lsize=  726931kB time=00:29:12.19 bitrate=3398.6kbits/s dup=1 drop=0
video:684599kB audio:41068kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.174097%
[libx264 @ 0x1fa0400] frame I:877   Avg QP:16.66  size: 90829
[libx264 @ 0x1fa0400] frame P:20102 Avg QP:21.19  size: 23414
[libx264 @ 0x1fa0400] frame B:22826 Avg QP:23.14  size:  6602
[libx264 @ 0x1fa0400] consecutive B-frames: 17.5% 35.0% 11.8% 35.7%
[libx264 @ 0x1fa0400] mb I  I16..4:  8.5% 70.5% 21.0%
[libx264 @ 0x1fa0400] mb P  I16..4:  2.9% 11.1%  1.3%  P16..4: 41.8% 18.6%  9.1%  0.0%  0.0%    skip:15.2%
[libx264 @ 0x1fa0400] mb B  I16..4:  0.1%  0.3%  0.0%  B16..8: 35.9%  5.3%  1.1%  direct: 4.0%  skip:53.3%  L0:40.9% L1:52.8% BI: 6.3%
[libx264 @ 0x1fa0400] 8x8 transform intra:71.9% inter:74.2%
[libx264 @ 0x1fa0400] coded y,uvDC,uvAC intra: 62.4% 65.4% 30.1% inter: 25.1% 26.3% 1.8%
[libx264 @ 0x1fa0400] i16 v,h,dc,p: 25% 28%  6% 42%
[libx264 @ 0x1fa0400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 20% 18%  5%  6%  7%  7%  7%  6%
[libx264 @ 0x1fa0400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 24% 11%  4%  7%  7%  6%  5%  5%
[libx264 @ 0x1fa0400] i8c dc,h,v,p: 52% 22% 18%  8%
[libx264 @ 0x1fa0400] Weighted P-Frames: Y:5.1% UV:2.0%
[libx264 @ 0x1fa0400] ref P L0: 61.0% 12.1% 18.9%  7.8%  0.1%
[libx264 @ 0x1fa0400] ref B L0: 80.0% 17.8%  2.2%
[libx264 @ 0x1fa0400] ref B L1: 94.3%  5.7%
[libx264 @ 0x1fa0400] kb/s:3200.68
--------------------------------------------------------------------------------------------------
Bayerischer Rundfunk; Rundfunkplatz 1; 80335 München
Telefon: +49 89 590001; E-Mail: info at BR.de; Website: http://www.BR.de


More information about the ffmpeg-user mailing list