[FFmpeg-user] Fixed GOP encoding for HLS

Stefano Sabatini stefasab at gmail.com
Tue Dec 18 21:05:05 CET 2012

On date Tuesday 2012-12-18 16:42:53 +1100, Andrew Sinclair wrote:
> Looking at the proposed code change the +1 isn't necessary as according the
> HLS spec the #EXT-X-TARGETDURATION only needs to be >= the segment
> timeframe so as long as it is equal to it is OK.
> I am also getting closer to the issue that I am seeing and it could be for
> support for some older players as using a decimal/float as the duration is
> only a reasonably recent addition to the spec as previously the #EXTINF
> needed to be an int. I am going to play with some patches to the code I
> have done for this and will report back.

> However there is definitely some significant variaion in what segment.c is
> generating as the #EXTINF durations and what ffprobe reports as the
> duration. Can anyone point me in the direction of how segment.c calculates
> the duration?

max_pkt_end_time - start_time

where max_pkt_end_time is the maximum of the values pts+duration for
all packets in the segment.

This can be improved, for example defining a reference stream and only
considering the packets coming from that stream when computing the

On the other hand ffprobe relies on header information and on the
assumed bitrate for computing the duration, but the only reliable way
to get a stream duration is to demux the stream and read the various

More information about the ffmpeg-user mailing list