forked from FFmpeg/FFmpeg
fftools/ffmpeg_mux_init: move the check for filtering+streamcopy
To streamcopy_init(). This will allow to simplify the control flow in ost_add() by moving the ost_get_filters() call (which previously had to handle both encoding and streamcopy streams) to ost_bind_filter() (which is only called for audio/video encoding). Also, return EINVAL rather than ENOSYS, as trying to combine filtering with streamcopy is a parameter error.
This commit is contained in:
parent
e83b5b2cc8
commit
71916aa107
1 changed files with 29 additions and 23 deletions
|
@ -424,27 +424,6 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
|
||||||
#endif
|
#endif
|
||||||
opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
|
opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
|
||||||
|
|
||||||
if (!ost->enc) {
|
|
||||||
if (
|
|
||||||
#if FFMPEG_OPT_FILTER_SCRIPT
|
|
||||||
filters_script ||
|
|
||||||
#endif
|
|
||||||
filters) {
|
|
||||||
av_log(ost, AV_LOG_ERROR,
|
|
||||||
"%s '%s' was specified, but codec copy was selected. "
|
|
||||||
"Filtering and streamcopy cannot be used together.\n",
|
|
||||||
#if FFMPEG_OPT_FILTER_SCRIPT
|
|
||||||
filters ? "Filtergraph" : "Filtergraph script",
|
|
||||||
filters ? filters : filters_script
|
|
||||||
#else
|
|
||||||
"Filtergraph", filters
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
return AVERROR(ENOSYS);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ost->ist) {
|
if (!ost->ist) {
|
||||||
if (
|
if (
|
||||||
#if FFMPEG_OPT_FILTER_SCRIPT
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
|
@ -1028,7 +1007,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **encoder_opts)
|
static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
|
||||||
|
OutputStream *ost, AVDictionary **encoder_opts)
|
||||||
{
|
{
|
||||||
MuxStream *ms = ms_from_ost(ost);
|
MuxStream *ms = ms_from_ost(ost);
|
||||||
|
|
||||||
|
@ -1044,6 +1024,32 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **e
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
const char *filters = NULL;
|
||||||
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
|
const char *filters_script = NULL;
|
||||||
|
|
||||||
|
opt_match_per_stream_str(ost, &o->filter_scripts, mux->fc, ost->st, &filters_script);
|
||||||
|
#endif
|
||||||
|
opt_match_per_stream_str(ost, &o->filters, mux->fc, ost->st, &filters);
|
||||||
|
|
||||||
|
if (
|
||||||
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
|
filters_script ||
|
||||||
|
#endif
|
||||||
|
filters) {
|
||||||
|
av_log(ost, AV_LOG_ERROR,
|
||||||
|
"%s '%s' was specified, but codec copy was selected. "
|
||||||
|
"Filtering and streamcopy cannot be used together.\n",
|
||||||
|
#if FFMPEG_OPT_FILTER_SCRIPT
|
||||||
|
filters ? "Filtergraph" : "Filtergraph script",
|
||||||
|
filters ? filters : filters_script
|
||||||
|
#else
|
||||||
|
"Filtergraph", filters
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
codec_ctx = avcodec_alloc_context3(NULL);
|
codec_ctx = avcodec_alloc_context3(NULL);
|
||||||
if (!codec_ctx)
|
if (!codec_ctx)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@ -1562,7 +1568,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ost->ist && !ost->enc) {
|
if (ost->ist && !ost->enc) {
|
||||||
ret = streamcopy_init(mux, ost, &encoder_opts);
|
ret = streamcopy_init(o, mux, ost, &encoder_opts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue