[FFmpeg-cvslog] fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets
Marton Balint
git at videolan.org
Tue May 26 23:02:02 EEST 2020
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Wed May 13 00:06:08 2020 +0200| [efe7a593649877e4fa185e01479cee3e1280ec70] | committer: Marton Balint
fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=efe7a593649877e4fa185e01479cee3e1280ec70
---
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.
+ at 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 ad95a0e417..de456df040 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 = {
More information about the ffmpeg-cvslog
mailing list