[FFmpeg-devel] [PATCH 1/7] avformat/hlsenc: correctly compute target duration

Nicolas Martyanoff khaelin at gmail.com
Fri Jul 18 10:57:41 CEST 2014


With HLS, the duration of all segments must be lower or equal to the target
duration. Therefore floor(duration + 0.5) yields incorrect results.

For example, for duration = 1.35, floor(duration + 0.5) yields 1.0, but the
correct result is 2.0.
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 86447d8..388a23a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -141,7 +141,7 @@ static int hls_window(AVFormatContext *s, int last)
 
     for (en = hls->list; en; en = en->next) {
         if (target_duration < en->duration)
-            target_duration = (int) floor(en->duration + 0.5);
+            target_duration = ceil(en->duration);
     }
 
     avio_printf(hls->pb, "#EXTM3U\n");
-- 
1.8.5.5



More information about the ffmpeg-devel mailing list