Opened 10 years ago

Closed 9 years ago

#3558 closed defect (fixed)

"-fflags +igndts" generates wrong dts when rewrapping some ts files to mp4

Reported by: wim_arbor Owned by:
Priority: wish Component: undetermined
Version: git-master Keywords: mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When copying the streams of a mpeg-ts containing h.264 and mpeg1L2 audio to mp4/mov using -fflags +igndts, av_interleaved_write_frame() reports: Invalid argument, pts (-10800) < dts (-3600). The output is (almost) empty. Without -fflags +igndts a proper output is created.

How to reproduce:

arbor@debian7:~$ bin/ffmpeg -y -fflags +igndts -i of_commercial_dvb_cut.ts -f mov -c:a copy -c:v copy out.mp4
ffmpeg version N-62439-g5e379cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 14 2014 13:41:14 with gcc 4.7 (Debian 4.7.2-5)
  configuration:
  libavutil      52. 76.100 / 52. 76.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
[mp3 @ 0x20fd2e0] Header missing
[mpegts @ 0x20f7a00] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from 'of_commercial_dvb_cut.ts':
  Duration: 00:00:05.96, start: 4576.668422, bitrate: 2523 kb/s
  Program 1
    Stream #0:0[0xa1]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x111](nla): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:2[0x489](nla): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
Output #0, mov, to 'out.mp4':
  Metadata:
    encoder         : Lavf55.37.100
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 720x576 [SAR 16:11 DAR 20:11], q=2-31, 25 fps, 90k tbn, 90k tbc
    Stream #0:1(nla): Audio: mp2 (.mp2 / 0x32706D2E), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov @ 0x20fe060] pts (-10800) < dts (-3600) in stream 0
av_interleaved_write_frame(): Invalid argument
frame=    2 fps=0.0 q=-1.0 Lsize=      55kB time=00:00:00.00 bitrate=N/A
video:61kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (2)

of_commercial_dvb_cut.ts (1.8 MB ) - added by wim_arbor 10 years ago.
source file
dts_error_refbframe.ts (1.8 MB ) - added by wim_arbor 10 years ago.
file which cannot be remuxed without -fflags +igndts

Change History (9)

by wim_arbor, 10 years ago

Attachment: of_commercial_dvb_cut.ts added

source file

comment:1 by wim_arbor, 10 years ago

Some observations:

  • Adding +genpts does not help.
  • Copying just the audio stream and transcoding the video stream results in a proper output using this commandline:
    ffmpeg -y -fflags +igndts -i of_commercial_dvb_cut.ts -f mov -c:a copy out.mp4
    
  • But copying just the videostream and transcoding the audio to aac does not resulting in the same error (pts<dts) using this commandline:
    ffmpeg -y -fflags +igndts -i of_commercial_dvb_cut.ts -strict -2 -f mov -c:v copy out.mp4
    
  • Transcoding both streams works fine.

in reply to:  description ; comment:2 by Carl Eugen Hoyos, 10 years ago

Replying to wim_arbor:

Without -fflags +igndts a proper output is created.

I don't understand: Why do you add this option if it breaks remuxing?

in reply to:  2 ; comment:3 by wim_arbor, 10 years ago

Priority: normalwish

Replying to cehoyos:

Replying to wim_arbor:

Without -fflags +igndts a proper output is created.

I don't understand: Why do you add this option if it breaks remuxing?

I also have files which require this option to be able to remux or transcode. I wanted to try to create a single set of options which work on all my files.

But I could try it without this option first, if it does not work try it with this option. I am just reporting that this option does not work correctly in all situations. So I will set the priority to wish as I have a workaround.

in reply to:  3 ; comment:4 by Carl Eugen Hoyos, 10 years ago

Replying to wim_arbor:

Replying to cehoyos:

Replying to wim_arbor:

Without -fflags +igndts a proper output is created.

I don't understand: Why do you add this option if it breaks remuxing?

I also have files which require this option to be able to remux or transcode.

Could you add such a sample for completeness?

in reply to:  4 comment:5 by wim_arbor, 10 years ago

Replying to cehoyos:

Replying to wim_arbor:

I also have files which require this option to be able to remux or transcode.

Could you add such a sample for completeness?

Yes, I can add such a sample (not today but later this week). Note that I already know that it is because the DTS is really wrong in those files. It is not a bug in FFmpeg, but FFmpeg is able to "repair" them.

by wim_arbor, 10 years ago

Attachment: dts_error_refbframe.ts added

file which cannot be remuxed without -fflags +igndts

in reply to:  4 comment:6 by wim_arbor, 10 years ago

Replying to cehoyos:

Replying to wim_arbor:

Replying to cehoyos:

Replying to wim_arbor:

Without -fflags +igndts a proper output is created.

I don't understand: Why do you add this option if it breaks remuxing?

I also have files which require this option to be able to remux or transcode.

Could you add such a sample for completeness?

I have attached such a sample. Here is the diagnostics I performed on that file;

Starting with the first I-Frame, attachment:dts_error_refbframe.ts contains the following values for PTS/DTS (PID 481/video):

754: PTS: 5562850426 DTS: 5562846826
821: PTS: 5562864826 DTS: 5562850426
859: PTS: 5562857626
866: PTS: 5562854026
875: PTS: 5562861226
879: PTS: 5562879226 DTS: 5562864826
891: PTS: 5562872026
902: PTS: 5562868426
905: PTS: 5562875626
908: PTS: 5562893626 DTS: 5562879226

It looks like the B-Frame with PTS=5562857626 is used as a reference frame. So this stream is correctly in decoding order, as that frame must be decoded before the frame with PTS=5562854026. But it needs a different (lower) DTS. So this file is no valid stream. (to be clear, it is not generated with ffmpeg).

Remuxing with ffmpeg without -fflags +igndts fails:

arbor@debian7:~$ bin/ffmpeg -y -i dts_error_refbframe.ts -f mov -c:a copy -c:v copy -bsf:a aac_adtstoasc out.mp4
ffmpeg version N-62439-g5e379cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 14 2014 13:41:14 with gcc 4.7 (Debian 4.7.2-5)
...
[mpegts @ 0x30549c0] DTS 5562792826 < 5562796426 out of order
...
Press [q] to stop, [?] for help
[mov @ 0x21cc440] Non-monotonous DTS in output stream 0:0; previous: 130560, current: 130560; changing to 130561. This may result in incorrect timestamps in the output file.
[mov @ 0x21cc440] pts (126960) < dts (130561) in stream 0
av_interleaved_write_frame(): Invalid argument
frame=    4 fps=0.0 q=-1.0 Lsize=      33kB time=00:00:01.45 bitrate= 186.1kbits/s
video:17kB audio:15kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.363399%

No problem that this fails, the DTS is wrong in the input file.

But with -fflags +igndts it succeeds;

arbor@debian7:~$ bin/ffmpeg -y -fflags +igndts -i dts_error_refbframe.ts -f mov -c:a copy -c:v copy -bsf:a aac_adtstoasc out.mp4
ffmpeg version N-62439-g5e379cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 14 2014 13:41:14 with gcc 4.7 (Debian 4.7.2-5)
...
[mpegts @ 0x20e3a20] DTS 5562792826 < 5562796426 out of order
...
Input #0, mpegts, from 'dts_error_refbframe.ts':
  Duration: 00:00:11.37, start: 61808.078511, bitrate: 1322 kb/s
  Program 1
    Stream #0:0[0x1e1]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1e2]: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 127 kb/s
Output #0, mov, to 'out.mp4':
  Metadata:
    encoder         : Lavf55.37.100
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 25 fps, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 127 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  251 fps=0.0 q=-1.0 Lsize=    1405kB time=00:00:11.29 bitrate=1019.4kbits/s
video:1229kB audio:167kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.648900%

There are other errors in the output because the file was not cut at an I-Frame.

comment:7 by wim_arbor, 9 years ago

Resolution: fixed
Status: newclosed

This issue seems to be fixed by 22844132069ebd2c0b2ac4e7b41c93c33890bfb9.

current version still shows a warning, but the output is ok.

arbor@debian7:~$ bin/ffmpeg  -y -fflags +igndts -i of_commercial_dvb_cut.ts -f mov -c:a copy -c:v copy out.mp4
ffmpeg version N-71212-g7034026 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.7 (Debian 4.7.2-5)
  configuration: --disable-yasm
  libavutil      54. 22.100 / 54. 22.100
  libavcodec     56. 33.100 / 56. 33.100
  libavformat    56. 28.100 / 56. 28.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
[mp3 @ 0x23c16c0] Header missing
[mpegts @ 0x23bc260] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from 'of_commercial_dvb_cut.ts':
  Duration: 00:00:06.00, start: 4576.668422, bitrate: 2506 kb/s
  Program 1 
    Stream #0:0[0xa1]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x111](nla): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Stream #0:2[0x489](nla): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
Output #0, mov, to 'out.mp4':
  Metadata:
    encoder         : Lavf56.28.100
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 720x576 [SAR 16:11 DAR 20:11], q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1(nla): Audio: mp2 (.mp2 / 0x32706D2E), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov @ 0x23c3080] Invalid DTS: -3600 PTS: -10800 in output stream 0:0, replacing by guess
[mov @ 0x23c3080] Non-monotonous DTS in output stream 0:0; previous: -7199, current: -10800; changing to -7198. This may result in incorrect timestamps in the output file.
[mov @ 0x23c3080] Non-monotonous DTS in output stream 0:0; previous: -7198, current: -7200; changing to -7197. This may result in incorrect timestamps in the output file.
[mpegts @ 0x23bc260] PES packet size mismatch
frame=  132 fps=0.0 q=-1.0 Lsize=    1586kB time=00:00:05.04 bitrate=2578.6kbits/s    
video:1480kB audio:101kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.335123%
Note: See TracTickets for help on using tickets.