12

What happens if you do not set a audio bitrate in the aac encoder ?

-ab 128k

Does it automaticly select the highest bitrate it can or something i am curious if i should do this or if it will be bad i see no difference.

C0nw0nk
  • 589
  • 3
  • 7
  • 16
  • 1
    Why would you not try it? And then for the output file do `ffmpeg -i outputfile`. It will tell you what bitrate the audio is at. No encoder `detects` incoming bitrate it justs falls to defaults. – Rajib Jan 01 '15 at 14:25

2 Answers2

18

The encoder does not necessarily need to be passed a bitrate to work. It's still recommended to set it.

What the default is and which bitrate to choose totally depends on the AAC encoder you are using. ffmpeg can use several AAC encoders:

  • aac (ffmpeg-internal) – defaults to 128 kBit/s for both mono and stereo.
  • libfdk-aac – defaults to 128 kBit/s for stereo and 96 kBit/s CBR for mono.

In general, you should choose a higher bitrate than the default for aac. This is because it produces somewhat lower quality than libfdk-aac at the same bitrate.

Do that by setting -b:a appropriately, e.g. -b:a 192k:

ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a

aac vs libfdk-aac

Why is libfdk-aac sometimes not recommended? Because it uses a nonfree license and cannot be included in ffmpeg static builds (i.e., the ones that you can directly download from the website). This is why it's easier to just go with aac, which is built into ffmpeg.

But if you have access to libfdk-aac, sure, use it.

Which quality options to choose?

Instead of going for a fixed bitrate, you can also choose VBR encoding.

I tried to summarize the VBR options on my homepage, and the FFmpeg Wiki has good info on AAC encoding as well as some example commands.

Can I trust the log output?

When you see a line similar to this in ffmpeg's log output:

Stream #0:0: Audio: aac (libfdk_aac) (mp4a / 0x6134706D), … 96 kb/s

Then the kb/s shown here do not necessarily reflect what the encoder will really use, as it's up to the specific implementation — the encoder could use variable quality.


There are also some encoders that are not supported anymore by ffmpeg:

  • libfaac – defaults to VBR setting of 100, which results in about 128 kBit/s for stereo audio (reference).
  • libvo-aacenc – defaults to 128 kBit/s for both mono and stereo.
  • libaacplus
slhck
  • 223,558
  • 70
  • 607
  • 592
  • Thanks so what is the recommended bitrate i should use with aac before i had it set to -ab 192k and i kept getting bit_rate width height error what is kind of annoying. – C0nw0nk Jan 01 '15 at 15:49
  • 1
    The recommended bitrate depends on what your application is, and what encoder you are using. For web video, you probably want 128 kBit/s but not much more. For listening to music, I'd go higher than that. For the internal AAC encoder, 192 kBit/s is very good quality. I don't know what a "bit_rate width height error" is, though. If *that* is your real problem, then you should ask a new question about the error and show the complete, uncut command line output from ffmpeg. – slhck Jan 01 '15 at 16:01
  • Unless it's this question you already asked: http://superuser.com/questions/805196/ffmpeg-windows-generate-360p-video-conversion-failed — you got a good answer there already. – slhck Jan 01 '15 at 16:02
  • Thanks i set it to be -ab 128k and i will just wait and see if that error ever comes back. – C0nw0nk Jan 01 '15 at 16:26
  • If `libfdk-aac` produces better quality than `aac` at the same bitrate, why use `aac` at all? And why is it the default suggestion in most answers? – Tim MB Mar 01 '23 at 20:40
  • 1
    @TimMB Because the `aac` encoder is built into ffmpeg, and `libfdk-aac` can only be included in ffmpeg builds that you a) compile yourself or b) where you dynamically link against `libfdk-aac`. This is due to its nonfree license. In other words: static ffmpeg builds cannot include it, and so it's hard to recommend to people when they can't use it out of the box. – slhck Mar 02 '23 at 10:09
-2

edit for very old versions of ffmpeg /edit Libfaac sets a default bitrate. 128k for a stereo input and 96k for mono.

This can safely be ignored in any current version

stib
  • 4,269
  • 6
  • 27
  • 38
  • The OP is talking about "ffmpeg's aac encoder", not FAAC. – slhck Jan 01 '15 at 15:29
  • True. But if I don't specify an encoder libFAAC *is* the default. Maybe it's just the way my build of ffmpeg works. – stib Jan 02 '15 at 11:01
  • Yeah, that's assuming ffmpeg is built with libfaac. In the default configuration, it will fail to convert to AAC, since the internal AAC encoder needs the `-strict experimental` flag. – slhck Jan 02 '15 at 11:06
  • For future visitors, since late 2015 FFMpeg's native AAC encoder has surpassed FAAC in quality and is no longer marked experimental. – thomasrutter Nov 05 '21 at 10:40