[FFmpeg-devel] Improved EXT-X-TARGETDURATION generation

Submitted by Artem Skoretskiy on Aug. 10, 2017, 11:09 a.m.

Details

Message ID B75E92BE-9F05-4897-99CB-57BEAB2946FB@gmail.com
State New
Headers show

Commit Message

Artem Skoretskiy Aug. 10, 2017, 11:09 a.m.
It improves EXT-X-TARGETDURATION when some chunk duration is bigger than requested -hls_time N

In the current implementation, it is ceiling the value (if float part is bigger than 0.001) but it should be rounded. Specification ​https://tools.ietf.org/html/draft-pantos-http-live-streaming-22#page-49 allows both implementation, but rounding is more precise and better matches user needs (especially having in mind that HLS segmenter could generate slightly longer than requested).

See conversation https://trac.ffmpeg.org/ticket/6533
---
 libavformat/hlsenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 74a3249b73..1c36ae4a12 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1038,8 +1038,8 @@  static int hls_window(AVFormatContext *s, int last)
         goto fail;
 
     for (en = hls->segments; en; en = en->next) {
-        if (target_duration <= en->duration)
-            target_duration = get_int_from_double(en->duration);
+        if (target_duration < en->duration)
+            target_duration = (int)round(en->duration);
     }
 
     hls->discontinuity_set = 0;