Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#7876 closed defect (fixed)

Using copyts with mpegts output fails after 26,5 hours

Reported by: malakudi Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: copyts mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When outputing to mpegts format, using -copyts option makes program fail after the oveflow of mpegts PCR happens at around 26 hours and 30 minutes. When not using -copyts, only a warning is reported.

In order to reproduce the issue, you first have to create a 27 hour mpegts video. I create it like that:

ffmpeg-git -t 97200 -f lavfi -i color=color=red -f lavfi -i sine=frequency=1000 -filter_complex '[1:a][1:a]amerge=inputs=2[aout]' -map 0:v -map '[aout]' -shortest -c:v libx264 -preset ultrafast -c:a libfdk_aac -ac 2 -vbr 2 -r 25 -f mpegts -y 27hours.ts

I named the produced file 27hours.ts and it takes around 760MB of disk space. It takes a while to create this file, depending on your CPU.

Running now the following command creates tons of errors after 26h 30m.

ffmpeg-git -copyts -i 27hours.ts -c copy -f mpegts -y /dev/null
ffmpeg version N-93715-gd0e4d0429e Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg --disable-libopencv --disable-podpages --disable-sndio --disa
ble-debug --enable-libaom --enable-avfilter --enable-avresample --enable-gcrypt --enable-gnutls --enable-gpl --enable-libass --enabl
e-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libfdk-aac --enable-libfontconfig --enabl
e-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmp3lame --enable-
libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable
-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtesseract --ena
ble-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --ena
ble-libzvbi --enable-libnpp --enable-cuda-nvcc --enable-nonfree --enable-opencl --enable-opengl --enable-postproc --enable-pthreads 
--enable-static --disable-shared --enable-version3 --enable-libwebp --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-
linux-gnu --prefix=/usr --toolchain=hardened --enable-frei0r --enable-chromaprint --enable-libx264 --enable-libiec61883 --enable-lib
dc1394 --enable-vaapi --enable-libmfx --disable-altivec --enable-libvmaf --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 52.100 / 58. 52.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 50.100 /  7. 50.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mpegts, from '27hours.ts':
  Duration: 00:29:16.33, start: 1.400000, bitrate: 3630 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 320x240 [SAR 1:1 DAR 4:3]
, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 25 kb/s
Output #0, mpegts, to '/dev/null':
  Metadata:
    encoder         : Lavf58.27.103
    Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-3
1, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 25 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=2374722 fps=131928 q=-1.0 size=  760576kB time=26:23:10.28 bitrate=  65.6kbits/s speed=5.28e+03x    
[mpegts @ 0x55630f5ea700] DTS 788 < 8589931780 out of order
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931780, current: 788; changing to 8589931781. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931781, current: 4388; changing to 8589931782. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931782, current: 7988; changing to 8589931783. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931783, current: 11588; changing to 8589931784. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931784, current: 15188; changing to 8589931785. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931785, current: 18788; changing to 8589931786. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931786, current: 22388; changing to 8589931787. This may result in incorrect timestamps in the output file.
[mpegts @ 0x55630f6887c0] Non-monotonous DTS in output stream 0:0; previous: 8589931787, current: 25988; changing to 8589931788. This may result in incorrect timestamps in the output file.

and keeps going till the end.

This problem is resolved if you use the attached diff file. It's not my own work, source is https://github.com/arut/ffmpeg-patches/blob/master/mpegts-33bit , I just modified it in order to apply in current git.

Using -copyts is important in some live streaming cases and failing after 26,5 hours of streaming is a problem.

Attachments (1)

mpegts-33bit.diff (1.3 KB ) - added by malakudi 5 years ago.
Implements smooth 33-bit mpeg-ts timestamp overflow in mpegts muxer.

Download all attachments as: .zip

Change History (8)

by malakudi, 5 years ago

Attachment: mpegts-33bit.diff added

Implements smooth 33-bit mpeg-ts timestamp overflow in mpegts muxer.

comment:1 by mkver, 5 years ago

Component: undeterminedavformat

Send the patch to the mailing list (ffmpeg-devel@ffmpeg.org). Patches are ignored on this bugtracker.

comment:2 by malakudi, 5 years ago

Developers don't look those tickets? If bugtracker is not used by the developers, what is the purpose? Anyway, if I send the patch to the mailing list, should I mention again all that is written on this ticket?

Last edited 5 years ago by malakudi (previous) (diff)

comment:3 by Gyan, 5 years ago

The bug-tracker serves to identify, catalogue and curate reports. Proposed code changes and their review take place on the development mailing list.

Anyway, if I send the patch to the mailing list, should I mention again all that is written on this ticket?

Provide a brief description of the issue and what the patch does, in your commit message. Also mention the ticket number.

comment:4 by malakudi, 5 years ago

OK, I sent it to ffmpeg-devel.

comment:5 by Dennis E. Mungai, 4 years ago

Any updates on this?

comment:6 by Carl Eugen Hoyos, 4 years ago

Resolution: fixed
Status: newclosed

comment:7 by Balling, 3 years ago

It still prints

[mpegts @ 0000018e9e8ce140] DTS 2298 < 8589933290 out of order

Also Duration: 00:29:16.31, which is wrong...

Note: See TracTickets for help on using tickets.