[FFmpeg-user] Fixed GOP encoding for HLS

Christian Ebert blacktrash at gmx.net
Thu Dec 13 10:56:07 CET 2012


* Stefano Sabatini on Wednesday, December 12, 2012 at 11:52:40 +0100
> What I did in a similar situation:
> 
> you set -force_key_frames with the list of frames, note that it is not
> perfectly accurate because of approximations so the actual I-frames
> may be placed before or after the specified time (this because you
> can't predict the position of video frames in the stream).

According to ffprobe all I frames in a 1h 50min movie were
exactly in the right position - every ten seconds. All fragments'
video tracks have a duration of 9.96000 (fps 25). However the
m3u8 file lists durations which are always slightly longer than
10 secs - and they don't coincide not only not with keyframes,
but also not with frames (should be multiples of 0.04 with 25
fps).

Here's the output for a shorter movie:

$ for f in *.ts; do ffprobe -show_streams $f 2>/dev/null | sed -e '/=aac/,$d' | fgrep duration=; done
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=9.960000
duration=2.200000

In the m3u8 they come out as variants of
#EXTINF:10.018689,
etc.

And then #EXT-X-TARGETDURATION is obviously set to 11.

Is there a reason for this? The audio tracks' durations again
differ.

I tried setting all EXTINF to 10 and the TARGETDURATION as well
manually, and it seemed to work.

Right now I'm experimenting with forced keyframes every 9
seconds and the ffmpeg default output which then yields a
TARGETDURATION of 10 - all EXTINF slightly at 9.x while all the
video tracks have a duration of 8.96.

Here's the current long sample:
http://flowplayer.blacktrash.org/test/videotag-ios.html

-- 
\black\trash movie           _COWBOY  CANOE  COMA_
            Ein deutscher Western/A German Western

--->> http://www.blacktrash.org/underdogma/ccc.php


More information about the ffmpeg-user mailing list