From patchwork Wed Dec 27 12:27:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dr Alan Barclay X-Patchwork-Id: 6992 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp7980414jad; Wed, 27 Dec 2017 04:32:59 -0800 (PST) X-Google-Smtp-Source: ACJfBotm8dG8noFsCGY/Vpw7Knfnc25DEExXWogLeniCkRNjvwdXPGTjRLLdiAqngtMhWLur9Gbz X-Received: by 10.223.138.143 with SMTP id y15mr29420559wry.273.1514377979273; Wed, 27 Dec 2017 04:32:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514377979; cv=none; d=google.com; s=arc-20160816; b=l5e4T+1sNv1n0FTyPabf2fAAD7BAErhojcJBfbAbhjZoqvzttLoNPczhZHq8r0fA44 hY5MXEqE7HqBEkGJ9Ewyy74VdKcWbfYkcBGXkjnHv1hxnttRbnvoFqRDyzMvaTnSlWZN jZNrtNL4ZRwBiqtsdtQQ3LZskf/GjatltNKepeTlmci6UcPaJPC8waUiQUKI42VZH9YV 7FWBY9HdIdttmqbJlxRzzhuGSAxxzgi123RFmdnZt2e6gLaB8LJeN+nloBAmvnZQ4r4o 9xsMgbwWPgVomF6JE3JvWgezovdJiTs3X0y+qviQQ6aVrB8mzKBnSBGz0Ct0YXRGr35T tcpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:delivered-to :arc-authentication-results; bh=P4u7dI7ECvf+pIoGi0Sdo/afRF3pyVf4hoUJAC3Dasc=; b=tW2TPX41CGfkHPQeMtRNBKRiH+wPwr5knEwgmiqwp8vBxzlNg2bw58gRiUfAIaa5r2 KZ4pZ3ipNLrA84rgvpRj50OOSl4ipSUsbVGGycYs+sx0tngsdfl7gT+025E0Bfo9rM+A V3wq+nYX5VyYX8VoDVMR92NhoEmoFFrZmux8qGTjNYHCu23EFJ4oMMWgmPtLXFJXlmOt nA+jry/8KIW5SqKjC732OHR0ejcY5QYT4Tafxg+MhN8j2hVzkruvRl4Knhabli8dfNzz iUXYXk1tk9CW/jlp3RIgk4CHR0cQlg/J7JgEzmwL13qBQCmNhAnetx75mdy0rdTLt6Ad 3IiQ== 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 j4si13650200wrd.355.2017.12.27.04.32.57; Wed, 27 Dec 2017 04:32:59 -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 BCBF86882C2; Wed, 27 Dec 2017 14:32:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CF45680ACF for ; Wed, 27 Dec 2017 14:32:36 +0200 (EET) Received: from [10.1.1.206] ([2.100.187.49]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MM2UC-1ebruB2sou-007iWf for ; Wed, 27 Dec 2017 13:27:40 +0100 To: ffmpeg-devel@ffmpeg.org References: <20171227014111.GY4926@michaelspb> From: Dr Alan Barclay Message-ID: <9483770e-4b2f-94ef-e18e-dfe358a55420@escribe.co.uk> Date: Wed, 27 Dec 2017 12:27:38 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171227014111.GY4926@michaelspb> Content-Language: en-US X-Provags-ID: V03:K0:KbX9FcvWS2kcj0jHPBDVHJuXUiBHqdLWR28gb7dvgLhpEjnB9Kf +nZtPijTf9mlOlFn7aKcijQi2sNz9eH7qpLOXD0n88a0n/Iw23NIEV6kIghc6UzET59EcZi cEC6qRPtPx1d0TMm95ybH82sSpem0fuKTr5huzV3NKctB2oEydow6fzpWIHbVcqv9bkGB+i jdRhBF1lK0eEX72dxHScQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ppDeQQGfHB8=:kpceD3MtCyCN8U4adl2Yq1 IRMjloNQLx0DYbIvAPlAwTw/s+fgHy242y1CK7afovDO2M3Nx3bHRUSt+S0kcBtf3t+gTJuaX NXRkU7ezu4sL2Q8i5jOTHJCEAJeCPPKjiRvoQQujaxxTI1GENAHF28CpVrMV3EKCuh5nzNV/m UAZRsa4yFCjoP6kuoTDG9K3neaj7/5sw3wLaXcUrdbGdxSr38TIqPSJSTF+wRU6y4KbWNAeFf 0m1f7UpXxm3x2ed4K6RMVM4lN+w1F+eur6jcpDKIRPd7zIWt5Q/m/o8P9Tx3deWrRNZgCwm2b shBixBNGylkZNcphLg7H4DGDUTG8BT6ZzST+zhyGtCxD6i1vutBZRh4ngc5soxki/DKMbSEud hCMGSNCx8+lI77fg1dXm8FhBu5vUEnYFOHZxv+lBVHlCXmcNjQE2rdrMIfj7WOhFcssHLwfu3 Uk/HXolp/3g6VQYZkRuWMKrLDfifXMXBghLmmtz5hhk8r41FBVmm0Cqy0FX7LbWn6jLHFYUyV K483mPRtf0yamrpONWWmdWWX2gycpwqNzQcO8XoiwL0mCJ91xm4p3AMCKlTtUUwaWnv0sd03X JAaebYOqXCaI/V/o+sTh3ETE1/kZ8Aw/JjSy0QOBr0RSXBei59iBEXnt2aDR1UtlVvJ6rRdWZ Aj8gLqFgMucQD6+8zuAvesQeudITO2WtgpG6xFt7Eb4YeIODyGMrjY13AFG6N7sJZK78lbajm 6/SQqpTH4mxGQvHJFyGHHWqJsIVDjDkgzy3QZLOfYOSzceNtbyn1yP3Ce/w= Subject: Re: [FFmpeg-devel] [PATCH] Adding mkdir option for img2enc (2nd attempt) 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" Hi, Resending the two (git format-patch) patches, without the top lines removed (which I thought I needed to do as some patch emails didn't seem to have them). All comments and help appreciated. Thanks and Regards, Alan. On 27/12/17 01:41, Michael Niedermayer wrote: > On Tue, Dec 26, 2017 at 10:44:31PM +0000, Dr Alan Barclay wrote: >> Hi All, >> >> Please would someone with an interest in img2enc take a look at my revised >> patches for a minor feature addition and consider committing it to the main >> line for me. >> >> Example: >> ffmpeg -i ~/trailer.mp4 -strftime 1 -mkdir 1 %Y/%m/%d/out_%H-%M-%S.jpg >> >> Without the new mkdir option, this command will fail if the directory >> hierarchy for the jpg files does not already exist, which can be difficult >> to predict for time-stamped directories. >> >> This patch adds a mkdir option to img2enc which invites it to make whatever >> directory hierarchy is necessary for each output file. When used in >> conjunction with the strftime then the jpg files will be located in a newly >> created (time-stamped) directory as processing progresses. >> >> My typical usage scenario is capturing a long-running live video feed >> (perhaps time-lapsed) and storing the resulting images in a time-stamped >> directory hierarchy fashion, rather than as a numbered sequence of files in >> a single directory. >> >> If you look at the code you will see that only a half dozen lines of code >> were required in img2enc. The function for creating directories already >> existed in hlsenc.c but I've moved into utils.c as I presumed that was a >> more generic location for it. >> >> All comments appreciated. >> >> Thanks ad Regards, >> Alan. >> >> >> On 17/12/17 22:46, Carl Eugen Hoyos wrote: >>> 2017-12-17 23:41 GMT+01:00 Dr Alan Barclay : >>> >>>> Please would someone with an interest in img2enc take a look >>>> at my minor feature addition and consider committing it to the >>>> main line for me. >>> To be acceptable, the patch has to be split in two and please >>> move the definition into internal.h >>> >>> Carl Eugen >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> hlsenc.c | 35 +---------------------------------- >> internal.h | 7 +++++++ >> utils.c | 33 +++++++++++++++++++++++++++++++++ >> 3 files changed, 41 insertions(+), 34 deletions(-) >> 9560fd03958f79f77b01c0e02c55d98e3dc7b937 0001-Move-mkdir_p-renamed-ff_mkdir_p-from-hlsenc.c-to-uti.patch >> --- >> libavformat/hlsenc.c | 35 +---------------------------------- >> libavformat/internal.h | 7 +++++++ >> libavformat/utils.c | 33 +++++++++++++++++++++++++++++++++ >> 3 files changed, 41 insertions(+), 34 deletions(-) > these patches are missing commit messages > patches should be genrated with git format-patch or git send-email > > > [...] > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From 0f8a3b00c502bdadd4571c3966e39aa00da17fc3 Mon Sep 17 00:00:00 2001 From: "Dr. Alan Barclay" Date: Tue, 26 Dec 2017 22:37:15 +0000 Subject: [PATCH 2/2] Adding mkdir option for img2enc. --- libavformat/img2enc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index b680676bff..a8ee064396 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -42,6 +42,7 @@ typedef struct VideoMuxData { char target[4][1024]; int update; int use_strftime; + int use_mkdir; int frame_pts; const char *muxer; int use_rename; @@ -114,6 +115,12 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) img->img_number, img->path); return AVERROR(EINVAL); } + if (img->use_mkdir) { + char *temp_filename = av_strdup(filename); + const char *temp_path = av_dirname(temp_filename); + ff_mkdir_p(temp_path); + av_free(temp_filename); + } for (i = 0; i < 4; i++) { snprintf(img->tmp[i], sizeof(img->tmp[i]), "%s.tmp", filename); av_strlcpy(img->target[i], filename, sizeof(img->target[i])); @@ -212,6 +219,7 @@ static const AVOption muxoptions[] = { { "update", "continuously overwrite one file", OFFSET(update), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, ENC }, { "strftime", "use strftime for filename", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, + { "mkdir", "make sub-dirs as required", OFFSET(use_mkdir), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "frame_pts", "use current frame pts for filename", OFFSET(frame_pts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC }, { NULL }, -- 2.11.0