From patchwork Fri Dec 30 17:24:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bodecs Bela X-Patchwork-Id: 1994 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2940973vsb; Fri, 30 Dec 2016 09:24:44 -0800 (PST) X-Received: by 10.194.20.34 with SMTP id k2mr41570631wje.9.1483118684242; Fri, 30 Dec 2016 09:24:44 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k136si59382771wmg.111.2016.12.30.09.24.43; Fri, 30 Dec 2016 09:24:44 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A210A689D08; Fri, 30 Dec 2016 19:24:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.vivacom.hu (mail.vivacom.hu [217.173.41.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70F87680A60 for ; Fri, 30 Dec 2016 19:24:30 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by mail.vivacom.hu (Postfix) with ESMTP id 44C7281637 for ; Fri, 30 Dec 2016 18:24:33 +0100 (CET) X-Virus-Scanned: amavisd-new at example.com Received: from mail.vivacom.hu ([127.0.0.1]) by localhost (mail.vivacom.intra [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uNBW61AMMdpe for ; Fri, 30 Dec 2016 18:24:31 +0100 (CET) Received: from [192.168.3.9] (pool-dsl-2f-00fd.externet.hu [217.173.47.253]) by mail.vivacom.hu (Postfix) with ESMTPA id 6644186A1F for ; Fri, 30 Dec 2016 18:24:31 +0100 (CET) References: <20161230171111.GA26868@sunshine.barsnick.net> To: ffmpeg-devel@ffmpeg.org From: Bodecs Bela Message-ID: Date: Fri, 30 Dec 2016 18:24:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161230171111.GA26868@sunshine.barsnick.net> Subject: Re: [FFmpeg-devel] [PATCH] libavformat/hlsenc: default segment name and, use_localtime 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2016.12.30. 18:11 keltezéssel, Moritz Barsnick írta: > On Fri, Dec 30, 2016 at 15:38:25 +0100, Bodecs Bela wrote: >> is not available on all system/environment. This patch checks %s >> availabilty at runtine and alter the default format string if necessary. > You forgot to add the patch. please, forgive me. I attached it now. > > Moritz > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Bela From 00530d632427c8e9170e0aff6b807a704af60e51 Mon Sep 17 00:00:00 2001 From: Bela Bodecs Date: Fri, 30 Dec 2016 15:15:39 +0100 Subject: [PATCH] libavformat/hlsenc: default segment name and use_localtime in hlcenc.c, in the hls_write_header() function the default format string for strftime() function contains %s specifier when use_localtime is true. This %s specifier will insert the seconds since EPOCH. But %s is not available on all system/environment. This patch check %s availabilty at runtine and alter the default format string if necessary. Signed-off-by: Bela Bodecs --- libavformat/hlsenc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index c9d8e3c..76b85e8 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -829,13 +829,22 @@ fail: return err; } +static const char * get_default_pattern_localtime_fmt(void) +{ + char b[21]; + time_t t = time(NULL); + struct tm *p, tmbuf; + p = localtime_r(&t, &tmbuf); + return (strftime(b, sizeof(b), "%s", p) > 2) ? "-%s.ts" : "-%Y%m%d%H%I%S.ts"; +} + static int hls_write_header(AVFormatContext *s) { HLSContext *hls = s->priv_data; int ret, i; char *p; const char *pattern = "%d.ts"; - const char *pattern_localtime_fmt = "-%s.ts"; + const char *pattern_localtime_fmt = get_default_pattern_localtime_fmt(); const char *vtt_pattern = "%d.vtt"; AVDictionary *options = NULL; int basename_size; -- 2.5.3.windows.1