@@ -755,10 +755,11 @@ int find_codec(void *logctx, const char *name,
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
int filtergraph_is_simple(const FilterGraph *fg);
-int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
- char *graph_desc,
- Scheduler *sch, unsigned sch_idx_enc,
- const OutputFilterOptions *opts);
+int fg_create_simple(FilterGraph **pfg,
+ InputStream *ist,
+ char *graph_desc,
+ Scheduler *sch, unsigned sched_idx_enc,
+ const OutputFilterOptions *opts);
int fg_finalise_bindings(void);
/**
@@ -1180,25 +1180,27 @@ fail:
return 0;
}
-int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
- char *graph_desc,
- Scheduler *sch, unsigned sched_idx_enc,
- const OutputFilterOptions *opts)
+int fg_create_simple(FilterGraph **pfg,
+ InputStream *ist,
+ char *graph_desc,
+ Scheduler *sch, unsigned sched_idx_enc,
+ const OutputFilterOptions *opts)
{
+ const enum AVMediaType type = ist->par->codec_type;
FilterGraph *fg;
FilterGraphPriv *fgp;
int ret;
- ret = fg_create(&ost->fg_simple, graph_desc, sch);
+ ret = fg_create(pfg, graph_desc, sch);
if (ret < 0)
return ret;
- fg = ost->fg_simple;
+ fg = *pfg;
fgp = fgp_from_fg(fg);
fgp->is_simple = 1;
snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf%s",
- av_get_media_type_string(ost->type)[0], opts->name);
+ av_get_media_type_string(type)[0], opts->name);
if (fg->nb_inputs != 1 || fg->nb_outputs != 1) {
av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
@@ -1208,16 +1210,14 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
graph_desc, fg->nb_inputs, fg->nb_outputs);
return AVERROR(EINVAL);
}
- if (fg->outputs[0]->type != ost->type) {
+ if (fg->outputs[0]->type != type) {
av_log(fg, AV_LOG_ERROR, "Filtergraph has a %s output, cannot connect "
"it to %s output stream\n",
av_get_media_type_string(fg->outputs[0]->type),
- av_get_media_type_string(ost->type));
+ av_get_media_type_string(type));
return AVERROR(EINVAL);
}
- ost->filter = fg->outputs[0];
-
ret = ifilter_bind_ist(fg->inputs[0], ist, opts->vs);
if (ret < 0)
return ret;
@@ -1010,8 +1010,11 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
ost->filter = ofilter;
ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts);
} else {
- ret = init_simple_filtergraph(ost->ist, ost, filters,
- mux->sch, ms->sch_idx_enc, &opts);
+ ret = fg_create_simple(&ost->fg_simple, ost->ist, filters,
+ mux->sch, ms->sch_idx_enc, &opts);
+ if (ret >= 0)
+ ost->filter = ost->fg_simple->outputs[0];
+
}
av_freep(&opts.nb_threads);
if (ret < 0)