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

Steven Liu lingjiujianke at gmail.com
Wed Sep 6 10:07:12 EEST 2017


2017-09-06 14:06 GMT+08:00 Jeyapal, Karthick <kjeyapal at akamai.com>:
> Hi Steven,
>
> I am restarting this discussion, just to conclude this thread one way or the other. Maybe I am not thinking correctly. Here is detailed thinking, on why I think this patch will not violate HLS spec.
>
>>        if (target_duration <= en->duration)
>>            target_duration = (hls->flags & HLS_ROUND_DURATIONS) ?
>>                    lrint(en->duration) : get_int_from_double(en->duration);
>
> As per the above code, target duration will be maximum of all lrint(en->duration) when HLS_ROUND_DURATIONS is set.
>
>>            if (hls->flags & HLS_ROUND_DURATIONS)
>>                avio_printf(out, "#EXTINF:%ld,\n",  lrint(en->duration));
>>            else
>>                avio_printf(out, "#EXTINF:%f,\n", en->duration);
>
> As per this code #EXTINF duration will be lrint(en->duration) when HLS_ROUND_DURATIONS is set.
>
>>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.
>
> As rightly pointed by you, spec says “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”. With this patch this is always true, and hence there is no violation of spec.
>
> Maybe I misunderstood and missing out something very obvious. Could you let me know the situation in which this code will generate target duration lesser than the EXTINF duration? Thanks for your help.

segment1.ts   duration = 4.880000
ROUND is 5, not 4,  is it?
if its duration = 4.040000
ROUND is 4,   the real segment1.ts duration is 4.040000,

the safe one is TARGETDURATION = 5, the get_int_from_ double API can
make the truely,

yes, your patch can make 4.880000 to 5, and make 4.040000 to 4, all
solution's TARGETDURATION is INT, but just make safe, i know the lrint
API, so that is why have not use it, not i don't know lrint.
>
> Regards,
> Karthick
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list