diff options
author | Muhammad Faiz <mfcc64@gmail.com> | 2017-05-17 13:03:28 +0700 |
---|---|---|
committer | Muhammad Faiz <mfcc64@gmail.com> | 2017-05-19 20:21:47 +0700 |
commit | 162414cefee64eff114179a45abc45aca5133ed0 (patch) | |
tree | b6feae5c236782073f74150492f6d882924d56a3 /libavfilter | |
parent | 3fb104f4476ad238e2ca768e9b80dc314e6e856d (diff) | |
download | ffmpeg-162414cefee64eff114179a45abc45aca5133ed0.tar.gz |
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=''"
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/graphparser.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 04b4272e05..1405926bfd 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -88,20 +88,36 @@ static char *parse_link_name(const char **buf, void *log_ctx) * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise. * @param ctx the filtergraph context * @param index an index which is supposed to be unique for each filter instance added to the filtergraph - * @param filt_name the name of the filter to create + * @param name the name of the filter to create, can be filter name or filter_name\@id as instance name * @param args the arguments provided to the filter during its initialization * @param log_ctx the log context to use * @return >= 0 in case of success, a negative AVERROR code otherwise */ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index, - const char *filt_name, const char *args, void *log_ctx) + const char *name, const char *args, void *log_ctx) { AVFilter *filt; - char inst_name[30]; + char name2[30]; + const char *inst_name = NULL, *filt_name = NULL; char *tmp_args = NULL; - int ret; + int ret, k; + + av_strlcpy(name2, name, sizeof(name2)); + + for (k = 0; name2[k]; k++) { + if (name2[k] == '@' && name[k+1]) { + name2[k] = 0; + inst_name = name; + filt_name = name2; + break; + } + } - snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%d", filt_name, index); + if (!inst_name) { + snprintf(name2, sizeof(name2), "Parsed_%s_%d", name, index); + inst_name = name2; + filt_name = name; + } filt = avfilter_get_by_name(filt_name); |