Skip to content

Commit

Permalink
ffmpeg_opt: Do not overwrite output if there is no input
Browse files Browse the repository at this point in the history
Fixes Ticket4254

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information
michaelni committed Mar 28, 2015
1 parent dcac15a commit 6a3833e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ffmpeg_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ static int no_file_overwrite = 0;
static int do_psnr = 0;
static int input_sync;
static int override_ffserver = 0;
static int input_stream_potentially_available = 0;

static void uninit_options(OptionsContext *o)
{
Expand Down Expand Up @@ -1008,6 +1009,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
av_dict_free(&opts[i]);
av_freep(&opts);

input_stream_potentially_available = 1;

return 0;
}

Expand Down Expand Up @@ -2104,6 +2107,12 @@ static int open_output_file(OptionsContext *o, const char *filename)
}
}

if (!(oc->oformat->flags & AVFMT_NOSTREAMS) && !input_stream_potentially_available) {
av_log(NULL, AV_LOG_ERROR,
"No input streams but output needs an input stream\n");
exit_program(1);
}

if (!(oc->oformat->flags & AVFMT_NOFILE)) {
/* test if it already exists to avoid losing precious files */
assert_file_overwrite(filename);
Expand Down Expand Up @@ -2608,6 +2617,9 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
filtergraphs[nb_filtergraphs - 1]->graph_desc = av_strdup(arg);
if (!filtergraphs[nb_filtergraphs - 1]->graph_desc)
return AVERROR(ENOMEM);

input_stream_potentially_available = 1;

return 0;
}

Expand All @@ -2622,6 +2634,9 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
return AVERROR(ENOMEM);
filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1;
filtergraphs[nb_filtergraphs - 1]->graph_desc = graph_desc;

input_stream_potentially_available = 1;

return 0;
}

Expand Down

0 comments on commit 6a3833e

Please sign in to comment.