History

avfilter/graphparser: allow specifying filter@id as filter instance

See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html Parsed_filter_X could remain and user can override it with custom one. Example: ffplay -f lavfi "nullsrc=s=640x360, sendcmd='1 drawtext@top reinit text=Hello; 2 drawtext@bottom reinit text=World', drawtext@top=x=16:y=16:fontsize=20:fontcolor=Red:text='', drawtext@bottom=x=16:y=340:fontsize=16:fontcolor=Blue:text=''"

Muhammad Faiz committed 9 years ago

Commit 162414c1 parent 3fb104f2 files · +31 −8Browse files

Unified · Split

2 files
  1. doc/filters.texi +10 −3
  2. libavfilter/graphparser.c +21 −5
doc/filters.texi+10−3
@@ -130,11 +130,11 @@ filterchains is represented by a list of ";"-separated filterchain · 129 unmodified lines
130130 descriptions.
131131
132132 A filter is represented by a string of the form:
133−[@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
133+[@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}@@@var{id}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
134134
135135 @var{filter_name} is the name of the filter class of which the
136136 described filter is an instance of, and has to be the name of one of
137−the filter classes registered in the program.
137+the filter classes registered in the program optionally followed by "@@@var{id}".
138138 The name of the filter class is optionally followed by a string
139139 "=@var{arguments}".
140140
@@ -212,10 +212,11 @@ to the filtergraph description. · 71 unmodified lines
212212 Here is a BNF description of the filtergraph syntax:
213213 @example
214214 @var{NAME} ::= sequence of alphanumeric characters and '_'
215+@var{FILTER_NAME} ::= @var{NAME}["@@"@var{NAME}]
215216 @var{LINKLABEL} ::= "[" @var{NAME} "]"
216217 @var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
217218 @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
218−@var{FILTER} ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
219+@var{FILTER} ::= [@var{LINKLABELS}] @var{FILTER_NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
219220 @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
220221 @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
221222 @end example
@@ -17246,6 +17247,12 @@ Specify audio tempo change at second 4: · 17024 unmodified lines
1724617247 asendcmd=c='4.0 atempo tempo 1.5',atempo
1724717248 @end example
1724817249
17250+@item
17251+Target a specific filter instance:
17252+@example
17253+asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
17254+@end example
17255+
1724917256 @item
1725017257 Specify a list of drawtext and hue commands in a file.
1725117258 @example
libavfilter/graphparser.c+21−5
@@ -88,20 +88,36 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 87 unmodified lines
8888 * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise.
8989 * @param ctx the filtergraph context
9090 * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
91− * @param filt_name the name of the filter to create
91+ * @param name the name of the filter to create, can be filter name or filter_name\@id as instance name
9292 * @param args the arguments provided to the filter during its initialization
9393 * @param log_ctx the log context to use
9494 * @return >= 0 in case of success, a negative AVERROR code otherwise
9595 */
9696 static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
97− const char *filt_name, const char *args, void *log_ctx)
97+ const char *name, const char *args, void *log_ctx)
9898 {
9999 AVFilter *filt;
100− char inst_name[30];
100+ char name2[30];
101+ const char *inst_name = NULL, *filt_name = NULL;
101102 char *tmp_args = NULL;
102− int ret;
103+ int ret, k;
104+
105+ av_strlcpy(name2, name, sizeof(name2));
106+
107+ for (k = 0; name2[k]; k++) {
108+ if (name2[k] == '@' && name[k+1]) {
109+ name2[k] = 0;
110+ inst_name = name;
111+ filt_name = name2;
112+ break;
113+ }
114+ }
103115
104− snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%d", filt_name, index);
116+ if (!inst_name) {
117+ snprintf(name2, sizeof(name2), "Parsed_%s_%d", name, index);
118+ inst_name = name2;
119+ filt_name = name;
120+ }
105121
106122 filt = avfilter_get_by_name(filt_name);
107123

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t