How to specify audio and video bitrate

40

13

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: 44100HZ

And 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.avi

But for my case, if I want to keep the original quality, what should be my audio and video bit rate?

michael

Posted 2011-07-16T07:16:40.710

Reputation: 4 127

Answers

56

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 1M -b:a 192k output.avi

Note:

  • 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. 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.

  • Look at the quality: Do you need it better? Then use a higher bitrate. Try and see what works best for you. If you simply use the same bitrate as the input, chances are high the quality will be much worse than the original due to generation loss.

  • ffmpeg selects a default video and audio codec for the AVI container, which is the mpeg4 and libmp3lame encoder, 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.

  • 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, use this mode instead. Please read the H.264 encoding guide and the section on the Constant Rate Factor for that.

slhck

Posted 2011-07-16T07:16:40.710

Reputation: 182 472

@Visionscaper That does not make sense. Your option will copy the input audio stream and therefore not perform any encoding. You should receive a warning about that. – slhck – 2015-03-17T16:23:09.543

hmm, you are right, sorry about that. I misunderstood the option; being in a hurry doesn't pay I guess. I got an error message without this option, so there must be something wrong with my audio codec (settings). – Visionscaper – 2015-03-17T18:35:36.997

Sure, feel free to post a new question with the full log and I'll have a look at it! – slhck – 2015-03-17T19:17:42.063

Here you go! http://superuser.com/q/890785/428914

– Visionscaper – 2015-03-17T19:41:30.907