Opened 9 years ago

Closed 8 years ago

#5343 closed defect (fixed)

flac decoding throws "non monotonically increasing dts" error causing audio dropout

Reported by: Will Wolcott Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: flac regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I occasionally run across a flac file which decodes with an "Application provided invalid, non monotonically increasing dts to muxer" error. This error is relatively harmless on some machines, but when I run this on an EC2 instance, the decode results in a block of audio silence at the sample where the error is pointing.

Any number of alterations to the exact bits in the encode (lpc_type, minor sample alterations, etc.) prevent the decode errors. However, the silent block is 100% reproducible on my machine for flac files exhibiting this problem.

Example flac file and corresponding ffmpeg output attached:

$ ~/ffmpeg/ffmpeg -i 5074690822_chol.flac output.wav
ffmpeg version N-79055-g7725210 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: 
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.103 / 57. 28.103
  libavformat    57. 28.102 / 57. 28.102
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
Input #0, flac, from '5074690822_chol.flac':
  Metadata:
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    TIMECODE        : 00:59:59:00
    ENCODER         : Lavf56.19.100
  Duration: 00:00:30.00, start: 0.000000, bitrate: 5363 kb/s
    Stream #0:0: Audio: flac, 48000 Hz, 7.1, s32 (24 bit)
Output #0, wav, to 'output.wav':
  Metadata:
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    ISMP            : 00:59:59:00
    ISFT            : Lavf57.28.102
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 7.1, s16 (24 bit), 6144 kb/s
    Metadata:
      encoder         : Lavc57.28.103 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[wav @ 0x3987540] Non-monotonous DTS in output stream 0:0; previous: 1055232, current: 1041408; changing to 1055232. This may result in incorrect timestamps in the output file.
[wav @ 0x3987540] Non-monotonous DTS in output stream 0:0; previous: 1055232, current: 1046016; changing to 1055232. This may result in incorrect timestamps in the output file.
[wav @ 0x3987540] Non-monotonous DTS in output stream 0:0; previous: 1055232, current: 1050624; changing to 1055232. This may result in incorrect timestamps in the output file.
size=   22356kB time=00:00:30.00 bitrate=6104.7kbits/s speed= 109x    
video:0kB audio:22356kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000533%

Change History (5)

comment:1 by Will Wolcott, 9 years ago

Priority: normalimportant

flac example file:

http://www.datafilehost.com/d/9da82307

With format=null, gives a similar error:

ffmpeg started on 2016-03-15 at 17:24:52
Report written to "ffmpeg-20160315-172452.log"
Command line:
/home/wwolcott/ffmpeg/ffmpeg -v 9 -loglevel 99 -report -i non-monotonically-error.flac -f null /dev/null
ffmpeg version N-79055-g7725210 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: 
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.103 / 57. 28.103
  libavformat    57. 28.102 / 57. 28.102
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
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 '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input file with argument 'non-monotonically-error.flac'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '/dev/null' ... 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 report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file non-monotonically-error.flac.
Successfully parsed a group of options.
Opening an input file: non-monotonically-error.flac.
[file @ 0x1e194e0] Setting default whitelist 'file'
[flac @ 0x1e18de0] Format flac probed with size=2048 and score=50
[flac @ 0x1e18de0] Before avformat_find_stream_info() pos: 8385 bytes read:32768 seeks:0
[flac @ 0x1e18de0] All info found
[flac @ 0x1e18de0] After avformat_find_stream_info() pos: 582656 bytes read:589824 seeks:0 frames:1
Input #0, flac, from 'non-monotonically-error.flac':
  Metadata:
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    TIMECODE        : 00:59:59:00
    ENCODER         : Lavf56.19.100
  Duration: 00:00:30.00, start: 0.000000, bitrate: 5363 kb/s
    Stream #0:0, 1, 1/48000: Audio: flac, 48000 Hz, 7.1, s32 (24 bit)
Successfully opened the file.
Parsing a group of options: output file /dev/null.
Applying option f (force format) with argument null.
Successfully parsed a group of options.
Opening an output file: /dev/null.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x1e1df80] Setting 'time_base' to value '1/48000'
[graph 0 input from stream 0:0 @ 0x1e1df80] Setting 'sample_rate' to value '48000'
[graph 0 input from stream 0:0 @ 0x1e1df80] Setting 'sample_fmt' to value 's32'
[graph 0 input from stream 0:0 @ 0x1e1df80] Setting 'channel_layout' to value '0x63f'
[graph 0 input from stream 0:0 @ 0x1e1df80] tb:1/48000 samplefmt:s32 samplerate:48000 chlayout:0x63f
[audio format for output stream 0:0 @ 0x1e1e9c0] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:0 @ 0x1e1e9c0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0x1e1d2c0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x1e20940] [SWR @ 0x1e39020] Using fltp internally between filters
[auto-inserted resampler 0 @ 0x1e20940] ch:8 chl:7.1 fmt:s32 r:48000Hz -> ch:8 chl:7.1 fmt:s16 r:48000Hz
Output #0, null, to '/dev/null':
  Metadata:
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    TIMECODE        : 00:59:59:00
    encoder         : Lavf57.28.102
    Stream #0:0, 0, 1/48000: Audio: pcm_s16le, 48000 Hz, 7.1, s16 (24 bit), 6144 kb/s
    Metadata:
      encoder         : Lavc57.28.103 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[flac @ 0x1e18de0] first_dts 0 not matching first dts 999936 (pts 999936, duration 4608) in the queue
[NULL @ 0x1e19c40] Junk frame till offset 182679
[NULL @ 0x1e19c40] dropping low score 30 frame header from offset 0 to 59259
[NULL @ 0x1e19c40] dropping low score 20 frame header from offset 59259 to 120555
[NULL @ 0x1e19c40] dropping low score 10 frame header from offset 120555 to 143665
[NULL @ 0x1e19c40] dropping low score 1 frame header from offset 143665 to 143671
[NULL @ 0x1e19c40] dropping low score -9 frame header from offset 143671 to 143677
[NULL @ 0x1e19c40] dropping low score -11 frame header from offset 143677 to 182679
[flac @ 0x1eb9400] underread: 123420 orig size: 182679
[null @ 0x1e1bb40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1055232 >= 1041408
[null @ 0x1e1bb40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1055232 >= 1046016
[null @ 0x1e1bb40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1055232 >= 1050624
[null @ 0x1e1bb40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1055232 >= 1055232
[output stream 0:0 @ 0x1e1e2c0] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
size=N/A time=00:00:30.00 bitrate=N/A speed= 225x    
video:0kB audio:22356kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (non-monotonically-error.flac):
  Input stream #0:0 (audio): 311 packets read (20102982 bytes); 311 frames decoded (1430784 samples); 
  Total: 311 packets (20102982 bytes) demuxed
Output file #0 (/dev/null):
  Output stream #0:0 (audio): 311 frames encoded (1430784 samples); 311 packets muxed (22892544 bytes); 
  Total: 311 packets (22892544 bytes) muxed
311 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x1e21840] Statistics: 20111367 bytes read, 0 seeks

comment:2 by Carl Eugen Hoyos, 9 years ago

Component: ffmpegundetermined
Priority: importantnormal

Do you think that this is a regression?

comment:3 by Will Wolcott, 9 years ago

Doesn't seem like it. I went as far back as v2.3.3 looking for a version that doesn't produce the error and haven't found one.

comment:4 by Carl Eugen Hoyos, 9 years ago

Component: undeterminedavcodec
Keywords: flac regression added
Priority: normalimportant
Reproduced by developer: set
Status: newopen

Decoding is incorrect since 9300de0409d52272387a9b9d84143dba212291f4
Workaround is to specify -threads 1.

comment:5 by Michael Niedermayer, 8 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.