[FFmpeg-devel] [PATCH] ffmpeg: extend -benchmark_all option to show elapsed time

Stefano Sabatini stefasab at gmail.com
Wed Jan 27 13:02:54 CET 2016


On date Monday 2016-01-11 18:21:15 +0100, Stefano Sabatini encoded:
> The value is useful to get a raw estimate of the expected
> encoding/decoding time.
> 
> Also extend option documentation.
> ---
>  doc/ffmpeg.texi | 6 ++++++
>  ffmpeg.c        | 9 +++++++--
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index a38a32e..9ea48bb 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -999,6 +999,12 @@ it will usually display as 0 if not supported.
>  @item -benchmark_all (@emph{global})
>  Show benchmarking information during the encode.
>  Shows CPU time used in various steps (audio/video encode/decode).
> +
> +This option shows the following information for each processing step,
> +in this order: the user process time (in microseconds), the elapsed
> +relative time (in microseconds), the processing step type, and the
> +relative stream.
> +
>  @item -timelimit @var{duration} (@emph{global})
>  Exit after ffmpeg has been running for @var{duration} seconds.
>  @item -dump (@emph{global})
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 86a0960..24536d1 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -129,7 +129,9 @@ static int nb_frames_dup = 0;
>  static int nb_frames_drop = 0;
>  static int64_t decode_error_stat[2];
>  
> -static int current_time;
> +static int64_t current_time;
> +static int64_t current_time_rel;
> +
>  AVIOContext *progress_avio = NULL;
>  
>  static uint8_t *subtitle_out;
> @@ -608,6 +610,7 @@ static void update_benchmark(const char *fmt, ...)
>  {
>      if (do_benchmark_all) {
>          int64_t t = getutime();
> +        int64_t t_rel = av_gettime_relative();
>          va_list va;
>          char buf[1024];
>  
> @@ -615,8 +618,10 @@ static void update_benchmark(const char *fmt, ...)
>              va_start(va, fmt);
>              vsnprintf(buf, sizeof(buf), fmt, va);
>              va_end(va);
> -            av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf);
> +            av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %8"PRIu64" %s \n",
> +                   t - current_time, t_rel - current_time_rel, buf);
>          }
> +        current_time_rel = t_rel;
>          current_time = t;

Ping.
-- 
FFmpeg = Frightening and Forgiving Marvellous Political Empowered Gospel


More information about the ffmpeg-devel mailing list