Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#1425 closed defect (fixed)

Clips generated by ffmpeg using segment muxer are not correctly played on some videoplayers

Reported by: Hector Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: segment mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

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.

What happens:
During the recording there appears to be no problem, and the clips are generated without a problem.

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.

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...

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).

Gnome MPlayer plays everything as I would like it (as if those were standalone movies of 5 second length).

Totem on Ubuntu plays it ok as well.

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).

Ticket #910 (closed as invalid) might be related.

The command:

% 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

Tested with current git head N-41352-gc8a1101:

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

The output: please see attached ffmpeg log (ffmpeg-20120606-100145.log generated by -report).

Attachments (3)

ffmpeg-20120606-100145.log (31.5 KB ) - added by Hector 9 years ago.
ffmpeg log generated by -report
0001-lavf-segment-add-reset_timestamps-option.patch (6.5 KB ) - added by Stefano Sabatini 9 years ago.
Patch which adds the reset_timestamps segment option
0002-lavf-segment-add-reset_timestamps-option.patch (4.9 KB ) - added by Stefano Sabatini 9 years ago.

Download all attachments as: .zip

Change History (14)

by Hector, 9 years ago

Attachment: ffmpeg-20120606-100145.log added

ffmpeg log generated by -report

comment:1 by Stefano Sabatini, 9 years ago

Analyzed by developer: set
Resolution: invalid
Status: newclosed

Please note that the generated playlist file is not an M3U8 file, so you can't expect players to play it like it was.

In order to generate an M3U8 playlist file you can use a script, or check ticket #1642 for which a patchset has been already posted.

in reply to:  1 ; comment:2 by Hector, 9 years ago

Replying to saste:

Please note that the generated playlist file is not an M3U8 file, so you can't expect players to play it like it was.

In order to generate an M3U8 playlist file you can use a script, or check ticket #1642 for which a patchset has been already posted.

First of all, thanks for your time.

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).

I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.

comment:3 by Felipe S, 9 years ago

Resolution: invalid
Status: closedreopened

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'.

in reply to:  3 comment:4 by Stefano Sabatini, 9 years ago

Replying to fesago90:

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'.

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.

comment:5 by Carl Eugen Hoyos, 9 years ago

Keywords: mov added; mp4 removed

in reply to:  2 ; comment:6 by Stefano Sabatini, 9 years ago

Replying to knovz:

Replying to saste:

[...]

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).

I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.

Please check the attached patch, and specify the option -reset_timestamps 1.

by Stefano Sabatini, 9 years ago

Patch which adds the reset_timestamps segment option

in reply to:  6 ; comment:7 by Hector, 9 years ago

Replying to saste:

Replying to knovz:

Replying to saste:

[...]

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).

I would ask, please, that you reopen the ticket, for the list format is only affecting this issue obliquely.

Please check the attached patch, and specify the option -reset_timestamps 1.

Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.

in reply to:  7 ; comment:8 by Stefano Sabatini, 9 years ago

Replying to knovz:
[...]

Please check the attached patch, and specify the option -reset_timestamps 1.

Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.

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.

comment:9 by Roman Gaufman, 9 years ago

I'm having the same issue and it is very annoying, I will try the attached patch, thank you!

EDIT: Patch is working beautifully, thank you!

Last edited 9 years ago by Roman Gaufman (previous) (diff)

comment:10 by Stefano Sabatini, 9 years ago

Component: FFmpegavformat
Resolution: fixed
Status: reopenedclosed

Should be fixed in:

commit 8e9056559e11cd708c68bf8a50ab1c13395ae9b0
Author: Stefano Sabatini <stefasab@gmail.com>
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.

in reply to:  8 comment:11 by Hector, 9 years ago

Replying to saste:

Replying to knovz:
[...]

Please check the attached patch, and specify the option -reset_timestamps 1.

Works perfect for me (I did the same original tests, with the current git head applying the patch).
Thank you.

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.

Sorry for the delay. It works like a charm. Thank you!

Note: See TracTickets for help on using tickets.