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
130descriptions.130descriptions.
131 131
132A filter is represented by a string of the form:132A 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}]
134 134
135@var{filter_name} is the name of the filter class of which the135@var{filter_name} is the name of the filter class of which the
136described filter is an instance of, and has to be the name of one of136described filter is an instance of, and has to be the name of one of
137the filter classes registered in the program.137the filter classes registered in the program optionally followed by "@@@var{id}".
138The name of the filter class is optionally followed by a string138The name of the filter class is optionally followed by a string
139"=@var{arguments}".139"=@var{arguments}".
140 140
@@ -212,10 +212,11 @@ to the filtergraph description. · 71 unmodified lines
212Here is a BNF description of the filtergraph syntax:212Here is a BNF description of the filtergraph syntax:
213@example213@example
214@var{NAME} ::= sequence of alphanumeric characters and '_'214@var{NAME} ::= sequence of alphanumeric characters and '_'
215@var{FILTER_NAME} ::= @var{NAME}["@@"@var{NAME}]
215@var{LINKLABEL} ::= "[" @var{NAME} "]"216@var{LINKLABEL} ::= "[" @var{NAME} "]"
216@var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]217@var{LINKLABELS} ::= @var{LINKLABEL} [@var{LINKLABELS}]
217@var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)218@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}]
219@var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]220@var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
220@var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]221@var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
221@end example222@end example
@@ -17246,6 +17247,12 @@ Specify audio tempo change at second 4: · 17024 unmodified lines
17246asendcmd=c='4.0 atempo tempo 1.5',atempo17247asendcmd=c='4.0 atempo tempo 1.5',atempo
17247@end example17248@end example
17248 17249
17250@item
17251Target a specific filter instance:
17252@example
17253asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
17254@end example
17255
17249@item17256@item
17250Specify a list of drawtext and hue commands in a file.17257Specify a list of drawtext and hue commands in a file.
17251@example17258@example
libavfilter/graphparser.c+21−5
@@ -88,20 +88,36 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 87 unmodified lines
88 * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise.88 * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise.
89 * @param ctx the filtergraph context89 * @param ctx the filtergraph context
90 * @param index an index which is supposed to be unique for each filter instance added to the filtergraph90 * @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 create91 * @param name the name of the filter to create, can be filter name or filter_name\@id as instance name
92 * @param args the arguments provided to the filter during its initialization92 * @param args the arguments provided to the filter during its initialization
93 * @param log_ctx the log context to use93 * @param log_ctx the log context to use
94 * @return >= 0 in case of success, a negative AVERROR code otherwise94 * @return >= 0 in case of success, a negative AVERROR code otherwise
95 */95 */
96static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,96static 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)
98{98{
99 AVFilter *filt;99 AVFilter *filt;
100 char inst_name[30];100 char name2[30];
101 const char *inst_name = NULL, *filt_name = NULL;
101 char *tmp_args = NULL;102 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 }
103 115
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 }
105 121
106 filt = avfilter_get_by_name(filt_name);122 filt = avfilter_get_by_name(filt_name);
107 123

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