From patchwork Sat May 16 18:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 19717 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 E2123449DC2 for ; Sat, 16 May 2020 21:54:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C732A689AA2; Sat, 16 May 2020 21:54:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6865A6805E5 for ; Sat, 16 May 2020 21:54:50 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D758FE257F; Sat, 16 May 2020 20:54:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WaQGIjCRGx5o; Sat, 16 May 2020 20:54:46 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3FAF4E241A; Sat, 16 May 2020 20:54:46 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 May 2020 20:52:24 +0200 Message-Id: <20200516185224.22066-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets 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 Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/ffmpeg.texi | 2 ++ fftools/ffmpeg.c | 4 ++++ fftools/ffmpeg.h | 3 ++- fftools/ffmpeg_opt.c | 5 +++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index ed437bb16f..76fafdcf7e 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1721,6 +1721,8 @@ Stop and abort on various conditions. The following flags are available: @table @option @item empty_output No packets were passed to the muxer, the output is empty. +@item empty_output_stream +No packets were passed to the muxer in some of the output streams. @end table @item -xerror (@emph{global}) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index f697460a30..cccf12e376 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4713,6 +4713,10 @@ static int transcode(void) av_freep(&ost->enc_ctx->stats_in); } total_packets_written += ost->packets_written; + if (!ost->packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) { + av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d.\n", i); + exit_program(1); + } } if (!total_packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT)) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 38205a1a13..828cb2a4ff 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -430,7 +430,8 @@ enum forced_keyframes_const { FKF_NB }; -#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) +#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) +#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1) extern const char *const forced_keyframes_const_names[]; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 60bb437ea7..2eb4e1c973 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -262,8 +262,9 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) static int opt_abort_on(void *optctx, const char *opt, const char *arg) { static const AVOption opts[] = { - { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, - { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" }, + { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, + { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" }, + { "empty_output_stream", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM }, .unit = "flags" }, { NULL }, }; static const AVClass class = {