Opened 9 years ago

Last modified 9 years ago

#4894 new defect

Problem with -acodec copy and AAC VBR

Reported by: hgg Owned by:
Priority: minor Component: avcodec
Version: git-master Keywords: AAC
Cc: kevingrondin@hotmail.fr Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
It's an extension of https://trac.ffmpeg.org/ticket/4546
If you extract the AAC VBR track from a file test.m4a to test.aac, then reinsert it into another file test2.m4a, it becomes an AAC CBR track if we check the metadata with MediaInfo.

How to reproduce:

ffmpeg -i test.m4a -vn -acodec copy test.aac

ffmpeg version N-75563-g235381e Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.100 / 57.  2.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  8.100 /  6.  8.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    encoder         : Lavf57.2.100
    gapless_playback: 0
  Duration: 00:00:05.02, start: 0.000000, bitrate: 270 kb/s
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 268 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, adts, to 'test.aac':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    gapless_playback: 0
    encoder         : Lavf57.2.100
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 268 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=     166kB time=00:00:05.01 bitrate= 270.6kbits/s
video:0kB audio:164kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.899406%

MediaInfo -> AAC Variable

ffmpeg -i test.aac -vn -acodec copy -bsf:a aac_adtstoasc test2.m4a

ffmpeg version N-75563-g235381e Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.100 / 57.  2.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  8.100 /  6.  8.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
[aac @ 0000000004fd86c0] Estimating duration from bitrate, this may be inaccurate
Input #0, aac, from 'test.aac':
  Duration: 00:00:05.14, bitrate: 264 kb/s
    Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 264 kb/s
File 'test2.m4a' already exists. Overwrite ? [y/N] y
[ipod @ 000000000507cce0] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, ipod, to 'test2.m4a':
  Metadata:
    encoder         : Lavf57.2.100
    Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 264 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=     166kB time=00:00:05.01 bitrate= 270.7kbits/s
video:0kB audio:164kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.952347%

MediaInfo -> AAC Constant

I think the problem is in the way the metadata are created from the raw AAC track to the m4a file.

Attachments (3)

test.aac (165.6 KB ) - added by hgg 9 years ago.
test.m4a (165.8 KB ) - added by hgg 9 years ago.
test2.m4a (165.7 KB ) - added by hgg 9 years ago.

Download all attachments as: .zip

Change History (8)

by hgg, 9 years ago

Attachment: test.aac added

by hgg, 9 years ago

Attachment: test.m4a added

by hgg, 9 years ago

Attachment: test2.m4a added

comment:1 by hgg, 9 years ago

Component: avformatavcodec

comment:2 by hgg, 9 years ago

Cc: kevingrondin@hotmail.fr added

comment:3 by Carl Eugen Hoyos, 9 years ago

Keywords: variable removed

comment:4 by Hendrik, 9 years ago

Are there actual playback problems? Otherwise I would just question MediaInfo.

comment:5 by peloverde, 9 years ago

MediaInfo compares the average and max bitrates in the esds to determine CBR vs VBR. For transmuxed files FFmpeg always sets max bitrate to avg bitrate. It should be possible to create a compute_max_bitrate() function just like compute_avg_bitrate() to create maximally complaint files. But I don't know of any practical implications of this.

Note: See TracTickets for help on using tickets.