From patchwork Tue Jul 9 11:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Pilar X-Patchwork-Id: 13870 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 98162447B40 for ; Tue, 9 Jul 2019 14:42:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E63268AFCA; Tue, 9 Jul 2019 14:42:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from gmmr1.centrum.cz (gmmr1.centrum.cz [46.255.225.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F148A68ABD5 for ; Tue, 9 Jul 2019 14:42:46 +0300 (EEST) Received: from gm-as3.cent (unknown [10.255.254.39]) by gmmr1.centrum.cz (Postfix) with ESMTP id C5FBA803D57E for ; Tue, 9 Jul 2019 13:42:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=centrum.cz; s=mail; t=1562672565; bh=MPun/0QVrxD+DEhzbYhA16GtRWbRXjY4JJ/2gc0iiZE=; h=From:To:Cc:Subject:Date:From; b=RzLfnIg3yDJpkUdcSHTALPd+An478wGVo51ima/aQ9+CjAWAtCcirlyJjAGoDF0WD mzo8fBRcRzGEBRfxUUT8/6DnSFcPAH7bue+WKL3Ujeqw7CuC7JzWRKwmLraSYIF5J6 gfMzZd6tM+kECUzb8FGolS9Di39AU4bAkl09hUzY= Received: by gm-as3.cent (Postfix, from userid 65534) id A77DA481F38; Tue, 9 Jul 2019 13:42:45 +0200 (CEST) X-Original-From: pilarpav@centrum.cz X-Envelope-To: ffmpeg-devel@ffmpeg.org X-Original-IP: 82.113.44.250 Received: from pavel-ubuntu.ciscorv325.com (unknown [82.113.44.250]) by gm-smtp6.centrum.cz (Postfix) with ESMTPX id 365D29C000C6; Tue, 9 Jul 2019 13:42:45 +0200 (CEST) From: Pavel Pilar To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Jul 2019 13:42:36 +0200 Message-Id: <20190709114236.8607-1-pilarpav@centrum.cz> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] libavformat/hlsenc.c Accurrate time output in program_date_time (corrected) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pavel Pilar MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/hlsenc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 00c725af18..94fd713834 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2653,6 +2653,9 @@ static int hls_init(AVFormatContext *s) char *p = NULL; int vtt_basename_size = 0; int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1; +#ifdef _POSIX_TIMERS + struct timespec now_accurate; +#endif hls->has_default_key = 0; hls->has_video_m3u8 = 0; @@ -2742,14 +2745,13 @@ static int hls_init(AVFormatContext *s) } if (hls->flags & HLS_PROGRAM_DATE_TIME) { -#ifdef _POSIX_TIMERS - struct timespec now0; - clock_gettime(CLOCK_MONOTONIC, &now0); - vs->initial_prog_date_time = now0.tv_sec + now0.tv_nsec / 1e9; -#else time_t now0; time(&now0); vs->initial_prog_date_time = now0; +#ifdef _POSIX_TIMERS + if (clock_gettime(CLOCK_REALTIME, &now_accurate) == 0) { + vs->initial_prog_date_time = now_accurate.tv_sec + now_accurate.tv_nsec / 1e9; + } #endif } if (hls->format_options_str) {