[Libav-user] A bug in AAC encoder?

CoDDoC coddoc at mail.ru
Tue May 8 14:46:38 EEST 2018


Hello, all!

ffmpeg version 4.0-static with native AAC encoder

Input file (in.mp4): CFR 30fps video with VBR AAC audio.
According to MediaInfo:
Duration                                 : 4mn 10s
Bit rate mode                            : Variable
Bit rate                                 : 192 Kbps
Maximum bit rate                         : 201 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)

I re-encode it with the same video and CBR AAC audio 192 Kbps.
-------------------
Experiment #1.
The simple command:

ffmpeg -y -i in.mp4 -vcodec copy -acodec aac -b:a 192k out.mp4

And inexpected result (VBR):
Duration                                 : 4mn 10s
Bit rate mode                            : Variable
Bit rate                                 : 185 Kbps
Maximum bit rate                         : 192 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)

The same with -vn.
Ok, continue...
-------------------
Experiment #2.

ffmpeg -y -i in.mp4 -vcodec copy -acodec copy out.mp4

Again inexpected result (because '-acodec copy'):
Duration                                 : 4mn 10s
Bit rate mode                            : Constant
Bit rate                                 : 192 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)

The options are changed?

I asking about because I found in my archives ffmpeg version 2.8.1-static and got exactly what i needed:

ffmpeg -y -i in.mp4 -vcodec copy -acodec aac -b:a 192k -strict experimental -flags +global_header out.mp4

Duration                                 : 4mn 10s
Bit rate mode                            : Constant
Bit rate                                 : 196 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)

-------------------
Note.
When I tried open 'out.mp4' created by ffmpeg v4.0, with MP4 Inspector (https://sourceforge.net/projects/mp4-inspector/), i got an error:
'Failed on reading box header, parent box path "\moov\trak\mdia\minf\stbl\sgpd".....'

By the way, input file opens without errors. File 'out.mp4' created by ffmpeg v2.8.1 - too.

Let's continuing experiments...
-------------------
Experiment #3.
Output file opens with MP4 Inspector without errors after such trick (v4.0):

ffmpeg -y -i in.mp4 -vcodec copy -acodec aac -b:a 192k -movflags +empty_moov out.mp4

But it's only trick, usually I not needed fragmented streams.

In this case MediaInfo shows that audio is CBR but 185 kbps instead of 192:
Duration                                 : 4mn 10s
Bit rate                                 : 185 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)

Ok, maybe reason of changing bitrate is that the input file has VBR audio.
But Exp. #2 says it can be exactly 192 kbps...
I'm slightly confused....

Any ideas?

--


More information about the Libav-user mailing list