Opened 4 years ago

Closed 4 years ago

#8428 closed defect (fixed)

ffmpeg has problems with some AC-3/EAC-3 files with "syncword" 0x770b

Reported by: Anon-san Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: ac3
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
ffmpeg only seem to distinguish AC-3(.ac3)/EAC-3(.ec3) files by a 0x0b77 syncword. so when i pass on an .ac3 file with 0x770b syncword to ffmpeg, it shows me the wrong .ac3 info. but when it comes to decoding said file into a lossless little-endian 16-bit PCM file with a RIFF header it only seems to have an entirely different header info from what's shown in mind. yet for whatever reason ffmpeg just stops decoding the whole thing after just two seconds.
How to reproduce:

H:\ffmpeg\bin>ffmpeg.exe -i H:\ffmpeg\bin\[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.ac3 H:\ffmpeg\bin\[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.wav
ffmpeg version git-2019-12-11-13f2b6d Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 36.101 / 56. 36.101
  libavcodec     58. 64.101 / 58. 64.101
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.101 / 58.  9.101
  libavfilter     7. 68.100 /  7. 68.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[ac3 @ 000001c92b258ec0] Estimating duration from bitrate, this may be inaccurate
Input #0, ac3, from 'H:\ffmpeg\bin\[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.ac3':
  Duration: 00:02:51.78, start: 0.000000, bitrate: 112 kb/s
    Stream #0:0: Audio: eac3, 44100 Hz, 2.1, fltp, 112 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (eac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[eac3 @ 000001c92b266980] Multiple frames in a packet.
[eac3 @ 000001c92b266980] incomplete frame
H:\ffmpeg\bin\[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.ac3: corrupt decoded frame in stream 0
Output #0, wav, to 'H:\ffmpeg\bin\[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.wav':
  Metadata:
    ISFT            : Lavf58.35.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 5.1(side), s16, 4608 kb/s
    Metadata:
      encoder         : Lavc58.64.101 pcm_s16le
[eac3 @ 000001c92b266980] new coupling strategy must be present in block 0
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] new snr offsets must be present in block 0
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] new coupling strategy must be present in block 0
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] new coupling strategy must be present in block 0
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] invalid coupling range (12 >= 11)
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] expacc 125 is out-of-range
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 000001c92b266980] exponent -2 is out-of-range
[eac3 @ 000001c92b266980] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
size=    1296kB time=00:00:02.30 bitrate=4608.4kbits/s speed=12.1x
video:0kB audio:1296kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.007686%

Anyway, the .7z file (which contains the .ac3 sample file) was made using 7-Zip ZS, an off-shoot of 7-Zip which apparently supports more compression algorithms than what base 7-Zip currently has. The version I used for this one is 19.00 v1.4.4 R1(Release 1).

this bug could be an endianness problem for all i care, but keep in mind that i only have an .ac3 file with me as of this writing. anyway, here's the file.
[https://www.sendspace.com/file/dzrgkm
[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.7z]
i got the file using my own quickBMS script that demuxes some dat+sz movie format i managed to discover through some PS2 game, hence the filename.

Change History (11)

comment:1 by Anon-san, 4 years ago

Version: unspecifiedgit-master

comment:2 by Carl Eugen Hoyos, 4 years ago

Please upload the uncompressed file, as required per https://ffmpeg.org/bugreports.html

comment:4 by Anon-san, 4 years ago

sooooooooooooorryyyyyyyyyyyyyyyyyyyyyyyy.
[https://www.sendspace.com/file/i0z2mm/
[some_ps2_game][ac3_file_demuxed_from_dat+sz_file]movie_01.ac3]

and secondly, yes it is 0x0b77 but bit-reversed into 0x770b instead alongside all its data with it.

Last edited 4 years ago by Anon-san (previous) (diff)

comment:5 by Anon-san, 4 years ago

new link.
uncommon_ac3_that_ffmpeg_cant_handle
these files might be uploaded later into an FTP server as per the "Bug Reports" page

dolby_digital_file_with_header_except_this_file_plays_way_too_fast.ac3 decodes well but it decodes too fast.
strangely_encoded_ac3_file_that_hangs_up_after_two_seconds_when_decoding_or_playing_it_on_anything_else_that_supports_ac3.ac3 also decodes well until about 2 seconds with literally the same error and the same wrong header info AGAIN.

yeah the file names are overly detailed, i just wanted to double down on that regard.

ffmpeg report(for strangely_encoded_ac3_file_that_hangs_up_after_two_seconds_when_decoding_or_playing_it_on_anything_else_that_supports_ac3.ac3 only, file used to have demo.ac3 name, sorry about that):

H:\ffmpeg\bin>ffmpeg.exe -i H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\demo.ac3
ffmpeg version git-2020-02-16-8578433 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[ac3 @ 000001efb31a8c00] Estimating duration from bitrate, this may be inaccurate
Input #0, ac3, from 'H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\demo.ac3':
  Duration: 00:02:51.78, start: 0.000000, bitrate: 112 kb/s
    Stream #0:0: Audio: eac3, 44100 Hz, 2.1, fltp, 112 kb/s
At least one output file must be specified

H:\ffmpeg\bin>ffmpeg.exe -i H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\demo.ac3 H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\ac3_file_that_sorta_fails_to_decode.wav
ffmpeg version git-2020-02-16-8578433 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[ac3 @ 0000022baf7f8f00] Estimating duration from bitrate, this may be inaccurate
Input #0, ac3, from 'H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\demo.ac3':
  Duration: 00:02:51.78, start: 0.000000, bitrate: 112 kb/s
    Stream #0:0: Audio: eac3, 44100 Hz, 2.1, fltp, 112 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (eac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[eac3 @ 0000022baf806b00] Multiple frames in a packet.
[eac3 @ 0000022baf806b00] incomplete frame
H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\demo.ac3: corrupt decoded frame in stream 0
Output #0, wav, to 'H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\ac3_file_that_sorta_fails_to_decode.wav':
  Metadata:
    ISFT            : Lavf58.38.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 5.1(side), s16, 4608 kb/s
    Metadata:
      encoder         : Lavc58.70.100 pcm_s16le
[eac3 @ 0000022baf806b00] new coupling strategy must be present in block 0
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] new snr offsets must be present in block 0
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] new coupling strategy must be present in block 0
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] new coupling strategy must be present in block 0
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] invalid coupling range (12 >= 11)
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] expacc 125 is out-of-range
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
[eac3 @ 0000022baf806b00] exponent -2 is out-of-range
[eac3 @ 0000022baf806b00] error decoding the audio block
Error while decoding stream #0:0: Error number -16976906 occurred
size=    1296kB time=00:00:02.30 bitrate=4608.4kbits/s speed=21.1x
video:0kB audio:1296kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.007686%

ffplay report:

H:\ffmpeg\bin>ffplay.exe -i H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\strangely_encoded_ac3_file.ac3
ffplay version git-2020-02-16-8578433 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[ac3 @ 00000271ee5a6f80] Estimating duration from bitrate, this may be inaccurate
Input #0, ac3, from 'H:\pcsx2-v1.5.0-dev-3358-g6ef0e9452-windows-x86\logs\strangely_encoded_ac3_file.ac3':
  Duration: 00:02:51.78, start: 0.000000, bitrate: 112 kb/s
    Stream #0:0: Audio: eac3, 44100 Hz, 2.1, fltp, 112 kb/s
SDL_OpenAudio (3 channels, 44100 Hz): Unsupported number of audio channels.
[eac3 @ 00000271ee5b6c80] Multiple frames in a packet.
[eac3 @ 00000271ee5b6c80] incomplete frame    0KB sq=    0B f=0/0
[eac3 @ 00000271ee5b6c80] new coupling strategy must be present in block 0
[eac3 @ 00000271ee5b6c80] error decoding the audio block
[eac3 @ 00000271ee5b6c80] new snr offsets must be present in block 0
[eac3 @ 00000271ee5b6c80] error decoding the audio block 0B f=0/0
[eac3 @ 00000271ee5b6c80] new coupling strategy must be present in block 0
[eac3 @ 00000271ee5b6c80] error decoding the audio block
[eac3 @ 00000271ee5b6c80] new coupling strategy must be present in block 0
[eac3 @ 00000271ee5b6c80] error decoding the audio block
[eac3 @ 00000271ee5b6c80] invalid coupling range (12 >= 11)
[eac3 @ 00000271ee5b6c80] error decoding the audio block
[eac3 @ 00000271ee5b6c80] expacc 125 is out-of-range
[eac3 @ 00000271ee5b6c80] error decoding the audio block
[eac3 @ 00000271ee5b6c80] exponent -2 is out-of-range    0B f=0/0
[eac3 @ 00000271ee5b6c80] error decoding the audio block
   2.23 M-A:  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

this issue persists even on the latest windows build of ffmpeg, ffplay and ffprobe (all of them on "version git-2020-02-20-56df829").

Last edited 4 years ago by Anon-san (previous) (diff)

comment:6 by Elon Musk, 4 years ago

How are such files encoded/created?

comment:7 by Anon-san, 4 years ago

i just had to find them out after data-mining a PS2 game called The Bouncer.

strangely_encoded_ac3_file_that_hangs_up_after_two_seconds_when_decoding_or_playing_it_on_anything_else_that_supports_ac3.ac3 is (or at the very least appears to be) a legit AC-3 file that came from a .dat+.sz "video+audio" file as used by the game. i extracted said AC-3 file out of said .dat+.sz file through this quickbms script:
squaresoft-square.enix_sz_dat.bms
this script here is my work and it's still WIP.

dolby_digital_file_with_header_except_this_file_plays_way_too_fast.ac3 was sorta generated after passing through the game with PCSX2. simply put, the game has a built-in option for Dolby Digital as its output audio that only really works in some places. i can't really explain how the file ended up into what it was here.

as for your question i just sorta answered it by covering only the "created" part. i just had to find a sample.

Last edited 4 years ago by Anon-san (previous) (diff)

comment:8 by Elon Musk, 4 years ago

I fixed first file, and posted patch, the second file is spdif infected and probably broken.

in reply to:  8 comment:9 by Anon-san, 4 years ago

as for the second file, i can't do much about that but thanks for taking the time to do this otherwise.

comment:11 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedavcodec
Keywords: ac3 added
Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.