Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] fftools/cmdutils: add an option to append to the report file
Date: Tue, 1 Feb 2022 09:05:45 -0300
Message-ID: <65480cd5-a842-3835-b083-d79d3c5723f1@gmail.com> (raw)
In-Reply-To: <e5fb2ac6-9a2c-834e-7acf-e617022ed3f6@gmail.com>

On 2/1/2022 8:58 AM, Dan Zwell wrote:
> 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.
> 
> 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 <devel@zwell.net>
> ---
>   doc/fftools-common-opts.texi | 3 +++
>   fftools/cmdutils.c           | 8 +++++++-
>   2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
> index d9145704d6..4c6c297315 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.

Maybe "A non zero value", since it will work with more than just 1.
Alternatively, you can check for the argument and error out on anything 
but 0 or 1.

>   @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..350329ee8b 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,8 @@ static int init_report(const char *env)
>                   exit_program(1);
>               }
>               envlevel = 1;
> +        } else if (!strcmp(key, "append")) {
> +            append = strtol(val, NULL, 10);

Don't silently ignore invalid arguments. See how level is handled above.

>           } else {
>               av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in 
> FFREPORT\n", key);
>           }
> @@ -1032,7 +1035,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",
_______________________________________________
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".

  reply	other threads:[~2022-02-01 12:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 11:58 Dan Zwell
2022-02-01 12:05 ` James Almer [this message]
2022-02-01 13:02 Dan Zwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65480cd5-a842-3835-b083-d79d3c5723f1@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git