* commit '481a3667495425db9fdffb653292b6460fb68208':
cmdutils: allow matching by metadata in stream specifiers
Conflicts:
Changelog
cmdutils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -821,6 +821,11 @@ To map all the streams except the second audio, use negative mappings |
821 | 821 |
ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT |
822 | 822 |
@end example |
823 | 823 |
|
824 |
+To pick the English audio stream: |
|
825 |
+@example |
|
826 |
+avconv -i INPUT -map 0:m:language:eng OUTPUT |
|
827 |
+@end example |
|
828 |
+ |
|
824 | 829 |
Note that using this option disables the default mappings for this output file. |
825 | 830 |
|
826 | 831 |
@item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][:@var{output_file_id}.@var{stream_specifier}] |
... | ... |
@@ -46,6 +46,13 @@ in the program with the id @var{program_id}. Otherwise, it matches all streams i |
46 | 46 |
program. |
47 | 47 |
@item #@var{stream_id} or i:@var{stream_id} |
48 | 48 |
Match the stream by stream id (e.g. PID in MPEG-TS container). |
49 |
+@item m:@var{key}[:@var{value}] |
|
50 |
+Matches streams with the metadata tag @var{key} having the specified value. If |
|
51 |
+@var{value} is not given, matches streams that contain the given tag with any |
|
52 |
+value. |
|
53 |
+ |
|
54 |
+Note that in @command{avconv}, matching by metadata will only work properly for |
|
55 |
+input files. |
|
49 | 56 |
@end table |
50 | 57 |
|
51 | 58 |
@section Generic options |
... | ... |
@@ -4216,6 +4216,29 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, |
4216 | 4216 |
stream_id = strtol(spec, &endptr, 0); |
4217 | 4217 |
if (!*endptr) |
4218 | 4218 |
return stream_id == st->id; |
4219 |
+ } else if (*spec == 'm' && *(spec + 1) == ':') { |
|
4220 |
+ AVDictionaryEntry *tag; |
|
4221 |
+ char *key, *val; |
|
4222 |
+ int ret; |
|
4223 |
+ |
|
4224 |
+ spec += 2; |
|
4225 |
+ val = strchr(spec, ':'); |
|
4226 |
+ |
|
4227 |
+ key = val ? av_strndup(spec, val - spec) : av_strdup(spec); |
|
4228 |
+ if (!key) |
|
4229 |
+ return AVERROR(ENOMEM); |
|
4230 |
+ |
|
4231 |
+ tag = av_dict_get(st->metadata, key, NULL, 0); |
|
4232 |
+ if (tag) { |
|
4233 |
+ if (!val || !strcmp(tag->value, val + 1)) |
|
4234 |
+ ret = 1; |
|
4235 |
+ else |
|
4236 |
+ ret = 0; |
|
4237 |
+ } else |
|
4238 |
+ ret = 0; |
|
4239 |
+ |
|
4240 |
+ av_freep(&key); |
|
4241 |
+ return ret; |
|
4219 | 4242 |
} else if (!*spec) /* empty specifier, matches everything */ |
4220 | 4243 |
return 1; |
4221 | 4244 |
|