From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 59C91408A3 for ; Tue, 1 Feb 2022 13:02:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C2E068B28B; Tue, 1 Feb 2022 15:02:21 +0200 (EET) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9978368B118 for ; Tue, 1 Feb 2022 15:02:15 +0200 (EET) Received: by mail-pf1-f173.google.com with SMTP id a19so9846087pfx.4 for ; Tue, 01 Feb 2022 05:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zwell-net.20210112.gappssmtp.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:from:subject:to :content-language:content-transfer-encoding; bh=HnggxJ7MbH1kHpwhpYeH7x+NHGumncqJ7llh6jqzt6s=; b=7Yd8C+OR3I8ijPpCrWUKavLImhIzuJnrH45x/NpvrW/WWC9vbYOh6i/f+a+Yiyg3Tv lWv4Qt96xF0wTwZrToFEPW3w6QRaX0I5PWErG77BM5Rn2yKdkgkqq+yKdiAX6ygbw0S2 0b19QR5DC6ZxhFkP5ZbGiwRphW1f2lmJ9ZveqehFbdD/Uo9slC5cPm91dRjGIelxwhJJ umCNMKAEtniGz8gOa1OMNLjgYjPrxK3KgThJz4M4I9DVTUzwDO9BUilA1hvIVSTR5daG L8iPe49XGeV027NVtEQZAVrNoiwT1eTjzTALwRQdwfMdkYB4xq3d3nz9PcSg0nLydp3s BXzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :from:subject:to:content-language:content-transfer-encoding; bh=HnggxJ7MbH1kHpwhpYeH7x+NHGumncqJ7llh6jqzt6s=; b=c+UivWpZZOSitUzb3KEdUlarUHB7TIyyQfv2XbSS17aV8fRvA0pO1baIverCRnxBJ5 WeYc/jqrCtLFBLathoaeAT+wLczKbTin4huNKX84XSosQVQ3Zxvl0jISpmKcoHbQajiu NDb1z2IZOPx9iJBfMIG7Omh7nsTAJiMJoRhBS0ZHOdPLAAh96jpCojw5tf6ojtWI7TF8 Z/kdgNUKgEgFRcqhk9NZ4opbmj3f3L3i4nG39j/8CzcbC0DJhDiadH398hB83GINiRLT Ez6WSxUalEJHXrdGrq0D9Q937rEQxEn9VJd2RR9IP2aOHWBIyX2q377Q6Up4lgsknoUk lxlA== X-Gm-Message-State: AOAM532knvbfgh1MPIKBUi2ZXNshv+KsFdLCID+TGi90yeqeh8TPDV/d 5oC5xkxvhM+KQo9ZRclNbyqH0ds65rpwQREfvNU= X-Google-Smtp-Source: ABdhPJzh2pOj7i4Y30ug5REuZtBq6sSyz8RyGcI2kQsuoBWsXZ9Lb3Fvrs2gepFfXk39e9e8ecqc3A== X-Received: by 2002:a63:2b4b:: with SMTP id r72mr20446100pgr.97.1643720533095; Tue, 01 Feb 2022 05:02:13 -0800 (PST) Received: from [192.168.1.228] (061092019098.ctinets.com. [61.92.19.98]) by smtp.gmail.com with ESMTPSA id x18sm21250189pfc.123.2022.02.01.05.02.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Feb 2022 05:02:12 -0800 (PST) Message-ID: <903e60ec-f7a7-5ab9-8775-f800b76f6724@gmail.com> Date: Tue, 1 Feb 2022 21:02:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 From: Dan Zwell To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] fftools/cmdutils: add an option to append to the report file X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There are times when we want ffmpeg to log, but we don't want it to overwrite the log file. In addition to the use case described in the ticket, a third party tool that invokes ffmpeg may write additional information to the log file, such as why the encoding options were chosen. I made the error checking nonfatal for future compatibility, because this feature is aimed at scripts and ffmpeg frontends. This implements: https://trac.ffmpeg.org/ticket/3059 Note: unknown keys are ignored, so adding a new "append" key does not break backward compatibility. Signed-off-by: Dan Zwell --- doc/fftools-common-opts.texi | 3 +++ fftools/cmdutils.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index d9145704d6..a9a8eda417 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -270,6 +270,9 @@ of the program, @code{%t} is expanded to a timestamp, @code{%%} is expanded to a plain @code{%} @item level set the log verbosity level using a numerical value (see @code{-loglevel}). +@item append +@code{append=1} tells ffmpeg to append to a report file if it exists instead of +overwriting it. @code{append=0} is the default @end table For example, to output a report to a file named @file{ffreport.log} diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 4b50e15eef..08aec489cb 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -983,6 +983,7 @@ static int init_report(const char *env) time_t now; struct tm *tm; AVBPrint filename; + int append = 0; if (report_file) /* already opened */ return 0; @@ -1012,6 +1013,13 @@ static int init_report(const char *env) exit_program(1); } envlevel = 1; + } else if (!strcmp(key, "append")) { + char *tail; + append = strtol(val, &tail, 10); + if (*val == '\0' || *tail || (append != 0 && append != 1)) { + av_log(NULL, AV_LOG_ERROR, "Invalid append value '%s' (should be 0 or 1)\n", val); + append = 0; + } } else { av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); } @@ -1032,7 +1040,10 @@ static int init_report(const char *env) if (!envlevel) report_file_level = FFMAX(report_file_level, prog_loglevel); - report_file = fopen(filename.str, "w"); + if (append) + report_file = fopen(filename.str, "a"); + else + report_file = fopen(filename.str, "w"); if (!report_file) { int ret = AVERROR(errno); av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".