FFmpeg: Ticket #1425: Clips generated by ffmpeg using segment muxer are not correctly played on some videoplayershttp://trac.ffmpeg.org/ticket/1425
<p>
What I am trying to do:
I am trying to record a video stream from an IP camera (Axis 210). I am using segment to split the output in 5 second chunks and generate a playing list.
I would like to be able to play the videos on the playlist one after the other seamlessly.
And/or be able to reproduce each one of the segment clips as an standalone movie.
</p>
<p>
What happens:
During the recording there appears to be no problem, and the clips are generated without a problem.
</p>
<p>
If I open the playlist on VLC the first clip plays smoothly. Then I have 5 seconds where VLC counter is working, but no video is played, then the second clip is played (while the time counter goes up to something like 10/5). Then 10 seconds pause, and increasing for every clip.
</p>
<p>
It also happens when playing each of the clips separatedly.
On VLC each one will have a "no video" time equal to the added length of all preceding files (equal to the "start" time), first plays ok, 5 seconds before the start of video for the second, 10 for the third...
</p>
<p>
MPlayer OSX Extended plays the videos correctly, but the time line below the image is not correct. It indicates playing time starting on "start" (5 to 10 seconds on de second clip, ...) but if I try to move the video using the handle it tries to play the first 5 seconds (therefore restarting the clip).
</p>
<p>
Gnome MPlayer plays everything as I would like it (as if those were standalone movies of 5 second length).
</p>
<p>
Totem on Ubuntu plays it ok as well.
</p>
<p>
Quicktime opens and plays the first clip smoothly.
The rest of the clips, Quicktime opens them without any problem nor error message, but presenting a black screen. If I click play it plays a black screen as if everything was normal, for the duration of the clip (more or less 5 seconds in my test). Then it stops.
On the second clip a few frames may appear at the end (the length of the clip is 5 seconds, the start time of the stream is a little before than the end).
</p>
<p>
Ticket <a class="closed ticket" href="http://trac.ffmpeg.org/ticket/910" title="defect: Segmented encode gives increasing time clips (closed: invalid)">#910</a> (closed as invalid) might be related.
</p>
<p>
The command:
</p>
<pre class="wiki">% ffmpeg -v 9 -loglevel 99 -report \
-i "rtsp://192.168.1.222/mpeg4/1/media.amp" \
-map 0 \
-vcodec mpeg4 \
-t 60 -f segment \
-segment_time 5 -segment_format mp4 \
-segment_list testsegmentedmp4.m3u8 -segment_list_size 30 \
testsegmentstartdelay%03d.mp4
</pre><p>
Tested with current git head N-41352-gc8a1101:
</p>
<pre class="wiki">ffmpeg version N-41352-gc8a1101 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 6 2012 09:34:33 with gcc 4.6.1
configuration: --enable-gpl --enable-libx264 --enable-x11grab
libavutil 51. 56.100 / 51. 56.100
libavcodec 54. 25.100 / 54. 25.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 78.100 / 2. 78.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
</pre><p>
The output: please see attached ffmpeg log (ffmpeg-20120606-100145.log generated by -report).
</p>
en-usFFmpeg/ffmpeg-logo.pnghttp://trac.ffmpeg.org/ticket/1425
Trac 1.0.9knovzWed, 06 Jun 2012 09:31:25 GMTattachment sethttp://trac.ffmpeg.org/ticket/1425
http://trac.ffmpeg.org/ticket/1425
<ul>
<li><strong>attachment</strong>
set to <em>ffmpeg-20120606-100145.log</em>
</li>
</ul>
<p>
ffmpeg log generated by -report
</p>
TicketsasteWed, 15 Aug 2012 22:36:02 GMTanalyzed, status changed; resolution sethttp://trac.ffmpeg.org/ticket/1425#comment:1
http://trac.ffmpeg.org/ticket/1425#comment:1
<ul>
<li><strong>analyzed</strong>
set
</li>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>invalid</em>
</li>
</ul>
<p>
Please note that the generated playlist file is <strong>not</strong> an M3U8 file, so you can't expect players to play it like it was.
</p>
<p>
In order to generate an M3U8 playlist file you can use a script, or check ticket <a class="closed ticket" href="http://trac.ffmpeg.org/ticket/1642" title="enhancement: -f segment: automagically generate #EXTM3U tags to -segment_list ... (closed: fixed)">#1642</a> for which a patchset has been already posted.
</p>
TicketknovzFri, 17 Aug 2012 01:14:55 GMThttp://trac.ffmpeg.org/ticket/1425#comment:2
http://trac.ffmpeg.org/ticket/1425#comment:2
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:1" title="Comment 1">saste</a>:
</p>
<blockquote class="citation">
<p>
Please note that the generated playlist file is <strong>not</strong> an M3U8 file, so you can't expect players to play it like it was.
</p>
<p>
In order to generate an M3U8 playlist file you can use a script, or check ticket <a class="closed ticket" href="http://trac.ffmpeg.org/ticket/1642" title="enhancement: -f segment: automagically generate #EXTM3U tags to -segment_list ... (closed: fixed)">#1642</a> for which a patchset has been already posted.
</p>
</blockquote>
<p>
First of all, thanks for your time.
</p>
<p>
I'd like to note that if I try to open a segment directly, not using the malformed playlist file, it also plays incorrectly.
Lets suppose you are only interested on reviewing the fifth segment and you open it with any of the players I stated above, you will have 20 seconds of nothing before the clip starts to play, best case scenario, and in Quicktime case 5 seconds of black screen and then nothing. (assuming the clips were of five seconds each).
</p>
<p>
I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.
</p>
Ticketfesago90Thu, 30 Aug 2012 22:11:24 GMTstatus changed; resolution deletedhttp://trac.ffmpeg.org/ticket/1425#comment:3
http://trac.ffmpeg.org/ticket/1425#comment:3
<ul>
<li><strong>status</strong>
changed from <em>closed</em> to <em>reopened</em>
</li>
<li><strong>resolution</strong>
<em>invalid</em> deleted
</li>
</ul>
<p>
I'm experiencing the same problem, note that the playback of all but the first segments is blank when trying to open the file directly, not through the 'playlist'.
</p>
TicketsasteSat, 01 Sep 2012 16:40:20 GMThttp://trac.ffmpeg.org/ticket/1425#comment:4
http://trac.ffmpeg.org/ticket/1425#comment:4
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:3" title="Comment 3">fesago90</a>:
</p>
<blockquote class="citation">
<p>
I'm experiencing the same problem, note that the playback of all but the first segments is blank when trying to open the file directly, not through the 'playlist'.
</p>
</blockquote>
<p>
This is expected (depending on the player), since the files won't start at 0. Anwyay I'll see if a "reset-timestamps" option can be easily added.
</p>
TicketcehoyosMon, 15 Oct 2012 11:52:38 GMTkeywords changedhttp://trac.ffmpeg.org/ticket/1425#comment:5
http://trac.ffmpeg.org/ticket/1425#comment:5
<ul>
<li><strong>keywords</strong>
<em>mov</em> added; <em>mp4</em> removed
</li>
</ul>
TicketsasteThu, 29 Nov 2012 12:48:55 GMThttp://trac.ffmpeg.org/ticket/1425#comment:6
http://trac.ffmpeg.org/ticket/1425#comment:6
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:2" title="Comment 2">knovz</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:1" title="Comment 1">saste</a>:
</p>
</blockquote>
<p>
[...]
</p>
<blockquote class="citation">
<p>
I'd like to note that if I try to open a segment directly, not using the malformed playlist file, it also plays incorrectly.
Lets suppose you are only interested on reviewing the fifth segment and you open it with any of the players I stated above, you will have 20 seconds of nothing before the clip starts to play, best case scenario, and in Quicktime case 5 seconds of black screen and then nothing. (assuming the clips were of five seconds each).
</p>
<p>
I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.
</p>
</blockquote>
<p>
Please check the attached patch, and specify the option -reset_timestamps 1.
</p>
TicketsasteThu, 29 Nov 2012 12:50:12 GMTattachment sethttp://trac.ffmpeg.org/ticket/1425
http://trac.ffmpeg.org/ticket/1425
<ul>
<li><strong>attachment</strong>
set to <em>0001-lavf-segment-add-reset_timestamps-option.patch</em>
</li>
</ul>
<p>
Patch which adds the reset_timestamps segment option
</p>
TicketknovzThu, 29 Nov 2012 17:27:48 GMThttp://trac.ffmpeg.org/ticket/1425#comment:7
http://trac.ffmpeg.org/ticket/1425#comment:7
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:6" title="Comment 6">saste</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:2" title="Comment 2">knovz</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:1" title="Comment 1">saste</a>:
</p>
</blockquote>
<p>
[...]
</p>
<blockquote class="citation">
<p>
I'd like to note that if I try to open a segment directly, not using the malformed playlist file, it also plays incorrectly.
Lets suppose you are only interested on reviewing the fifth segment and you open it with any of the players I stated above, you will have 20 seconds of nothing before the clip starts to play, best case scenario, and in Quicktime case 5 seconds of black screen and then nothing. (assuming the clips were of five seconds each).
</p>
<p>
I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.
</p>
</blockquote>
<p>
Please check the attached patch, and specify the option -reset_timestamps 1.
</p>
</blockquote>
<p>
Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.
</p>
TicketsasteSun, 09 Dec 2012 17:25:46 GMThttp://trac.ffmpeg.org/ticket/1425#comment:8
http://trac.ffmpeg.org/ticket/1425#comment:8
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:7" title="Comment 7">knovz</a>:
[...]
</p>
<blockquote class="citation">
<blockquote class="citation">
<p>
Please check the attached patch, and specify the option -reset_timestamps 1.
</p>
</blockquote>
<p>
Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.
</p>
</blockquote>
<p>
I updated the patch, now it's simpler and should avoid potential desynch problems, will push in a few days. Please confirm that this one is working as expected, thank you.
</p>
TicketsasteSun, 09 Dec 2012 17:26:23 GMTattachment sethttp://trac.ffmpeg.org/ticket/1425
http://trac.ffmpeg.org/ticket/1425
<ul>
<li><strong>attachment</strong>
set to <em>0002-lavf-segment-add-reset_timestamps-option.patch</em>
</li>
</ul>
TickethackeronMon, 10 Dec 2012 13:04:29 GMThttp://trac.ffmpeg.org/ticket/1425#comment:9
http://trac.ffmpeg.org/ticket/1425#comment:9
<p>
I'm having the same issue and it is very annoying, I will try the attached patch, thank you!
</p>
<p>
EDIT: Patch is working beautifully, thank you!
</p>
TicketsasteMon, 10 Dec 2012 23:24:34 GMTstatus, component changed; resolution sethttp://trac.ffmpeg.org/ticket/1425#comment:10
http://trac.ffmpeg.org/ticket/1425#comment:10
<ul>
<li><strong>status</strong>
changed from <em>reopened</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>component</strong>
changed from <em>FFmpeg</em> to <em>avformat</em>
</li>
</ul>
<p>
Should be fixed in:
</p>
<pre class="wiki">commit 8e9056559e11cd708c68bf8a50ab1c13395ae9b0
Author: Stefano Sabatini &lt;stefasab@gmail.com&gt;
Date: Thu Nov 29 13:45:50 2012 +0100
lavf/segment: add reset_timestamps option
The new options reset the timestamps at each new segment, so that the
generated segments will have timestamps starting close to 0.
It is meant to address trac ticket #1425.
</pre>
TicketknovzWed, 12 Dec 2012 22:16:45 GMThttp://trac.ffmpeg.org/ticket/1425#comment:11
http://trac.ffmpeg.org/ticket/1425#comment:11
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:8" title="Comment 8">saste</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="http://trac.ffmpeg.org/ticket/1425#comment:7" title="Comment 7">knovz</a>:
[...]
</p>
<blockquote class="citation">
<blockquote class="citation">
<p>
Please check the attached patch, and specify the option -reset_timestamps 1.
</p>
</blockquote>
<p>
Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.
</p>
</blockquote>
<p>
I updated the patch, now it's simpler and should avoid potential desynch problems, will push in a few days. Please confirm that this one is working as expected, thank you.
</p>
</blockquote>
<p>
Sorry for the delay. It works like a charm. Thank you!
</p>
Ticket