Opened 20 months ago

Last modified 20 months ago

#11351 new defect

Native AAC-enocoder doesn't create constant bitrate.

Reported by: maxmanus Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: native aac
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by maxmanus)

Summary of the bug:
How to reproduce:

% ffmpeg -i input -c:a aac -b:a 320k -af aresample=resampler=soxr -ar 48k  ... output
Output is then variable bitrate.

If I just write -b instead of -b:a 320k it creates constant bitrate but then it defaults to 192k

ffmpeg version N-114629-g1590a96adc-20240403
built on ...gcc 13.2.0 (crosstool-NG 1.26.0.65_ecc5e41

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Change History (9)

comment:1 by maxmanus, 20 months ago

Description: modified (diff)

comment:2 by maxmanus, 20 months ago

Description: modified (diff)

comment:3 by Balling, 20 months ago

Neither of those produce true constant bitrate, you need -bit_rate_tolerance 0 option. b92af7b64e7acd015aea3ae1da2228c5a7e677bf

Output is then variable bitrate.

it does decrease bitrate if the sound does not need needed amount of data, but bit_rate_tolerance 0 has bugs https://patchwork.ffmpeg.org/project/ffmpeg/patch/517a57ef18398a39952fcc1d02e51ef423cf80ae.1726262133.git.pav@iki.fi/

in reply to:  3 ; comment:4 by maxmanus, 20 months ago

Ok, but when I write just -b it does show as constant bitrate in mediainfo.
If -b:a 320k it shows as variable. I want it to show as constant. No way to fix this?
I'm using qaac now because of this, but seems buggy when muxing together after with ffmpeg.

Replying to Balling:

Neither of those produce true constant bitrate, you need -bit_rate_tolerance 0 option. b92af7b64e7acd015aea3ae1da2228c5a7e677bf

Output is then variable bitrate.

it does decrease bitrate if the sound does not need needed amount of data, but bit_rate_tolerance 0 has bugs https://patchwork.ffmpeg.org/project/ffmpeg/patch/517a57ef18398a39952fcc1d02e51ef423cf80ae.1726262133.git.pav@iki.fi/

in reply to:  4 comment:5 by maxmanus, 20 months ago

Replying to maxmanus:

Ok, but when I write just -b it does show as constant bitrate in mediainfo.
If -b:a 320k it shows as variable. I want it to show as constant. No way to fix this?
I'm using qaac now because of this, but seems buggy when muxing together after with ffmpeg.

Replying to Balling:

Neither of those produce true constant bitrate, you need -bit_rate_tolerance 0 option. b92af7b64e7acd015aea3ae1da2228c5a7e677bf

Output is then variable bitrate.

it does decrease bitrate if the sound does not need needed amount of data, but bit_rate_tolerance 0 has bugs https://patchwork.ffmpeg.org/project/ffmpeg/patch/517a57ef18398a39952fcc1d02e51ef423cf80ae.1726262133.git.pav@iki.fi/

Is there any difference though? Quality and support wise on TVs and other platforms?
I started messing with this because I used to convert to 384k before, and noticed sound dropping out on my samsung tv under playback. Might av been because of too high bitrate. Haven't reproduced this issue after changing to 320k.

Is it true that the native encoder at 320k variable is same quality as with qaac 320k constant?

Last edited 20 months ago by maxmanus (previous) (diff)

comment:6 by Balling, 20 months ago

Qaac is much superiour than two-loop in ffmpeg.

That option if for headphones, bluetooth likes close to perfect constant bitrate.

in reply to:  6 comment:7 by maxmanus, 20 months ago

Replying to Balling:

Qaac is much superiour than two-loop in ffmpeg.

That option if for headphones, bluetooth likes close to perfect constant bitrate.

I'm not sure I understand.
At that bitrate, shouldn't the quality be the same? I've not heard any difference with 320k with ffmpeg native aac as variable and qaac with 320k constant. Just thinking about support on devices. Strange ffmpeg makes it variable for me, when I specify constant. I used fdk before, but such a hassle to build ffmpeg every time.
Why is this still a problem though with ffmpeg. A good aac encoder should'nt be a big deal in my eyes. I don't get it. I thought aac at these bitrates should be the same.
Now when using qaac standalone together with ffmpeg the duration of the audio and video always slightly different. Can't find sync problems, but I read that if a delay is in the metadata it will get deleted with qaac.

Last edited 20 months ago by maxmanus (previous) (diff)

comment:8 by Balling, 20 months ago

I'm not sure I understand.

Bluetooth A2DP supports AAC. It is literally the only codec in Apple after Apple removed AptX in MacOS.

At that bitrate, shouldn't the quality be the same?

Nah, Qaac from Apple is superior.

Now when using qaac standalone together with ffmpeg the duration of the audio and video always slightly different

That is because Apple uses 2112 samples and we use 1024 samples of priming. those should be removed, as they are just garbage. It is even more complex in HE-AAC(v2).

I read that if a delay is in the metadata it will get deleted with qaac.

Yes, qaac decoder supports sample accurate removal of both two styles of gapless metadata, ITunSMPB and edit lists.

comment:9 by Balling, 20 months ago

Anyway, here it is said that true VBR is not supported, only ABR

https://stackoverflow.com/q/59693214

And wiki says the same: https://trac.ffmpeg.org/wiki/Encode/AAC

Native FFmpeg AAC Encoder does not do CBR audio encoding.

So...

Note: See TracTickets for help on using tickets.