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=''"
Showing the changes to libavfilter/graphparser.c (1 of 2 files). Show all
Unified · Split
| @@ -88,20 +88,36 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 87 unmodified lines | ||
| 88 | 88 | * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise. |
| 89 | 89 | * @param ctx the filtergraph context |
| 90 | 90 | * @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 | |
| 92 | 92 | * @param args the arguments provided to the filter during its initialization |
| 93 | 93 | * @param log_ctx the log context to use |
| 94 | 94 | * @return >= 0 in case of success, a negative AVERROR code otherwise |
| 95 | 95 | */ |
| 96 | 96 | 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) | |
| 98 | 98 | { |
| 99 | 99 | AVFilter *filt; |
| 100 | − char inst_name[30]; | |
| 100 | + char name2[30]; | |
| 101 | + const char *inst_name = NULL, *filt_name = NULL; | |
| 101 | 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 | 122 | filt = avfilter_get_by_name(filt_name); |
| 107 | 123 | |