From patchwork Mon Dec 21 09:21:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 24607 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 23C714492C0 for ; Mon, 21 Dec 2020 11:21:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F0A268AD39; Mon, 21 Dec 2020 11:21:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 99B8968ACF7 for ; Mon, 21 Dec 2020 11:21:43 +0200 (EET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Czv9f4Sk9zQlWV for ; Mon, 21 Dec 2020 10:21:42 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id nERV90ucCjWN for ; Mon, 21 Dec 2020 10:21:38 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Dec 2020 14:51:20 +0530 Message-Id: <20201221092122.1658-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.16 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8D0CF1844 X-Rspamd-UID: 5d6cf9 Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: add option stats_period 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" At present, progress stats are updated at a hardcoded interval of half a second. For long processes, this can lead to bloated logs and progress reports. Users can now set a custom period using option -stats_period Default is kept at 0.5 seconds. --- doc/ffmpeg.texi | 7 ++++++- fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 1 + fftools/ffmpeg_opt.c | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 95d6463685..62015d7565 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -675,14 +675,19 @@ Specify the preset for matching stream(s). Print encoding progress/statistics. It is on by default, to explicitly disable it you need to specify @code{-nostats}. +@item -stats_period @var{time} (@emph{global}) +Set period at which encoding progress/statistics are updated. Default is 0.5 seconds. + @item -progress @var{url} (@emph{global}) Send program-friendly progress information to @var{url}. -Progress information is written approximately every second and at the end of +Progress information is written periodically and at the end of the encoding process. It is made of "@var{key}=@var{value}" lines. @var{key} consists of only alphanumeric characters. The last key of a sequence of progress information is always "progress". +The update period is set using @code{-stats_period}. + @anchor{stdin option} @item -stdin Enable interaction on standard input. On by default unless standard input is diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b446d9b206..6d25f1bca9 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1699,7 +1699,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti last_time = cur_time; return; } - if ((cur_time - last_time) < 500000) + if ((cur_time - last_time) < stats_period) return; last_time = cur_time; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 3b54dab7fc..8046e75026 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -614,6 +614,7 @@ extern int debug_ts; extern int exit_on_error; extern int abort_on_flags; extern int print_stats; +extern int64_t stats_period; extern int qp_hist; extern int stdin_interaction; extern int frame_bits_per_raw_sample; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 7ee034c9c9..242468fc64 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -174,6 +174,7 @@ int filter_nbthreads = 0; int filter_complex_nbthreads = 0; int vstats_version = 2; int auto_conversion_filters = 1; +int64_t stats_period = 500000; static int intra_only = 0; @@ -282,6 +283,21 @@ static int opt_abort_on(void *optctx, const char *opt, const char *arg) return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags); } +static int opt_stats_period(void *optctx, const char *opt, const char *arg) +{ + int64_t user_stats_period = parse_time_or_die(opt, arg, 1); + + if (user_stats_period <= 0) { + av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg); + return AVERROR(EINVAL); + } + + stats_period = user_stats_period; + av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg); + + return 0; +} + static int opt_sameq(void *optctx, const char *opt, const char *arg) { av_log(NULL, AV_LOG_ERROR, "Option '%s' was removed. " @@ -3557,6 +3573,8 @@ const OptionDef options[] = { "enable automatic conversion filters globally" }, { "stats", OPT_BOOL, { &print_stats }, "print progress report during encoding", }, + { "stats_period", HAS_ARG | OPT_EXPERT, { .func_arg = opt_stats_period }, + "set the period at which ffmpeg updates stats and -progress output", "time" }, { "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_attach }, "add an attachment to the output file", "filename" }, From patchwork Mon Dec 21 09:21:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 24606 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D87964492C0 for ; Mon, 21 Dec 2020 11:21:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AFE4F68ACFE; Mon, 21 Dec 2020 11:21:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9674C68ABB4 for ; Mon, 21 Dec 2020 11:21:43 +0200 (EET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Czv9f3jRDzQlWr for ; Mon, 21 Dec 2020 10:21:42 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id e0oIGfPFZ91g for ; Mon, 21 Dec 2020 10:21:39 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Dec 2020 14:51:21 +0530 Message-Id: <20201221092122.1658-2-ffmpeg@gyani.pro> In-Reply-To: <20201221092122.1658-1-ffmpeg@gyani.pro> References: <20201221092122.1658-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.18 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8CFFC1843 X-Rspamd-UID: 63a17f Subject: [FFmpeg-devel] [PATCH 2/2] ffmpeg: don't delay printing initial stats 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" The first stats is printed after the initial stats_period has elapsed. With a large period, it may appear that ffmpeg has frozen at startup. The initial stats is now printed after the first transcode_step. --- fftools/ffmpeg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6d25f1bca9..2c0820aacf 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1685,6 +1685,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti double speed; int64_t pts = INT64_MIN + 1; static int64_t last_time = -1; + static int first_report = 1; static int qp_histogram[52]; int hours, mins, secs, us; const char *hours_sign; @@ -1697,9 +1698,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (!is_last_report) { if (last_time == -1) { last_time = cur_time; - return; } - if ((cur_time - last_time) < stats_period) + if ((cur_time - last_time) < stats_period && !first_report) return; last_time = cur_time; } @@ -1876,6 +1876,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti } } + first_report = 0; + if (is_last_report) print_final_stats(total_size); }