[FFmpeg-user] The parameter of bit_rate in video encoding does not work

Li codingpotatolinda at gmail.com
Thu Nov 14 23:56:04 CET 2013


On Thu, Nov 14, 2013 at 6:13 AM, James Darnley <james.darnley at gmail.com>wrote:

> On 2013-11-14 08:41, Li wrote:
> > inVStruct.inCodecContext->bit_rate
>
> Does this contain the value you expect? I mean does it contain 7974000
> (or something close) that you say is the input bitrate.
>




Yes, inVStruct.inCodecContext->bit_rate contains the value I expect, close
to 7974*1024 something, as you suggested.



>
> > The file is too big for me.
>
> What are the other encoding settings you are using?  Last I knew,
> ffmpeg's defaults were bad.  If you tried to use libx264 as the encoder
> it should spit an error message at you.
>


When I compiled the ffmpeg library, I have enabled libx264.



>
> > If I use the ffmpeg command to do fps processing (actually the original
> fps
> > is 30 too. So this command is only for test purpose):
> > ffmpeg -i VID_2013_output.mp4 -r  30 VID_2013_output_fps30.mp4
> >
> > The file size is 1.9MB!  Bitrate: 584 kbps
> >
> >
> > Since the ffmpeg command can achieve the purpose (lower the video
> encoding
> > bit rate), where is wrong with my ffmpeg C++ code?
>
> ffmpeg prints a very useful log when encoding.  Where is it?  Where is
> the log from your code?
>
>

(BTW, I found one subject in the FFmpeg user that they complained about the
bit_rate parameter does not work:
[Libav-user] Setting libx264 bitrate via API
jettoblack jettoblack at gmail.com
Mon Jul 23 23:12:39 CEST 2012)

The log is as below:

$ ffmpeg -i VID_20131007_165007_output.mp4 -r 30
VID_20131007_165007_output_fps30.mp4
ffmpeg version git-2013-03-26-1741fec Copyright (c) 2000-2013 the FFmpeg
developers
  built on May 25 2013 14:22:06 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libass --enable-libfaac
--enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libspeex --enable-librtmp
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-x11grab
--enable-libx264 --enable-nonfree --enable-version3 --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.105 /  3. 48.105
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VID_20131007_165007_output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.2.100
  Duration: 00:00:23.11, start: 0.000000, bitrate: 25618 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp,
96 kb/s
    Metadata:
      handler_name    : SoundHandler
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1072x196, 26123 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
[libx264 @ 0x24ddf20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x24ddf20] profile High, level 3.0
[libx264 @ 0x24ddf20] 264 - core 130 r2 c832fe9 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2013 - 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=12 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 'VID_20131007_165007_output_fps30.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.0.100
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1072x196, q=-1--1, 15360 tbn, 30 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, mono,
s16, 128 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:1 -> #0:0 (h264 -> libx264)
  Stream #0:0 -> #0:1 (aac -> libfaac)
Press [q] to stop, [?] for help
frame=   83 fps=0.0 q=29.0 size=      70kB time=00:00:02.94 bitrate=
195.6kbits/frame=  142 fps=141 q=29.0 size=     213kB time=00:00:04.90
bitrate= 356.1kbits/frame=  196 fps=130 q=29.0 size=     355kB
time=00:00:06.72 bitrate= 432.9kbits/frame=  259 fps=129 q=29.0 size=
499kB time=00:00:08.81 bitrate= 463.6kbits/frame=  317 fps=126 q=29.0
size=     653kB time=00:00:10.75 bitrate= 497.6kbits/frame=  378 fps=125
q=29.0 size=     809kB time=00:00:12.77 bitrate= 518.4kbits/frame=  432
fps=123 q=29.0 size=     955kB time=00:00:14.57 bitrate= 537.1kbits/frame=
489 fps=121 q=29.0 size=    1091kB time=00:00:16.46 bitrate=
542.5kbits/frame=  545 fps=120 q=29.0 size=    1223kB time=00:00:18.34
bitrate= 546.1kbits/frame=  677 fps=113 q=32766.0 Lsize=    1768kB
time=00:00:23.10 bitrate= 626.7kbits/s
video:1508kB audio:233kB subtitle:0 global headers:0kB muxing overhead
1.486466%
[libx264 @ 0x24ddf20] frame I:3     Avg QP:21.78  size: 19890
[libx264 @ 0x24ddf20] frame P:213   Avg QP:24.33  size:  5021
[libx264 @ 0x24ddf20] frame B:461   Avg QP:29.53  size:   900
[libx264 @ 0x24ddf20] consecutive B-frames:  0.7%  4.1% 63.8% 31.3%
[libx264 @ 0x24ddf20] mb I  I16..4: 12.9% 59.1% 28.0%
[libx264 @ 0x24ddf20] mb P  I16..4:  0.7%  1.3%  1.0%  P16..4: 51.4% 20.7%
10.7%  0.0%  0.0%    skip:14.3%
[libx264 @ 0x24ddf20] mb B  I16..4:  0.0%  0.1%  0.1%  B16..8: 45.8%  3.0%
0.3%  direct: 0.8%  skip:49.8%  L0:42.2% L1:54.1% BI: 3.7%
[libx264 @ 0x24ddf20] 8x8 transform intra:47.6% inter:68.4%
[libx264 @ 0x24ddf20] coded y,uvDC,uvAC intra: 55.2% 83.4% 43.3% inter:
11.4% 18.7% 2.6%
[libx264 @ 0x24ddf20] i16 v,h,dc,p:  9% 45% 10% 36%
[libx264 @ 0x24ddf20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 37% 12%  3%  3%
3%  6%  3%  8%
[libx264 @ 0x24ddf20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 55% 25%  6%  2%  2%
2%  4%  2%  3%
[libx264 @ 0x24ddf20] i8c dc,h,v,p: 41% 36% 17%  6%
[libx264 @ 0x24ddf20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x24ddf20] ref P L0: 56.3% 12.8% 22.2%  8.7%
[libx264 @ 0x24ddf20] ref B L0: 82.4% 14.9%  2.7%
[libx264 @ 0x24ddf20] ref B L1: 91.2%  8.8%
[libx264 @ 0x24ddf20] kb/s:547.31



Thanks for your help!


More information about the ffmpeg-user mailing list