From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 00F0444D98 for ; Tue, 22 Nov 2022 13:09:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9630168BA32; Tue, 22 Nov 2022 15:09:02 +0200 (EET) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3475768B8B9 for ; Tue, 22 Nov 2022 15:08:54 +0200 (EET) Received: by mail-oo1-f52.google.com with SMTP id v7-20020a4aa507000000b00496e843fdfeso2244348ook.7 for ; Tue, 22 Nov 2022 05:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=gaN34YRvDKic8PTGRptOruKnGUJ2Zg8gtSN1lX4X03U=; b=QKAS9iwWCF4eEyea1akvYaqPWDc8u2niJxAghQ4e+EYI4esrd5Le8uJuh4aVBqiBid s+smgIlytWXRfOPAsBrJVkNRUsweCvFF+6fAIsv4fZEQ0/l4U+bPp21KKaBAD+7McZfs Bl4KIVWc1IaBMvTms96D/5EogiR1XPTIsCIGY9cXLbbrinYihKHP/e0Xg9xDSvnfKmiP OAtwJEfPyHtBOGDOKRR36kA4wr3ePKVHzfQZKjdNHwh/wzUlr+QGZz7YVEsj4GSg3FO8 xEZ2qTZ5RuHjTGY040DLQiS5ScqxUVs5TbbgzMMGvLpY9ozHRODQTLR/VVSxV34mU05Y 8dGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gaN34YRvDKic8PTGRptOruKnGUJ2Zg8gtSN1lX4X03U=; b=X4dJziXIcbsgfI2taUv9S6ZH1BFm2w9qA/mYPjr3aLszrYPzntS+3wcSn10gUQaUJf wX5Bn8jaPoQfzCt1ND2sPi/3nurDP4kZOoXWDzz/zxq/1i1Ack4owKjoUy4S90kmTD3p tcvVsuwlFHglEIcZ7RF1LFf6NXMduvckC4/uuLL4M94rAUCQwCPOM6RWSDa8Y9IL4h3o xPRrFetDC1n/WJDMQhzpo6lcBDz4CTgtqDFPzZFoU2LAdehEWm4I7uWYI6VRggeW+TW1 ZS1YvcHR/XqTiIQNbHueg3CjTkI0CVluwPERRK9rL5eHOvjS+lNnzGlD1Vy3ycGfNt5O Gbwg== X-Gm-Message-State: ANoB5pm0It87tuDuKoZ2odBnuHtxUqkyvY01DQueql7/5mClevA9ZHqZ EplVvOs3Ry/YqqHXn2qqpBM/gs+e5mQ= X-Google-Smtp-Source: AA0mqf6SH90haJMIlfJznYRXimwy4BnUSHxL2wQPzuHJRU2+tEz/78IbsFlGy/h9tNraoQndGfCSmw== X-Received: by 2002:a4a:94a9:0:b0:480:8f4a:7062 with SMTP id k38-20020a4a94a9000000b004808f4a7062mr1630295ooi.57.1669122532423; Tue, 22 Nov 2022 05:08:52 -0800 (PST) Received: from localhost.localdomain ([181.85.72.69]) by smtp.gmail.com with ESMTPSA id g4-20020a056870d20400b00142fa439ee5sm1825258oac.39.2022.11.22.05.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 05:08:51 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Nov 2022 10:07:32 -0300 Message-Id: <20221122130732.403-4-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122130732.403-1-jamrial@gmail.com> References: <20221122130732.403-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] fftools/ffmpeg: handle decoders returning AVERROR_UNRECOVERABLE X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Stop feeding them packets after this error is signaled but don't abort the process unless explicitly requested. For this, introduce a new abort_on flag. Signed-off-by: James Almer --- fftools/ffmpeg.c | 9 ++++++++- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_demux.c | 1 + fftools/ffmpeg_opt.c | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index dfdfad3ce4..6793f2748f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2399,6 +2399,12 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo break; } + if (ist->fatal) + break; + + if (ret == AVERROR_UNRECOVERABLE) + ist->fatal = 1; + if (ret < 0) { if (decode_failed) { av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", @@ -2407,7 +2413,8 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded " "data for stream #%d:%d\n", ist->file_index, ist->st->index); } - if (!decode_failed || exit_on_error) + if (!decode_failed || exit_on_error || + (ret == AVERROR_UNRECOVERABLE && (abort_on_flags & ABORT_ON_FLAG_UNRECOVERABLE_DECODE_ERROR))) exit_program(1); break; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index a96ff0d723..07a47d3f0e 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -322,6 +322,7 @@ typedef struct InputStream { int file_index; AVStream *st; int discard; /* true if stream data should be discarded */ + int fatal; /* true if the decoding process for the stream is in a unrecoverable state */ int user_set_discard; int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ #define DECODING_FOR_OST 1 @@ -475,6 +476,7 @@ enum forced_keyframes_const { #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1) +#define ABORT_ON_FLAG_UNRECOVERABLE_DECODE_ERROR (1 << 2) extern const char *const forced_keyframes_const_names[]; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d2a6d39703..0188b2896e 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -586,6 +586,7 @@ static void add_input_streams(const OptionsContext *o, AVFormatContext *ic) ist->st = st; ist->file_index = nb_input_files; ist->discard = 1; + ist->fatal = 0; st->discard = AVDISCARD_ALL; ist->nb_samples = 0; ist->first_dts = AV_NOPTS_VALUE; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 61aa0be0ab..91a2f88e0a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -304,6 +304,7 @@ static int opt_abort_on(void *optctx, const char *opt, const char *arg) { "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" }, + { "unrecoverable_decode_error", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_UNRECOVERABLE_DECODE_ERROR }, .unit = "flags" }, { NULL }, }; static const AVClass class = { -- 2.38.1 _______________________________________________ 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".