[FFmpeg-trac] #9185(avformat:new): ffmpeg flac decoder incorrectly finds junk frame

FFmpeg trac at avcodec.org
Tue Apr 13 18:34:27 EEST 2021


#9185: ffmpeg flac decoder incorrectly finds junk frame
----------------------------------+--------------------------------------
             Reporter:  wader     |                     Type:  defect
               Status:  new       |                 Priority:  normal
            Component:  avformat  |                  Version:  git-master
             Keywords:            |               Blocked By:
             Blocking:            |  Reproduced by developer:  0
Analyzed by developer:  0         |
----------------------------------+--------------------------------------
 Summary of the bug:

 Raw flac demuxer seems to incorrectly discard frames.

 Example file was cut out from longer FLAC file that i unfortunately can't
 share. With the longer file the frames seem to also cause indeterministic
 behaviour when decoded using the ffmpeg http protocol.

 Tested with master as of 2021-04-13
 (33db0cbfd08384d611370006a77675cc6b778d12)

 Looking at the offsets 0, 352, 486, 497, and 621 in the 4:the frame they
 all seems to be false headers found amoung nearly silence samples (lots of
 bits set) in the first subframe.

 I was only able to produce a file triggering the issue using flac
 reference encoding.

 How to reproduce:
 {{{
 # make && ./ffmpeg_g -v trace -f flac -i flac_junk_frame_issue.flac -f
 null -
 ffmpeg version N-101944-g33db0cbfd0 Copyright (c) 2000-2021 the FFmpeg
 developers
   built with gcc 10.2.1 (Alpine 10.2.1_pre1) 20201203
   configuration: --enable-debug --disable-optimizations
   libavutil      56. 72.100 / 56. 72.100
   libavcodec     58.136.101 / 58.136.101
   libavformat    58. 78.100 / 58. 78.100
   libavdevice    58. 14.100 / 58. 14.100
   libavfilter     7.111.100 /  7.111.100
   libswscale      5. 10.100 /  5. 10.100
   libswresample   3. 10.100 /  3. 10.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument 'trace'.
 Reading option '-f' ... matched as option 'f' (force format) with argument
 'flac'.
 Reading option '-i' ... matched as input url with argument
 '/Users/wader/src/ffmpeg-master/flac_junk_frame_issue.flac'.
 Reading option '-f' ... matched as option 'f' (force format) with argument
 'null'.
 Reading option '-' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument trace.
 Successfully parsed a group of options.
 Parsing a group of options: input url /Users/wader/src/ffmpeg-
 master/flac_junk_frame_issue.flac.
 Applying option f (force format) with argument flac.
 Successfully parsed a group of options.
 Opening an input file: /Users/wader/src/ffmpeg-
 master/flac_junk_frame_issue.flac.
 [flac @ 0x7f03f3724040] Opening '/Users/wader/src/ffmpeg-
 master/flac_junk_frame_issue.flac' for reading
 [file @ 0x7f03f37bc6c0] Setting default whitelist 'file,crypto,data'
 [flac @ 0x7f03f3724040] Before avformat_find_stream_info() pos: 8304 bytes
 read:12029 seeks:0 nb_streams:1
 [flac @ 0x7f03f37195c0] Junk frame till offset 714
 [flac @ 0x7f03f37195c0] dropping low score 10 frame header from offset 0
 to 352
 [flac @ 0x7f03f37195c0] dropping low score -49 frame header from offset
 352 to 486
 [flac @ 0x7f03f37195c0] dropping low score -39 frame header from offset
 486 to 497
 [flac @ 0x7f03f37195c0] dropping low score -49 frame header from offset
 497 to 623
 [flac @ 0x7f03f37195c0] dropping low score -21 frame header from offset
 623 to 714
 [flac @ 0x7f03f3724040] All info found
 [flac @ 0x7f03f3724040] stream 0: start_time: 0 duration: 0.5
 [flac @ 0x7f03f3724040] format: start_time: 0 duration: 0.5 (estimate from
 stream) bitrate=192 kb/s
 [flac @ 0x7f03f3724040] After avformat_find_stream_info() pos: 12029 bytes
 read:12029 seeks:0 frames:1
 Input #0, flac, from '/Users/wader/src/ffmpeg-
 master/flac_junk_frame_issue.flac':
   Duration: 00:00:00.50, start: 0.000000, bitrate: 192 kb/s
   Stream #0:0, 1, 1/44100: Audio: flac, 44100 Hz, stereo, s16
 Successfully opened the file.
 Parsing a group of options: output url -.
 Applying option f (force format) with argument null.
 Successfully parsed a group of options.
 Opening an output file: -.
 Successfully opened the file.
 detected 2 logical cores
 Stream mapping:
   Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
 Press [q] to stop, [?] for help
 cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless
 if it occurs once at the start per stream)
     Last message repeated 2 times
 [graph_0_in_0_0 @ 0x7f03f36ff440] Setting 'time_base' to value '1/44100'
 [graph_0_in_0_0 @ 0x7f03f36ff440] Setting 'sample_rate' to value '44100'
 [graph_0_in_0_0 @ 0x7f03f36ff440] Setting 'sample_fmt' to value 's16'
 [graph_0_in_0_0 @ 0x7f03f36ff440] Setting 'channel_layout' to value '0x3'
 [graph_0_in_0_0 @ 0x7f03f36ff440] tb:1/44100 samplefmt:s16
 samplerate:44100 chlayout:0x3
 [format_out_0_0 @ 0x7f03f36ffe00] Setting 'sample_fmts' to value 's16'
 [AVFilterGraph @ 0x7f03f371aa40] query_formats: 4 queried, 9 merged, 0
 already done, 0 delayed
 Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf58.78.100
   Stream #0:0, 0, 1/44100: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411
 kb/s
     Metadata:
       encoder         : Lavc58.136.101 pcm_s16le
 [null @ 0x7f03f36fd040] Application provided invalid, non monotonically
 increasing dts to muxer in stream 0: 20480 >= 16384
 [null @ 0x7f03f36fd040] Application provided invalid, non monotonically
 increasing dts to muxer in stream 0: 20480 >= 20480
 [out_0_0 @ 0x7f03f36ff540] EOF on sink link out_0_0:default.
 No more output streams to write to, finishing.
 size=N/A time=00:00:00.55 bitrate=N/A speed=52.9x
 video:0kB audio:86kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 Input file #0 (/Users/wader/src/ffmpeg-master/flac_junk_frame_issue.flac):
   Input stream #0:0 (audio): 6 packets read (3725 bytes); 6 frames decoded
 (22050 samples);
   Total: 6 packets (3725 bytes) demuxed
 Output file #0 (pipe:):
   Output stream #0:0 (audio): 6 frames encoded (22050 samples); 6 packets
 muxed (88200 bytes);
   Total: 6 packets (88200 bytes) muxed
 6 frames successfully decoded, 0 decoding errors
 [AVIOContext @ 0x7f03f3724c40] Statistics: 12029 bytes read, 0 seeks
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/9185>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list