diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-08-12 16:51:28 +0000 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-08-13 17:24:18 +0000 |
commit | 481a3667495425db9fdffb653292b6460fb68208 (patch) | |
tree | 5611cb00cce6341ee13d26710504090f3734ddd6 /cmdutils.c | |
parent | 8ddc32629a6d6be77256694c9e322dde134609f3 (diff) | |
download | ffmpeg-481a3667495425db9fdffb653292b6460fb68208.tar.gz |
cmdutils: allow matching by metadata in stream specifiers
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c index 69a11bdd4f..b208e52d68 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -1536,6 +1536,29 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) spec += 2; stream_id = strtol(spec, &endptr, 0); return stream_id == st->id; + } else if (*spec == 'm' && *(spec + 1) == ':') { + AVDictionaryEntry *tag; + char *key, *val; + int ret; + + spec += 2; + val = strchr(spec, ':'); + + key = val ? av_strndup(spec, val - spec) : av_strdup(spec); + if (!key) + return AVERROR(ENOMEM); + + tag = av_dict_get(st->metadata, key, NULL, 0); + if (tag) { + if (!val || !strcmp(tag->value, val + 1)) + ret = 1; + else + ret = 0; + } else + ret = 0; + + av_freep(&key); + return ret; } else if (!*spec) /* empty specifier, matches everything */ return 1; |