[FFmpeg-user] FDK_AAC OUTPUTS CBR AUDIO STREAM ONLY?!!!

bigshot bigshot at wickmail.net
Sat May 16 04:39:23 CEST 2015


/"why are you screaming?"/

Ummm...didn't mean to scream. If it came out like that to you and it was
disruptive I may need to apologize?!! :)

/"It is no longer relevant for newer versions of libfdk_aac, because VBR
encoding modes are now meant to work properly."/

I'm using the most recent one. I made a custom built of ffmpeg just
recently, and all external libs are downloaded from their respective repos.

For FDK encoder I see:

"Name: Fraunhofer FDK AAC Codec Library
Description: AAC codec library
Version: 0.1.4
Libs: -L${libdir} -lfdk-aac 
Libs.private: 
Cflags: -I${includedir}" 

So, 0.1.4 is the version I'm currently using with ffmpeg which is on par
with the current version declared on sourceforge.
 
/"Is there anything else than mediainfo we can use to confirm this
behavior?"/

Well, I trust MediaInfo very much for reading all my video and audio file
tags accurately...almost :).
As an alternative I also use exiftool which displays even more info on
file's metadata. But strangely enough audio bitrate is one of the few tags
it can't read from a mp4 auido stream.It's fine with some other containers
thou...   

/"So, I believe either ffmpeg of mediainfo is doing something wrong with the
headers."/

I'm suspecting ffmpeg or fdk-aac or both to be the offenders here.
MediaInfo, reads whatever audio encoder decides to write to the headers of
the file. In my opinion MediaInfo is not to blame here. MeGUI also comes
with an option to include a standalone FDK-AAC encoder (current v0.6.2) in
its tools library. I use it from time to time in VBR mode and Mediainfo
reports the audio bitrate mode of the output correctly...as VBR.

OK, made a few experiments:

Source file tags, according to MediaInfo:

General

Complete name : C:\src.mp4 
Format : MPEG-4 
Format profile : Base Media / Version 2 
Codec ID : mp42 
File size : 4.61 MiB 
Duration : 28s 737ms 
Overall bit rate : 1 345 Kbps 

Video

Format : AVC 
Source file: 4.6MB
Stream size : 4.17 MiB (90%)

Audio

Format : AAC 
Duration : 28s 737ms 
Source duration : 28s 746ms 
Bit rate mode : Constant 
Bit rate : 128 Kbps 
Channel(s) : 2 channels 
Channel positions : Front: L R 
Sampling rate : 44.1 KHz 
Stream size : 435 KiB (9%) 
Source stream size : 435 KiB (9%) 

Audio Output script: 

Code:

ffmpeg -i src.mp4 -vn -c:a libfdk_aac -vbr 1 aud.aac -y   

Mediainfo reads: 

Audio 

Format : AAC 
Format/Info : Advanced Audio Codec 
Format version : Version 4 
Format profile : LC 
Bit rate mode : Variable 
Channel(s) : 2 channels 
Channel positions : Front: L R 
Sampling rate : 44.1 KHz 
Compression mode : Lossy 
Stream size : 194 KiB (100%) 


ffmpeg -i src.mp4 -vn -c:a libfdk_aac -vbr 1 aud.m4a -y 

Mediainfo reads: 

Audio 
ID : 1 
Format : AAC 
Format/Info : Advanced Audio Codec 
Format profile : LC 
Codec ID : 40 
Duration : 28s 793ms 
Bit rate mode : Constant 
Bit rate : 52.9 Kbps 
Channel(s) : 2 channels 
Channel positions : Front: L R 
Sampling rate : 44.1 KHz 
Compression mode : Lossy 
Stream size : 186 KiB (97%) 

Attempting to mux the encoded audio stream back to original video file:

Code:

ffmpeg -i src.mp4 -i aud.m4a -map 0:v:0 -map 1:a:0 -c:v copy -c:a copy
-shortest dst.mp4 -y

...and ffmpeg prints the following warnings and errors in the log:

......

[mp4 @ 031fa840] Codec for stream 0 does not use global headers but
container format requires global headers
[mp4 @ 031fa840] Codec for stream 1 does not use global headers but
container format requires global headers
Output #0, mp4, to 'dst.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42mp41
    encoder         : Lavf56.30.100
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1280x720, q=2-31, 1215 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc
(default)
    Metadata:
      creation_time   : 2012-11-07 00:06:05
      handler_name    : Apple Video Media Handler
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo,
52 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  689 fps=0.0 q=-1.0 Lsize=    4474kB time=00:00:28.69
bitrate=1276.9kbits/s
video:4265kB audio:186kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.512366%


MediaInfo on the muxed output:

Complete name : C:\dst.mp4 
Format : MPEG-4 
Format profile : Base Media 
Codec ID : isom 
File size : 4.37 MiB 
Duration : 28s 738ms 
Overall bit rate : 1 275 Kbps 
Writing application : Lavf56.30.100 

Video 
ID : 1 
Format : AVC 
Format/Info : Advanced Video Codec 
Format profile : Main at L3.1 
Format settings, CABAC : No 
Format settings, ReFrames : 2 frames 
Format settings, GOP : M=2, N=90 
Codec ID : avc1 
Codec ID/Info : Advanced Video Coding 
Duration : 28s 738ms 
Bit rate : 1 216 Kbps 
Width : 1 280 pixels 
Height : 720 pixels 
Display aspect ratio : 16:9 
Frame rate mode : Constant 
Frame rate : 23.976 fps 
Color space : YUV 
Chroma subsampling : 4:2:0 
Bit depth : 8 bits 
Scan type : Progressive 
Bits/(Pixel*Frame) : 0.055 
Stream size : 4.17 MiB (95%) 
Language : English 
Color range : Limited 
Color primaries : BT.709 
Transfer characteristics : BT.709 
Matrix coefficients : BT.709 

Audio 
ID : 2 
Format : AAC 
Format/Info : Advanced Audio Codec 
Format profile : LC 
Codec ID : 40 
Duration : 28s 700ms 
Bit rate mode : Constant 
Bit rate : 53.1 Kbps 
Channel(s) : 2 channels 
Channel positions : Front: L R 
Sampling rate : 44.1 KHz 
Compression mode : Lossy 
Stream size : 186 KiB (4%) 
Language : English 


As you can see, -vbr switch has indeed re-encoded the audio stream but in
CONSTANT mode.

I tried to mux the same source as above but this time with audio in aac
format, but it did not work. So I actually abandoned working with acc audio,
although it was the only format reported by MediaInfo as VBR AFTER
re-encode.  

Here is the log:

C:\>ffmpeg -i src.mp4 -i aud.aac -map 0:v:0 -map 1:a:0 -c:v copy -c:a copy
-shortest dst.mp4 -y
ffmpeg version N-71380-gbc48c88 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 4.9.2 (GCC)
  configuration: --arch=x86 --target-os=mingw32
--cross-prefix=/home/<my_name>/ffmpeg/sandbox/mingw-w64-i686/bin/i686-w64-mingw32-
--pkg-config=pkg-config --enable-gpl --enable-libsoxr --enable-fontconfig
--enable-libass --enable-libutv
ideo --enable-libbluray --enable-iconv --enable-libtwolame
--extra-cflags=-DLIBTWOLAME_STATIC --enable-libzvbi --enable-libcaca
--enable-libmodplug --extra-libs=-lstdc++ --extra-libs=-lpng
--enable-libvidstab --enable-libx265 --enable-
decklink --extra-libs=-loleaut32 --enable-libx264 --enable-libxvid
--enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp
--enable-libvorbis --enable-libtheora --enable-libopenjpeg --enable-gnutls
--enable-libgsm --enable
-libfreetype --enable-libopus --disable-w32threads --enable-frei0r
--enable-filter=frei0r --enable-bzlib --enable-libxavs
--extra-cflags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libvo-amrwbenc -
-enable-libschroedinger --enable-libvpx --enable-libilbc --enable-libwavpack
--enable-libwebp --enable-libgme --enable-dxva2 --enable-libdcadec
--enable-avisynth --enable-static --disable-shared --extra-cflags=
--prefix=/home/<my_name>/
ffmpeg/sandbox/mingw-w64-i686/i686-w64-mingw32 --enable-nonfree
--enable-libfdk-aac --disable-libfaac --disable-decoder=aac --enable-nvenc
--enable-runtime-cpudetect
  libavutil      54. 22.101 / 54. 22.101
  libavcodec     56. 34.100 / 56. 34.100
  libavformat    56. 30.100 / 56. 30.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42mp41
    creation_time   : 2012-11-07 00:06:05
  Duration: 00:00:28.74, start: 0.000000, bitrate: 1345 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16,
123 kb/s (default)
    Metadata:
      creation_time   : 2012-11-07 00:06:05
      handler_name    : Apple Sound Media Handler
    Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1280x720, 1215 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 48k tbc
(default)
    Metadata:
      creation_time   : 2012-11-07 00:06:05
      handler_name    : Apple Video Media Handler
[aac @ 0321b020] Estimating duration from bitrate, this may be inaccurate
Input #1, aac, from 'aud.aac':
  Duration: 00:01:34.33, bitrate: 16 kb/s
    Stream #1:0: Audio: aac, 44100 Hz, stereo, s16, 16 kb/s
[mp4 @ 03168000] Codec for stream 0 does not use global headers but
container format requires global headers
[mp4 @ 03168000] Codec for stream 1 does not use global headers but
container format requires global headers
Output #0, mp4, to 'dst.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42mp41
    encoder         : Lavf56.30.100
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1280x720, q=2-31, 1215 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc
(default)
    Metadata:
      creation_time   : 2012-11-07 00:06:05
      handler_name    : Apple Video Media Handler
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 16
kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 03168000] Malformed AAC bitstream detected: use the audio bitstream
filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
av_interleaved_write_frame(): Operation not permitted
frame=    3 fps=0.0 q=-1.0 Lsize=       4kB time=00:00:00.04 bitrate=
784.1kbits/s
video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 26.179464%
Conversion failed!

So, can you shed some light if we've discovered a bug in my ffmpeg build or
maybe I need to use another code within ffmpeg to get to what I want, I
would appreciate your input!!!

Thanks...
TM




--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/FDK-AAC-OUTPUTS-CBR-AUDIO-STREAM-ONLY-tp4670348p4670425.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list