[FFmpeg-trac] #5973(ffmpeg:new): Regression: aac_adtstoasc bitstream filter leads to malformed AAC stream
FFmpeg
trac at avcodec.org
Tue Nov 22 01:46:19 EET 2016
#5973: Regression: aac_adtstoasc bitstream filter leads to malformed AAC stream
---------------------------------+--------------------------------------
Reporter: zmwangx | Type: defect
Status: new | Priority: normal
Component: ffmpeg | Version: git-master
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
---------------------------------+--------------------------------------
== Summary of the bug ==
There's a regression in FFmpeg 3.2 where applying the aac_adtstoasc
bitstream filter could result in malformed AAC streams (with extra data).
Specifically, when decoding the output streams, we get errors like
{{{
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (45) exceeds
limit (41).
}}}
The regression is caused by
[https://github.com/FFmpeg/FFmpeg/commit/5ef19590802f000299e418143fc2301e3f43affe
commit 5ef1959], "ffmpeg: switch to the new BSF API".
== How to reproduce ==
{{{
% ffmpeg -v 9 -loglevel 99 -y -i aac_adtstoasc_bsf_breaks_aac_stream.m4a
-c copy -bsf:a aac_adtstoasc filtered.m4a
ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.38)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-
ffplay --enable-frei0r --enable-libass --enable-libcaca --enable-libfdk-
aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-
libschroedinger --enable-libspeex --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-opencl --enable-openssl --disable-lzma --enable-
libopenjpeg --disable-decoder=jpeg2000 --extra-
cflags=-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1 --enable-
nonfree --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with
argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument '99'.
Reading option '-y' ... matched as option 'y' (overwrite output files)
with argument '1'.
Reading option '-i' ... matched as input file with argument
'aac_adtstoasc_bsf_breaks_aac_stream.m4a'.
Reading option '-c' ... matched as option 'c' (codec name) with argument
'copy'.
Reading option '-bsf:a' ... matched as option 'bsf' (A comma-separated
list of bitstream filters) with argument 'aac_adtstoasc'.
Reading option 'filtered.m4a' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Applying option loglevel (set logging level) with argument 99.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file
aac_adtstoasc_bsf_breaks_aac_stream.m4a.
Successfully parsed a group of options.
Opening an input file: aac_adtstoasc_bsf_breaks_aac_stream.m4a.
[file @ 0x7fa757600000] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] Format mov,mp4,m4a,3gp,3g2,mj2
probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] ISO: File Type Major Brand: M4A
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] Unknown dref type 0x08206c7275
size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] Processing st: 0, edit list 0 -
media time: 0, duration: 10272
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] Before
avformat_find_stream_info() pos: 2499 bytes read:2499 seeks:0 nb_streams:1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa759801000] After
avformat_find_stream_info() pos: 78 bytes read:2499 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'aac_adtstoasc_bsf_breaks_aac_stream.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
encoder : Lavf57.56.100
Duration: 00:00:00.21, start: 0.000000, bitrate: 93 kb/s
Stream #0:0(und), 1, 1/48000: Audio: aac (HE-AAC) (mp4a / 0x6134706D),
48000 Hz, stereo, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Successfully opened the file.
Parsing a group of options: output file filtered.m4a.
Applying option c (codec name) with argument copy.
Applying option bsf:a (A comma-separated list of bitstream filters) with
argument aac_adtstoasc.
Successfully parsed a group of options.
Opening an output file: filtered.m4a.
[file @ 0x7fa757405f60] Setting default whitelist 'file,crypto'
Successfully opened the file.
Output #0, ipod, to 'filtered.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
encoder : Lavf57.56.100
Stream #0:0(und), 0, 1/48000: Audio: aac (HE-AAC) (mp4a / 0x6134706D),
48000 Hz, stereo, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per
stream)
No more output streams to write to, finishing.
size= 2kB time=00:00:00.17 bitrate= 117.0kbits/s speed= 749x
video:0kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 43.721199%
Input file #0 (aac_adtstoasc_bsf_breaks_aac_stream.m4a):
Input stream #0:0 (audio): 5 packets read (1736 bytes);
Total: 5 packets (1736 bytes) demuxed
Output file #0 (filtered.m4a):
Output stream #0:0 (audio): 5 packets muxed (1736 bytes);
Total: 5 packets (1736 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7fa757406080] Statistics: 30 seeks, 28 writeouts
[AVIOContext @ 0x7fa7576000c0] Statistics: 2499 bytes read, 0 seeks
}}}
The output stream is malformed, as revealed by `ffprobe`:
{{{
% ffprobe -v 9 -loglevel 99 -show_frames filtered.m4a
ffprobe version 3.2 Copyright (c) 2007-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.38)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-
ffplay --enable-frei0r --enable-libass --enable-libcaca --enable-libfdk-
aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-
libschroedinger --enable-libspeex --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-opencl --enable-openssl --disable-lzma --enable-
libopenjpeg --disable-decoder=jpeg2000 --extra-
cflags=-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1 --enable-
nonfree --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[file @ 0x7fe0ae600320] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] Format mov,mp4,m4a,3gp,3g2,mj2
probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] ISO: File Type Major Brand: M4A
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] Unknown dref type 0x08206c7275
size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] Processing st: 0, edit list 0 -
media time: 0, duration: 10272
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] Before
avformat_find_stream_info() pos: 2495 bytes read:2495 seeks:0 nb_streams:1
[aac @ 0x7fe0af004600] noise_facs_q 254 is invalid
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0af003a00] After
avformat_find_stream_info() pos: 78 bytes read:2495 seeks:0 frames:1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'filtered.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
encoder : Lavf57.56.100
Duration: 00:00:00.21, start: 0.000000, bitrate: 93 kb/s
Stream #0:0(und), 1, 1/48000: Audio: aac (HE-AAC) (mp4a / 0x6134706D),
96000 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
Processing read interval id:0 start:N/A end:N/A
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (45) exceeds
limit (41).
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (45) exceeds
limit (41).
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (45) exceeds
limit (41).
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (45) exceeds
limit (41).
[aac @ 0x7fe0af012600] Number of scalefactor bands in group (14) exceeds
limit (12).
[AVIOContext @ 0x7fe0ae40f340] Statistics: 2495 bytes read, 0 seeks
}}}
The same command line produces valid AAC output with FFmpeg 3.1.5.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/5973>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list