Opened 8 years ago
Closed 5 years ago
#6333 closed defect (fixed)
ffplay returns error in case of flac picture data error
Reported by: | Mikhail Novosyolov | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avcodec |
Version: | git-master | Keywords: | flac regression |
Cc: | mattias.wadman@gmail.com | Blocked By: | |
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | yes |
Description
libavformat/flac_picture.c:116: av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
In that code, in case of error, it does "goto fail":
memset(data->data + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); if (avio_read(pb, data->data, len) != len) { av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n"); if (s->error_recognition & AV_EF_EXPLODE) ret = AVERROR(EIO); goto fail; }
So, I try to ffplay this file and ffmpeg does not play it, returning an error:
$ ffplay file.flac ffplay version 3.2.4-2~xenial Copyright (c) 2003-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --prefix=/usr --extra-version='2~xenial' --libdir=/usr/lib/ffmpeg --shlibdir=/usr/lib/ffmpeg --disable-static --disable-debug --toolchain=hardened --enable-pthreads --enable-runtime-cpudetect --enable-gpl --enable-shared --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-netcdf --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libkvazaar --enable-libopenh264 --enable-nonfree --enable-libfdk-aac libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 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 [flac @ 0x7f57b0000920] Error reading attached picture data.f=0/0 Input #0, flac, from 'file.flac': 0KB vq= 0KB sq= 0B f=0/0 Duration: 00:04:02.23, bitrate: 4517 kb/s Stream #0:0: Audio: flac, 44100 Hz, 5.1(side), s32 (24 bit) nan M-A: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
The same is with other programs using ffmpeg for decoding, e.g. mpv:
$ mpv file.flac Playing: file.flac [ffmpeg/demuxer] flac: Error reading attached picture data. (+) Audio --aid=1 (flac) Error initializing audio. Audio: no audio Exiting... (Errors when loading file)
But the file IS WELL playable with other decoders (e.g. in Amarok, Banshee, Clementine), and ffmpeg cannot transcode the file, while it seems to not return propper erros, the vast majority of console output is green, see the screenshot.
$ ffmpeg -v 9 -loglevel 99 -i file.flac file2.flac ffmpeg version 3.2.4-2~xenial Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --prefix=/usr --extra-version='2~xenial' --libdir=/usr/lib/ffmpeg --shlibdir=/usr/lib/ffmpeg --disable-static --disable-debug --toolchain=hardened --enable-pthreads --enable-runtime-cpudetect --enable-gpl --enable-shared --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-netcdf --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-libkvazaar --enable-libopenh264 --enable-nonfree --enable-libfdk-aac libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 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 '-i' ... matched as input url with argument 'file.flac'. Reading option 'file2.flac' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option v (set logging level) with argument 9. Successfully parsed a group of options. Parsing a group of options: input url file.flac. Successfully parsed a group of options. Opening an input file: file.flac. [file @ 0x55f7b9425cc0] Setting default whitelist 'file,crypto' Probing flac score:50 size:2048 [flac @ 0x55f7b9425460] Format flac probed with size=2048 and score=50 [flac @ 0x55f7b9425460] Error reading attached picture data. [flac @ 0x55f7b9425460] Before avformat_find_stream_info() pos: 4815279 bytes read:214681 seeks:1 nb_streams:1 [flac @ 0x55f7b9425460] stream 0: start_time: -209146758205323.719 duration: 242.227 [flac @ 0x55f7b9425460] format: start_time: -9223372036854.775 duration: 242.227 bitrate=4517 kb/s [flac @ 0x55f7b9425460] After avformat_find_stream_info() pos: 136786045 bytes read:132185447 seeks:1 frames:0 Input #0, flac, from 'file.flac': Duration: 00:04:02.23, bitrate: 4517 kb/s Stream #0:0, 0, 1/44100: Audio: flac, 44100 Hz, 5.1(side), s32 (24 bit) Successfully opened the file. Parsing a group of options: output url file2.flac. Successfully parsed a group of options. Opening an output file: file2.flac. [file @ 0x55f7b9429c20] Setting default whitelist 'file,crypto' Successfully opened the file. detected 4 logical cores [graph 0 input from stream 0:0 @ 0x55f7b942af00] Setting 'time_base' to value '1/44100' [graph 0 input from stream 0:0 @ 0x55f7b942af00] Setting 'sample_rate' to value '44100' [graph 0 input from stream 0:0 @ 0x55f7b942af00] Setting 'sample_fmt' to value 's32' [graph 0 input from stream 0:0 @ 0x55f7b942af00] Setting 'channel_layout' to value '0x60f' [graph 0 input from stream 0:0 @ 0x55f7b942af00] tb:1/44100 samplefmt:s32 samplerate:44100 chlayout:0x60f [audio format for output stream 0:0 @ 0x55f7b942b6e0] Setting 'sample_fmts' to value 's16|s32' [AVFilterGraph @ 0x55f7b9429de0] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed [flac @ 0x55f7b94290a0] compression: 5 [flac @ 0x55f7b94290a0] lpc type: Levinson-Durbin recursion with Welch window [flac @ 0x55f7b94290a0] prediction order: 1, 8 [flac @ 0x55f7b94290a0] order method: estimate [flac @ 0x55f7b94290a0] partition order: 0, 8 [flac @ 0x55f7b94290a0] block size: 4608 [flac @ 0x55f7b94290a0] lpc precision: 15 Output #0, flac, to 'file2.flac': Metadata: encoder : Lavf57.56.101 Stream #0:0, 0, 1/44100: Audio: flac, 44100 Hz, 5.1(side), s32 (24 bit), 128 kb/s Metadata: encoder : Lavc57.64.101 flac Stream mapping: Stream #0:0 -> #0:0 (flac (native) -> flac (native)) Press [q] to stop, [?] for help cur_dts is invalid (this is harmless if it occurs once at the start per stream) Last message repeated 2 times [output stream 0:0 @ 0x55f7b942ad80] EOF on sink link output stream 0:0:default. No more output streams to write to, finishing. size= 8kB time=00:00:00.00 bitrate=N/A speed= 0x video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Input file #0 (file.flac): Input stream #0:0 (audio): 0 packets read (0 bytes); 0 frames decoded (0 samples); Total: 0 packets (0 bytes) demuxed Output file #0 (file2.flac): Output stream #0:0 (audio): 0 frames encoded (0 samples); 1 packets muxed (0 bytes); Total: 1 packets (0 bytes) muxed 0 frames successfully decoded, 0 decoding errors [AVIOContext @ 0x55f7b9429aa0] Statistics: 2 seeks, 2 writeouts [AVIOContext @ 0x55f7b942e060] Statistics: 132185447 bytes read, 1 seeks
So it reports successfull transcoding, while the output file is not decodable. The input (file.flac) is 130 MB, the output (file2.flac) is 8 KB.
Attachments (1)
Change History (11)
by , 8 years ago
Attachment: | Приложение для снимков экрана Deepin 20170419152958.png added |
---|
comment:1 by , 8 years ago
Arttached file.flac (example input file, causing problems) via https://streams.videolan.org/upload/, specified ticket number 6333
comment:2 by , 8 years ago
The bug was originally reported here:
https://vk.com/wall-114916478_192270
comment:4 by , 8 years ago
Yes, it is.
$ ./ffmpeg ffmpeg version N-85595-g0f05f2c Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --disable-everything --enable-protocol=file --enable-demuxer=flac --enable-muxer=flac --enable-decoder=flac --enable-encoder=flac --enable-parser=flac --enable-ffplay libavutil 55. 61.100 / 55. 61.100 libavcodec 57. 93.100 / 57. 93.100 libavformat 57. 72.101 / 57. 72.101 libavdevice 57. 7.100 / 57. 7.100 libavfilter 6. 84.101 / 6. 84.101 libswscale 4. 7.101 / 4. 7.101 libswresample 2. 8.100 / 2. 8.100
comment:5 by , 8 years ago
Component: | undetermined → avformat |
---|---|
Keywords: | regression added |
Priority: | normal → important |
Reproduced by developer: | set |
Status: | new → open |
Version: | 3.2.4 → git-master |
Afaict, there is a bug in ff_flac_parse_picture() that makes reading the attachment of this file impossible.
Decoding fails since a5379d6e (I don't think the merge fixed anything).
comment:6 by , 5 years ago
- The length field for flac metadata blocks is 3 bytes long. A METADATA_BLOCK_PICTURE has its own length field for the length of the binary data and said field is four bytes long. These fields are 0x02C66B and 0x0102C642 and they are consistent in the sense that the implied length of the picture given by the metadata block picture size agrees with the lower 24 bits of the picture data length field.
- Afterwards lots of picture data gets shoved into the parser and runs afoul of a check designed to tackle invalid data. As a result of said check, new data (that is valid flac) doesn't even get looked for sync codes at all.
comment:7 by , 5 years ago
Analyzed by developer: | set |
---|---|
Component: | avformat → avcodec |
comment:8 by , 5 years ago
Fixed in master c9865fe7a48b223e162eabce21cc180f305c libavformat/flacdec: Workaround for truncated metadata picture size
comment:9 by , 5 years ago
Cc: | added |
---|
comment:10 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
screenshot of green and successfull-reporting console putput after trying to transcode