[FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: Fix target duration computation when 'round_durations' is enabled

Steven Liu lingjiujianke at gmail.com
Fri Sep 1 13:46:16 EEST 2017


2017-09-01 18:40 GMT+08:00 Steven Liu <lingjiujianke at gmail.com>:
> 2017-09-01 18:32 GMT+08:00 Steven Liu <lingjiujianke at gmail.com>:
>> 2017-09-01 18:15 GMT+08:00  <kjeyapal at akamai.com>:
>>> From: Karthick J <kjeyapal at akamai.com>
>>>
>>> Signed-off-by: Karthick J <kjeyapal at akamai.com>
>>> ---
>>>  libavformat/hlsenc.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index 4a908863..dd36fde 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -1,6 +1,7 @@
>>>  /*
>>>   * Apple HTTP Live Streaming segmenter
>>>   * Copyright (c) 2012, Luca Barbato
>>> + * Copyright (c) 2017 Akamai Technologies, Inc.
>>>   *
>>>   * This file is part of FFmpeg.
>>>   *
>>> @@ -1039,7 +1040,8 @@ static int hls_window(AVFormatContext *s, int last)
>>>
>>>      for (en = hls->segments; en; en = en->next) {
>>>          if (target_duration <= en->duration)
>>> -            target_duration = get_int_from_double(en->duration);
>>> +            target_duration = (hls->flags & HLS_ROUND_DURATIONS) ?
>>> +                    lrint(en->duration) : get_int_from_double(en->duration);
>>>      }
>>>
>>>      hls->discontinuity_set = 0;
>>> --
>>> 1.9.1
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
>> LGTM
>
> Sorry, my mistake.
>
> the target_duration must large or equal to the en->duration, can not
> small than en->duration from HLS version 3.

https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.


More information about the ffmpeg-devel mailing list