[FFmpeg-devel] [PATCH 2/2] fftools: add -report option.

Clément Bœsch ubitux at gmail.com
Thu Dec 8 16:11:49 CET 2011


On Thu, Dec 08, 2011 at 02:45:33PM +0100, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  Changelog                    |    1 +
>  cmdutils.c                   |   85 ++++++++++++++++++++++++++++++++++++++++++
>  cmdutils.h                   |    2 +
>  cmdutils_common_opts.h       |    1 +
>  doc/avtools-common-opts.texi |   10 +++++
>  5 files changed, 99 insertions(+), 0 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 6ab3e84..b610be5 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -130,6 +130,7 @@ easier to use. The changes are:
>  - Microsoft Windows ICO demuxer
>  - life source
>  - PCM format support in OMA demuxer
> +- new option: -report
>  


Nice idea. Maybe we could detect a crash just like mplayer and request the
user to "-report" the bug.

[...]
>  }
>  
>  #define FLAGS(o) ((o)->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
> @@ -424,6 +477,38 @@ int opt_loglevel(const char *opt, const char *arg)
>      return 0;
>  }
>  
> +int opt_report(const char *opt)
> +{
> +    char filename[64];
> +    time_t now;
> +    struct tm *tm;
> +
> +    if (report_file) /* already opened */
> +        return 0;
> +    time(&now);
> +    tm = localtime(&now);

I think you should conditionally use localtime_r (see in vf_drawtext).

> +    snprintf(filename, sizeof(filename), "%s-%04d%02d%02d-%02d%02d%02d.log",
> +             program_name,
> +             tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
> +             tm->tm_hour, tm->tm_min, tm->tm_sec);
> +    report_file = fopen(filename, "w");
> +    if (!report_file) {
> +        av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
> +               filename, strerror(errno));
> +        return AVERROR(errno);
> +    }
> +    av_log_set_callback(log_callback_report);
> +    av_log(NULL, AV_LOG_INFO,
> +           "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
> +           "Report written to \"%s\"\n",
> +           program_name,
> +           tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
> +           tm->tm_hour, tm->tm_min, tm->tm_sec,
> +           filename);
> +    opt_loglevel("loglevel", "verbose");
> +    return 0;
> +}
> +
>  int opt_codec_debug(const char *opt, const char *arg)
>  {
>      av_log_set_level(AV_LOG_DEBUG);
> diff --git a/cmdutils.h b/cmdutils.h
> index 4773c3d..15f9836 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -76,6 +76,8 @@ int opt_default(const char *opt, const char *arg);
>   */
>  int opt_loglevel(const char *opt, const char *arg);
>  
> +int opt_report(const char *opt);
> +
>  int opt_codec_debug(const char *opt, const char *arg);
>  
>  /**
> diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
> index cced0bb..058f2b1 100644
> --- a/cmdutils_common_opts.h
> +++ b/cmdutils_common_opts.h
> @@ -14,3 +14,4 @@
>      { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
>      { "v", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" },
>      { "debug", HAS_ARG, {(void*)opt_codec_debug}, "set debug flags", "flags" },
> +    { "report", 0, {(void*)opt_report}, "generate a report" },
> diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
> index 59db4fe..30b30f6 100644
> --- a/doc/avtools-common-opts.texi
> +++ b/doc/avtools-common-opts.texi
> @@ -123,6 +123,16 @@ the environment variable @env{FFMPEG_FORCE_COLOR}.
>  The use of the environment variable @env{NO_COLOR} is deprecated and
>  will be dropped in a following FFmpeg version.
>  
> + at item -report
> +Dump full command line and console output to a file named
> + at code{@var{program}- at var{YYYYMMDD}- at var{HHMMSS}.log} in the current
> +directory.
> +This file can be useful for bug reports.
> +It also implies @code{-loglevel verbose}.
> +
> +Note: setting the environment variable @code{FFREPORT} to any value has the
> +same effect.
> +
>  @end table
>  

Note: we might want to update http://ffmpeg.org/bugreports.html after that.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111208/2421bea8/attachment.asc>


More information about the ffmpeg-devel mailing list