Opened 12 years ago

Closed 12 years ago

#960 closed defect (invalid)

h264 in ts: non monotonically increasing dts

Reported by: Aurélien Nephtali Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: av_interleaved_write_frame h264 ts
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

I have a sample : H.264/AAC wrapped in MPEG-TS whith cannot be transcoded (or copy using -vcodec copy) using ffmpeg-git.

jupiter@~/ffmpeg> ./ffmpeg -y -i /tmp/sample-non-monotonic-dts.ts -an -vcodec copy -f mpegts /dev/null
ffmpeg version N-37401-g151ecc2 Copyright (c) 2000-2012 the FFmpeg developers

built on Jan 31 2012 12:54:08 with gcc 4.6.2
configuration: --prefix=/home/aurelien/local --enable-postproc --enable-nonfree --enable-gpl --enable-libopencore-amrnb --enable-libfaac --enable-libmp3lame --enable-shared --enable-libxvid --enable-libx264 --extra-cflags=-I/home/aurelien/local/include --extra-ldflags=-L/home/aurelien/local/lib --enable-version3 --disable-optimizations
libavutil 51. 36.100 / 51. 36.100
libavcodec 54. 0.102 / 54. 0.102
libavformat 54. 0.100 / 54. 0.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 60.100 / 2. 60.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100

[mpegts @ 0xda43a0] max_analyze_duration 5000000 reached at 5000000
[mpegts @ 0xda43a0] PES packet size mismatch
Input #0, mpegts, from '/tmp/sample-non-monotonic-dts.ts':

Duration: 00:01:08.67, start: 0.500011, bitrate: 2189 kb/s
Program 1

Stream #0:0[0x3e8]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 16:11 DAR 20:11], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1e2](fra): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 192 kb/s (clean effects)

[mpegts @ 0xdab3e0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to '/dev/null':

Metadata:

encoder : Lavf54.0.100
Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 16:11 DAR 20:11], q=2-31, 50 fps, 90k tbn, 25 tbc

Stream mapping:

Stream #0:0 -> #0:0 (copy)

Press [q] to stop, ? for help
[mpegts @ 0xdab3e0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 23399 >= 23399
av_interleaved_write_frame(): Invalid argument

It does not work with ffmpeg version shipped with Debian Squeeze either.

jupiter@~> ffmpeg -y -i /tmp/sample-non-monotonic-dts.ts -an -vcodec copy -f mpegts /dev/null
FFmpeg version SVN-r0.5.6-4:0.5.6-3, Copyright (c) 2000-2009 Fabrice Bellard, et al.

configuration: --extra-version=4:0.5.6-3 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libfaad --enable-libdc1394 --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Dec 31 2011 16:14:46, gcc: 4.4.5

Input #0, mpegts, from '/tmp/sample-non-monotonic-dts.ts':

Duration: 00:01:08.67, start: 0.500022, bitrate: 2189 kb/s
Program 1

Stream #0.0[0x3e8]: Video: h264, yuv420p, 720x576 [PAR 16:11 DAR 20:11], 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1e2](fra): Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s

Output #0, mpegts, to '/dev/null':

Stream #0.0: Video: 0x0000, yuv420p, 720x576 [PAR 16:11 DAR 20:11], q=2-31, 90k tbn, 25 tbc

Stream mapping:

Stream #0.0 -> #0.0

Press [q] to stop encoding
[mpegts @ 0x170b870]dts < pcr, TS is invalid

Last message repeated 220 times

[NULL @ 0x170a710]error, non monotone timestamps 23398 >= 23398
av_interleaved_write_frame(): Error while opening file

Sample name : sample-non-monotonic-dts.ts (uploaded on upload.ffmpeg.org)

Here are two frames taken from the sample :

NEW DATA

PID : 1000
Size : 5280
PTS : 81000
DTS : 68400

NEW DATA

PID : 1000
Size : 1072
PTS : 68400
DTS : no value

I guess the problem is the second frame has pts=dts=68400 which is also the dts of the previous frame though I don't know if the sample is valid regarding ISO 13818-1.

Attachments (1)

sample-non-monotonic-dts_cut.ts (2.4 MB ) - added by Carl Eugen Hoyos 12 years ago.

Change History (6)

comment:1 by Carl Eugen Hoyos, 12 years ago

Component: avformatundetermined
Priority: importantnormal

Do you think this is a regression?
Please provide the sample.

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

I don't know if this is a regression. All I can say is that it's working fine with VLC.
I provided a sample : "Sample name : sample-non-monotonic-dts.ts (uploaded on upload.ffmpeg.org)"
Do you want a public URL ?

by Carl Eugen Hoyos, 12 years ago

comment:3 by Carl Eugen Hoyos, 12 years ago

Keywords: av_interleaved_write_frame h264 ts added
Reproduced by developer: set
Status: newopen

comment:4 by Carl Eugen Hoyos, 12 years ago

Summary: Application provided invalid, non monotonically increasing dts to muxerh264 in ts: non monotonically increasing dts

comment:5 by Mike, 12 years ago

Analyzed by developer: set
Resolution: invalid
Status: openclosed

As you've already noticed, the timestamps in this stream are not valid. The duplicate timestamps happen many, many times in this file. The file is broken.

The only way to (maybe) fix this *with ffmpeg* is to re-encode the video, which will generate new timestamps as a side-effect. Even then, you may discover that audio sync gets more and more wrong as you play the file (I didn't check). For example:

./ffmpeg -vsync 0 -i sample-non-monotonic-dts_cut.ts -vcodec mpeg2video -b:v 5000000 -acodec copy out.ts

You need the '-vsync 0' option because the input video has field pictures, not frame pictures, and ffmpeg gets the input frame rate wrong. This bug has existed forever.


Last edited 12 years ago by Mike (previous) (diff)
Note: See TracTickets for help on using tickets.