Commit efe7a593 authored by Marton Balint's avatar Marton Balint

fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 64b12624
...@@ -1721,6 +1721,8 @@ Stop and abort on various conditions. The following flags are available: ...@@ -1721,6 +1721,8 @@ Stop and abort on various conditions. The following flags are available:
@table @option @table @option
@item empty_output @item empty_output
No packets were passed to the muxer, the output is empty. 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 @end table
@item -xerror (@emph{global}) @item -xerror (@emph{global})
......
...@@ -4713,6 +4713,10 @@ static int transcode(void) ...@@ -4713,6 +4713,10 @@ static int transcode(void)
av_freep(&ost->enc_ctx->stats_in); av_freep(&ost->enc_ctx->stats_in);
} }
total_packets_written += ost->packets_written; 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)) { if (!total_packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT)) {
......
...@@ -430,7 +430,8 @@ enum forced_keyframes_const { ...@@ -430,7 +430,8 @@ enum forced_keyframes_const {
FKF_NB 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[]; extern const char *const forced_keyframes_const_names[];
......
...@@ -262,8 +262,9 @@ static AVDictionary *strip_specifiers(AVDictionary *dict) ...@@ -262,8 +262,9 @@ static AVDictionary *strip_specifiers(AVDictionary *dict)
static int opt_abort_on(void *optctx, const char *opt, const char *arg) static int opt_abort_on(void *optctx, const char *opt, const char *arg)
{ {
static const AVOption opts[] = { static const AVOption opts[] = {
{ "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .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" , 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 }, { NULL },
}; };
static const AVClass class = { static const AVClass class = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment