From patchwork Tue Sep 25 22:24:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 10481 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp28776jap; Tue, 25 Sep 2018 15:24:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV61V272PMvyJSdGopvmi5iUCz1lq61rIW/6kDeaixBjwyvOj6pE/VdG/fnBVTphMgOTJSMrl X-Received: by 2002:a1c:de05:: with SMTP id v5-v6mr2220266wmg.127.1537914287657; Tue, 25 Sep 2018 15:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537914287; cv=none; d=google.com; s=arc-20160816; b=JSq/TEPvkEwuzwBE6Nq5RGi3r4E2A6cl4zFR2GxTQVeRBIeqCuaGJvv+bUOjcjs+xW NYcc4h/qCJ7lOJI3d/vo363/2M6dJKKR66PFwvDoUA06zCiaJw6z98jqZ2nA/UhzLsYH rTlapx6USwdwvS+xIHAgnF68wwbADSbDqUOKAGpZS1jHAwXFJ4yG7LlBcP7HS3sBRy82 QJCx/Xkv4MusJacp8u2toAbVWZVeQfxukkR3/o5uomXIIDbVH9tSKckdV/CjtuQoyTWh drfQHf0NVBDSMm7HnvWwNs+fafRbKDOJ0yQ2w/GnYwyH253I9YOr6J+Pz+X/e+tdGKMm OBlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:to:references:message-id :date:in-reply-to:from:mime-version:delivered-to; bh=IdTRIT2T8fEAj8zh5JPTPtCVh9JXylnfp+j/FqRi7j4=; b=i1AGI5eiJzilGBp581aqKeo/gKbiaKjkfcljfhBMMqCjmzNzGobcS1JE2S0YryJYj5 tpxbxq018GMhYB8wOyJh1FDn6QODerJYt8HmCPyWZyH3VOWnl3vfT3N6Ednpy0daBbps nX2gawpUeoRCM/Z+NNOzKGw5R+C03puca3V9HIDfWBkQiK0VQm3mAzXm3hhRu5DhkuNL Eesbcv/9OlLk9wHHeUbA76JyZlxWPy3wtaiQPclH31Z+kG+zlwpJ3rfPnTV0/W9Cp6hp A3B6lfAFZR1lhx5tgVaQZFh0dbBhvoNC+hSdIsq6Z5pvFTD1ku7il34tgSKctwF/wFPo 3Q5A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z6si3394421wrw.97.2018.09.25.15.24.45; Tue, 25 Sep 2018 15:24:47 -0700 (PDT) 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 411F368A425; Wed, 26 Sep 2018 01:24:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4ABF668A3D1 for ; Wed, 26 Sep 2018 01:24:20 +0300 (EEST) X-QQ-mid: bizesmtp7t1537914270tsp9368ax Received: from [10.10.5.3] (unknown [123.115.198.184]) by esmtp4.qq.com (ESMTP) with id ; Wed, 26 Sep 2018 06:24:29 +0800 (CST) X-QQ-SSF: 00100000002000F0FMF0B00A0000000 X-QQ-FEAT: tL/Ys13R06lw9MBFDJ0cZ5Cu/oPsKWlBHeRDoCrRXs8CSN+4Mo0TQK9iw5iWT /wScQOnqaYw+og5oE1g1zXuVI0Ip4IUYtgiWULRLSJOWIhohYuEJUrHcIAWbpKHNSYuraJ6 9PQpApgIkirtfWs2XAfZraaNyvf7yt2kESjZiKMx4u1I+Q/ABluqu9j9/CEoGOnDg0Ib2Ya EVRyrU6CtN6R3C3wFMQscEZqH4DV6Mw7dA+ivNlC8UW3GxtWRomx6MOCwJB7lDsp51DQwn2 LIZAp2dRjJBpWCbTi68ytyukvQbnHOvVtNQjy7rmraMAUS X-QQ-GoodBg: 0 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) From: Steven Liu In-Reply-To: Date: Wed, 26 Sep 2018 06:24:25 +0800 Message-Id: <183EFA33-3FB5-4D82-9F2B-9EF806874795@chinaffmpeg.org> References: <20180922162656.GB3200@michaelspb> <20180924124833.GI20958@sunshine.barsnick.net> <20180925092228.GB5851@sunshine.barsnick.net> <725C767D-31BF-4225-A2BF-3A151F2B0993@chinaffmpeg.org> <3A356D75-7489-4FCE-9573-FBC6B0064905@chinaffmpeg.org> To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3445.9.1) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: Re: [FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories 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: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" > On Sep 26, 2018, at 00:52, James Courtier-Dutton wrote: > >> >> Automatically create sub-directories if needed based on date. >> E.g. >> ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10 >> "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv" >> >> >> >> >> Maybe you want add an option named “strftime_mkdir” not >> “use_localtime_mkdir”. >> You should add the option describe into doc/muxer.texi >> >> reference to: https://trac.ffmpeg.org/ticket/7393 >> >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> Thanks >> Steven >> >> Hi Steven, > > I don't understand what you are suggesting? Signed-off-by: James Courtier-Dutton --- libavformat/segment.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) + } + av_free(fn_copy); } else if (av_get_frame_filename(buf, sizeof(buf), s->url, seg->segment_idx) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url); diff --git a/libavformat/segment.c b/libavformat/segment.c index 7fb4dc7..57fce8d 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -200,12 +200,27 @@ static int set_segment_filename(AVFormatContext *s) if (seg->use_strftime) { time_t now0; struct tm *tm, tmpbuf; + const char *dir; + char *fn_copy; time(&now0); tm = localtime_r(&now0, &tmpbuf); if (!strftime(buf, sizeof(buf), s->url, tm)) { av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } + /* Automatically create directories if needed */ + /* E.g. %Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv */ + fn_copy = av_strdup(buf); + if (!fn_copy) { + return AVERROR(ENOMEM); + } + dir = av_dirname(fn_copy); + if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { + av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); ==========look at here, what dose this error message mean? + av_free(fn_copy); + return AVERROR(errno);