[FFmpeg-devel] [PATCH V1] lavf/hlsenc: fix hls muxer time drifts from the actual clock time

Jun Zhao mypopydev at gmail.com
Sat Jul 13 11:03:15 EEST 2019


From: Jun Zhao <barryjzhao at tencent.com>

fix hls muxer time drifts from the actual clock time, based on
Pavel Pilar's fix.

fix: Ticket7986

Signed-off-by: Pavel Pilar <pilarpav at centrum.cz>
Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
---
 libavformat/hlsenc.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 4abc728..110d114 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -42,6 +42,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 #include "libavutil/time_internal.h"
+#include "libavutil/time.h"
 
 #include "avformat.h"
 #include "avio_internal.h"
@@ -2741,11 +2742,9 @@ static int hls_init(AVFormatContext *s)
                    "Disabling 'independent_segments' flag\n");
         }
 
-        if (hls->flags & HLS_PROGRAM_DATE_TIME) {
-            time_t now0;
-            time(&now0);
-            vs->initial_prog_date_time = now0;
-        }
+        if (hls->flags & HLS_PROGRAM_DATE_TIME)
+            vs->initial_prog_date_time = av_gettime() * 0.000001; // microseconds to seconds
+
         if (hls->format_options_str) {
             ret = av_dict_parse_string(&hls->format_options, hls->format_options_str, "=", ":", 0);
             if (ret < 0) {
-- 
1.7.1



More information about the ffmpeg-devel mailing list