[FFmpeg-devel] [PATCH] avformat/hlsenc: improve compute target_duration way

Steven Liu lq at chinaffmpeg.org
Sat Dec 23 01:29:56 EET 2017


just use lrint(lrint(duration * 10.0) / 10.0)
fix ticket: 6915

Suggested-by: beloko
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/dashenc.c | 2 +-
 libavformat/hlsenc.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5368a2334c..102558d17e 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
             Segment *seg = os->segments[i];
             double duration = (double) seg->duration / timescale;
             if (target_duration <= duration)
-                target_duration = lrint(duration);
+                target_duration = lrint(lrint(duration * 10.0) / 10.0);
         }
 
         ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0095ca4339..bf6f1d9253 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1235,7 +1235,7 @@ 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 = lrint(lrint(en->duration * 10.0) / 10.0);
     }
 
     vs->discontinuity_set = 0;
-- 
2.11.0 (Apple Git-81)





More information about the ffmpeg-devel mailing list