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

Li codingpotatolinda at gmail.com
Thu Nov 14 08:41:58 CET 2013


My program is to decode a video file, process each frame, and encode frames
back to the output video file.
I find that the output video file has a large size.
So I set the bit_rate to be 0.2 of the original bit_rate.
The code snippet is as follows:

ouVStruct.ouCodecContext->bit_rate = 0.2 *
inVStruct.inCodecContext->bit_rate;  (or 0.5)
------------
input video file .mp4 (recorded by Nexus 4)
Video:
    1280x720
    H.264/AVC
    30 frames per second
    Bitrate: 7974 kbps
Audio:
    codec: MPEG-4AAC
    Channels: Stereo
    Sample rate: 48000 Hz
    Bitrate: 96 kbps
The file size is: 21.2MB
------------
------------
output video file .mp4 (processed by my program using ffmpeg)
Video:
    1280x720
    H.264/AVC
    30 frames per second
    Bitrate: 25289 kbps
Audio:
    codec: MPEG-4AAC
    Channels: Stereo
    Sample rate: 48000 Hz
    Bitrate: 96 kbps
The file size is: 66.6MB
------------

The file is too big for me.

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?

Thanks!


More information about the ffmpeg-user mailing list