From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 4/4] fftools/ffmpeg: handle decoders returning AVERROR_UNRECOVERABLE
Date: Tue, 22 Nov 2022 10:07:32 -0300
Message-ID: <20221122130732.403-4-jamrial@gmail.com> (raw)
In-Reply-To: <20221122130732.403-1-jamrial@gmail.com>
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 <jamrial@gmail.com>
---
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".
prev parent reply other threads:[~2022-11-22 13:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 13:07 [FFmpeg-devel] [PATCH 1/4] avutil/error: add a new error to signal processing got into an unrecoverable state James Almer
2022-11-22 13:07 ` [FFmpeg-devel] [PATCH 2/4] avcodec/decode: allow the decoder to signal an unrecoverable error was found James Almer
2022-11-22 13:07 ` [FFmpeg-devel] [PATCH 3/4] avutil/cuda_check: propagate AVERROR_UNRECOVERABLE when needed James Almer
2022-11-22 13:21 ` Timo Rothenpieler
2022-11-22 13:31 ` James Almer
2022-11-22 14:33 ` Soft Works
2022-11-22 14:41 ` James Almer
2022-11-22 14:55 ` Soft Works
2022-11-22 18:08 ` Soft Works
2022-11-22 14:48 ` Andreas Rheinhardt
2022-11-22 14:59 ` Soft Works
2022-11-22 15:15 ` Timo Rothenpieler
2022-11-22 16:02 ` Soft Works
2022-11-22 22:59 ` Timo Rothenpieler
2022-11-22 23:49 ` Soft Works
2022-11-22 13:07 ` James Almer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221122130732.403-4-jamrial@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git