How to specify audio and video bitrate
I have a mov file with the following media information:
Stream 0
Type: Video
Codec: H264-MPEG-4 AVC (part 10)avc1
Language: English
Resolution: 1280x720
Frame rate: 24
Stream 1
Type: Audio
Codec: MPEG AAC Audio (mp4a)
Language: English
Channels: Stereo
Sample rate: 44100HZAnd I would like to use FFmpeg to convert that MOV file to an AVI file.
I know i can specify audio and video bit rate (from this article):
ffmpeg -i InputFile.mpg -ab 128 -b 1200 OutputFile.aviBut for my case, if I want to keep the original quality, what should be my audio and video bit rate?
01 Answer
In order to specify the target bitrate for video and audio, use the -b:v and -b:a options, respectively. You can use abbreviations like K for kBit/s and M for MBit/s.
For example:
ffmpeg -i input.mp4 -b:v 2M -b:a 192k output.mp4But before you just run it like this, note the following:
This is a simple one-pass encode that tries to reach the specified bitrate at the end. This will likely lead to wrong bitrate estimations for the video part. The output quality might be bad. It's recommended to use a two-pass encoding mode if you want to target a certain bitrate. See the H.264 encoding guide for more tips.
ffmpeg selects a default video and audio codec for the chosen output extension. For the AVI container this is the
mpeg4andlibmp3lameencoder, respectively, so MPEG-4 Part II video and MP3 audio. You cannot use the original video and audio codecs (H.264 and AAC) here because they're not supported by AVI containers. Choose the MP4 container as output, which will default tolibx264andaacencoders, i.e. MPEG-4 Part 10 video and AAC audio.Almost any codec allows you to set a specific bitrate, but many codecs have variable bitrate / fixed quality modes. If you do not care about a specific file size, you should use a fixed-quality mode instead. Please read the H.264 encoding guide and the section on the Constant Rate Factor (CRF) for that. Replace the video bitrate
-b:v 2Mwith-crf 23, for instance.