Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#3176 closed defect (fixed)

Transcoding with -copyts does not work with some MPEG-TS files/streams

Reported by: Aurélien Nephtali Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: copyts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hello,

ffmpeg is stuck when trying to transcode a video stream from some MPEG-TS files or streams (maybe other formats are affected).

It seems the problem lies in do_video_out() of ffmpeg.c (showing only the relevant lines) :

    sync_ipts = in_picture->pts;
    delta = sync_ipts - ost->sync_opts + duration;
    [...]
    case VSYNC_CFR:
        // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
        if (delta < -1.1)
            nb_frames = 0;
        else if (delta > 1.1)
            nb_frames = lrintf(delta);
    [...]
  /* duplicates frame if needed */
  for (i = 0; i < nb_frames; i++) {
    av_init_packet(&pkt);
    pkt.data = NULL;
    pkt.size = 0;

the lrintf() call sets nb_frames to a very huge value (since delta is huge) and the frame is then duplicated (in my example file i get nb_frames=2013400).

My guess is that -copyts seems to work fine when the first pts is very close to 0 but not when it starts from a big value.

I uploaded the sample copyts_pictures_dup.ts on the FTP.

How to reproduce:

% ffmpeg -i /dump/copyts_pictures_dup.ts -copyts -an -vcodec libx264 -profile:v baseline -r 25 -s 144x96 -b:v 200k -preset ultrafast -filter:v yadif -f mpegts -y /dev/null
ffmpeg version N-58499-gb723c4e Copyright (c) 2000-2013 the FFmpeg developers
  built on Nov 27 2013 19:40:04 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --prefix=/home/aurelien/local --enable-postproc --enable-nonfree --enable-gpl --enable-libfaac --enable-shared --enable-libx264 --extra-cflags=-I/home/aurelien/local/include --extra-ldflags=-L/home/aurelien/local/lib --enable-version3 --disable-optimizations --enable-libfreetype --disable-stripping --enable-libaacplus --enable-libfdk-aac
  libavutil      52. 55.100 / 52. 55.100
  libavcodec     55. 44.100 / 55. 44.100
  libavformat    55. 21.102 / 55. 21.102
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     3. 91.100 /  3. 91.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[h264 @ 0x1103c80] non-existing PPS referenced
[h264 @ 0x1103c80] non-existing PPS 0 referenced
[h264 @ 0x1103c80] decode_slice_header error
[... non-existing PPS messages skipped ...]
[mpegts @ 0x22c9b40] PES packet size mismatch
Input #0, mpegts, from '/dump/copyts_pictures_dup.ts':
  Duration: 00:00:08.09, start: 80533.820156, bitrate: 9297 kb/s
  Program 234 
    Stream #0:0[0x3fc]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x3fd](fra): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x3fe](qaa): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
[libx264 @ 0x22d0040] using SAR=32/27
[libx264 @ 0x22d0040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x22d0040] profile Constrained Baseline, level 1.3
Output #0, mpegts, to '/dev/null':
  Metadata:
    encoder         : Lavf55.21.102
    Stream #0:0: Video: h264 (libx264), yuv420p, 144x96 [SAR 32:27 DAR 16:9], q=-1--1, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
[h264 @ 0x36b2d60] reference picture missing during reorder
[h264 @ 0x36b2d60] Missing reference picture, default is 2147483647
[h264 @ 0x3766840] mmco: unref short failure
[h264 @ 0x398fa40] reference picture missing during reorder
[h264 @ 0x398fa40] Missing reference picture, default is 65516
[h264 @ 0x39fe440] mmco: unref short failure
[h264 @ 0x36f7ec0] mmco: unref short failure
[h264 @ 0x398fa40] mmco: unref short failure

<<< need to Ctrl-C twice to kill ffmpeg from here >>>

Change History (2)

comment:1 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: newclosed

Fixed by Michael in 738ebb4a
Thank you for the report!

comment:2 by Aurélien Nephtali, 10 years ago

Confirmed, thanks !

Note: See TracTickets for help on using tickets.