[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 14:07:24 EEST 2017

2017-09-06 18:31 GMT+08:00 Jeyapal, Karthick <kjeyapal at akamai.com>:
>>On 9/6/17, 3:43 PM, "Steven Liu" <lingjiujianke at gmail.com<mailto:lingjiujianke at gmail.com>> wrote:
>>>2017-09-06 16:46 GMT+08:00 Jeyapal, Karthick <kjeyapal at akamai.com<mailto:kjeyapal at akamai.com>>:
>>>>On 9/6/17, 12:37 PM, "Steven Liu" <lingjiujianke at gmail.com<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel><mailto:lingjiujianke at gmail.com<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>>> wrote:
>>>>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, when duration of segment1.ts is 4.040000, EXTINF duration is 4 when HLS_ROUND_DURATIONS is set. After this patch EXT-X-TARGETDURATION will also be 4(instead of 5), which will be equal to the EXTINF duration and hence there is no violation of spec. And when another segment has duration of 4.880000 both the EXTINF and duration and EXT-X-TARGETDURATION will be 5, still in line with the HLS specification. What is reason to be safe when we know deterministically that EXTINF duration will always be lesser than or equal to EXT-X-TARGETDURATION?
>>>>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.
>>> lrint was already being used for EXTINF duration when HLS_ROUND_DURATIONS is set. And this patch kicks in only when HLS_ROUND_DURATIONS is set. It still uses the get_int_from_double API otherwise. This patch still doesn’t affect the default path when EXTINF is not rounded.
>>when 4.040000, the after ROUND  EXTINF value is lesser than segment duration.
> Thanks for the reply. Yes, that is true. But as per the HLS spec in https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#page-21 specifies “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;” for target duration. Please note that phrase “when rounded to the nearest integer” in that line. HLS specification allows you to specify target duration as maximum of segment duration “after rounding to the nearest integer”.
> Just to add a little more justification, we have been running Apple’s mediastreamvalidator in our daily regression tests with this patch, and it has never warned about the target duration. While I agree Apple’s mediastreamvalidator is not a conformance tool to check all kinds of HLS errors, but they definitely have quite a few checks in place that flags several duration related errors.

That is not perfect solution, because that just " that phrase 'when
rounded to the nearest integer' in that line", not write in the spec,
it not said the EXTINF value is "when rounded to the nearest integer",
and now it support have not problem, or can you reproduce problem when
not apply this modify?

>>> Thanks and Regards,
>>> Karthick
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org<http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

More information about the ffmpeg-devel mailing list