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

Submitted by Jun Zhao on July 13, 2019, 8:03 a.m.

Details

Message ID 1563004995-10494-1-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao July 13, 2019, 8:03 a.m.
From: Jun Zhao <barryjzhao@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@centrum.cz>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/hlsenc.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

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) {