[FFmpeg-devel] [PATCH 2/2] hlsenc: set target duration always exact or longer than max segment duration

Jan Ekström jeebjp at gmail.com
Sat Mar 24 00:42:51 EET 2018


From: Jan Ekström <jan.ekstrom at aminocom.com>

Follows the RFC with floating point durations.
F.ex., 5.005 => 6

Signed-off-by: Jan Ekström <jan.ekstrom at aminocom.com>
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 07569dbff1..ecb581acb9 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1386,7 +1386,8 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 
     for (en = vs->segments; en; en = en->next) {
         if (target_duration <= en->duration)
-            target_duration = lrint(en->duration);
+            /* Target duration has to always be exactly or longer than any segment */
+            target_duration = ceil(en->duration);
     }
 
     vs->discontinuity_set = 0;
-- 
2.14.3



More information about the ffmpeg-devel mailing list