Log in

View Full Version : ffmpeg non monotone timestamps M2TS -> MP4


DanN
28th November 2010, 16:23
I want to join avchd/mts files from a camcorder to a single mp4 file without re-encoding. There is an issue with audio/video sync coming from mts clips having different audio and video length. I managed to create a script with help from http://www.kucher.org/projects/avchd/

Now after upgrading my computer to Ubuntu 10.04 I have a problem with ffmpeg (that also was upgraded from SVN-r20918 (Dec 25 2009) to SVN-r25837 (Nov 28 2010)).

The script uses “eac3to.exe”, tsMuxeR and ffmpeg for joining and repackaging the clips in 3 steps:
1. eac3to.exe (wine) to join and demux ac3 and h264 streams
2. tsMuxeR to to mux the the ac3 and h264 streams. Output is a m2ts file with audio and video in sync.
3. ffmpeg to repackage the m2ts to a mp4 file

Now I get an error in the last step when running “ffmpeg -i temp.m2ts -f mp4 -vcodec copy -acodec copy test.mp4”:

[mp4 @ 0xa08daa0] st:0 error, non monotone timestamps 1 >= 1
av_interleaved_write_frame(): Operation not permitted

The “test.mp4” is only 48 bytes and not working.

The complete output from ffmpeg is:

FFmpeg version SVN-r25837, Copyright (c) 2000-2010 the FFmpeg developers
built on Nov 28 2010 13:59:29 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50.33. 0 / 50.33. 0
libavcore 0.14. 0 / 0.14. 0
libavcodec 52.97. 2 / 52.97. 2
libavformat 52.87. 1 / 52.87. 1
libavdevice 52. 2. 2 / 52. 2. 2
libavfilter 1.65. 0 / 1.65. 0
libswscale 0.12. 0 / 0.12. 0
libpostproc 51. 2. 0 / 51. 2. 0

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
Input #0, mpegts, from 'temp.m2ts':
Duration: 00:00:12.96, start: 599.960033, bitrate: 23723 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, mp4, to 'test.mp4':
Metadata:
encoder : Lavf52.87.1
Stream #0.0: Video: libx264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[mp4 @ 0xa08daa0] st:0 error, non monotone timestamps 1 >= 1
av_interleaved_write_frame(): Operation not permitted

I am grateful for any advice.

And also: Is there a simpler batch processing on Linux, that join avchd/mts files to a single mp4 file without re-encoding?

Regards, Dan

roozhou
29th November 2010, 10:32
This has been a bug in ffmpeg for years. You can disable this error message in libavformat/utils.c and make your own ffmpeg build.

DanN
29th November 2010, 19:42
Thanks a lot. I solved my problem, but unfortunately my skills are not enough to supply a bug-fix. Regards, Dan

DanN
13th March 2011, 17:04
My ffmpeg package was removed by something called a "partial distribution upgrade" of Ubuntu 10.04. So I built a new ffmpeg to version git-N-28429-gfbe98ae.

This time I couldn't find the code to disable the "non monotone timestamps" error message in libavformat/utils.c.

Now ffmpeg does'nt produce any output, see below:

Running command: ffmpeg -i temp.m2ts -f mp4 -vcodec copy -acodec copy "2011-03-13 Stockholmsmästerskapen, Felicia.mp4"
FFmpeg version git-N-28429-gfbe98ae, Copyright (c) 2000-2011 the FFmpeg developers
built on Mar 13 2011 16:30:15 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 50. 39. 0 / 50. 39. 0
libavcodec 52.114. 0 / 52.114. 0
libavformat 52.103. 0 / 52.103. 0
libavdevice 52. 3. 0 / 52. 3. 0
libavfilter 1. 76. 0 / 1. 76. 0
libswscale 0. 12. 0 / 0. 12. 0
libpostproc 51. 2. 0 / 51. 2. 0

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
Input #0, mpegts, from 'temp.m2ts':
Duration: 00:11:21.12, start: 599.960033, bitrate: 23438 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, mp4, to '2011-03-13 Stockholmsmästerskapen, Felicia.mp4':
Metadata:
encoder : Lavf52.103.0
Stream #0.0: Video: libx264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[mp4 @ 0x9ff97e0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 1
av_interleaved_write_frame(): Operation not permitted

Any ideas?

Regards, Dan

roozhou
13th March 2011, 17:15
Hope this helps

@@ -2948,11 +2948,14 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){
av_log(s, AV_LOG_ERROR,
"Application provided invalid, non monotonically increasing dts to muxer in stream %d: %"PRId64" >= %"PRId64"\n",
st->index, st->cur_dts, pkt->dts);
- return -1;
+ pkt->dts = st->cur_dts + 1;
}
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){
av_log(s, AV_LOG_ERROR, "pts < dts in stream %d\n", st->index);

DanN
14th March 2011, 21:58
Thanks,

Now it seems to stumble on the next line, se below:

Running command: ffmpeg -i temp.m2ts -f mp4 -vcodec copy -acodec copy "2011-03-13 Stockholmsmästerskapen, Felicia.mp4"
FFmpeg version git-f1efbca, Copyright (c) 2000-2011 the FFmpeg developers
built on Mar 14 2011 21:33:01 with gcc 4.4.3
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame
libavutil 50. 39. 0 / 50. 39. 0
libavcodec 52.114. 0 / 52.114. 0
libavformat 52.103. 0 / 52.103. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1. 76. 0 / 1. 76. 0
libswscale 0. 12. 0 / 0. 12. 0
libpostproc 51. 2. 0 / 51. 2. 0

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
Input #0, mpegts, from 'temp.m2ts':
Duration: 00:11:21.12, start: 599.960033, bitrate: 23438 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, mp4, to '2011-03-13 Stockholmsmästerskapen, Felicia.mp4':
Metadata:
encoder : Lavf52.103.0
Stream #0.0: Video: libx264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 25 tbn, 25 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, 256 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[mp4 @ 0x9d49740] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1 >= 1
[mp4 @ 0x9d49740] pts < dts in stream 0
av_interleaved_write_frame(): Operation not permitted

New ideas?

Regards, Dan