aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-02-13 12:18:27 +0100
committerAnton Khirnov <anton@khirnov.net>2024-02-21 10:27:20 +0100
commitbd3c1c194bd2252ada4cfd025b14ae091a30b3b5 (patch)
tree3470078f652456f9dcfbb5655e2e08265c68c916 /fftools/ffmpeg_filter.c
parent8f592eb35f4ba42c8516fe296d75e7589edb0359 (diff)
downloadffmpeg-bd3c1c194bd2252ada4cfd025b14ae091a30b3b5.tar.gz
fftools/ffmpeg_filter: accept a name from its upstream input
Do not construct the name manually from input file/stream indices. This is a step towards avoiding the assumption that filtergraph inputs are always fed by demuxers.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index c411b882de..0f57035104 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -889,6 +889,7 @@ void fg_free(FilterGraph **pfg)
av_buffer_unref(&ifp->hw_frames_ctx);
av_freep(&ifp->linklabel);
+ av_freep(&ifp->opts.name);
av_freep(&ifilter->name);
av_freep(&fg->inputs[j]);
}
@@ -1475,7 +1476,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
const AVPixFmtDescriptor *desc;
InputStream *ist = ifp->ist;
- InputFile *f = ist->file;
AVRational fr = ist->framerate;
AVRational sar;
AVBPrint args;
@@ -1506,8 +1506,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
ifp->color_space, ifp->color_range);
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
- snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
- f->index, ist->index);
+ snprintf(name, sizeof(name), "graph %d input from stream %s", fg->index,
+ ifp->opts.name);
if ((ret = avfilter_graph_create_filter(&ifp->filter, buffer_filt, name,
@@ -1558,8 +1558,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
return ret;
}
- snprintf(name, sizeof(name), "trim_in_%d_%d",
- f->index, ist->index);
+ snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name);
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -1580,8 +1579,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
AVFilterContext *last_filter;
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
- InputStream *ist = ifp->ist;
- InputFile *f = ist->file;
AVBPrint args;
char name[255];
int ret, pad_idx = 0;
@@ -1599,8 +1596,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
av_channel_layout_describe_bprint(&ifp->ch_layout, &args);
} else
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
- snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
- f->index, ist->index);
+ snprintf(name, sizeof(name), "graph_%d_in_%s", fg->index, ifp->opts.name);
if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt,
name, args.str, NULL,
@@ -1608,8 +1604,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
return ret;
last_filter = ifp->filter;
- snprintf(name, sizeof(name), "trim for input stream %d:%d",
- f->index, ist->index);
+ snprintf(name, sizeof(name), "trim for input stream %s", ifp->opts.name);
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
&last_filter, &pad_idx, name);
if (ret < 0)
@@ -2566,8 +2561,8 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
if (ifp->format < 0) {
av_log(NULL, AV_LOG_ERROR,
- "Cannot determine format of input stream %d:%d after EOF\n",
- ifp->ist->file->index, ifp->ist->index);
+ "Cannot determine format of input %s after EOF\n",
+ ifp->opts.name);
return AVERROR_INVALIDDATA;
}
}