yading@10
|
1 /*
|
yading@10
|
2 * Copyright (c) 2011 Reinhard Tartler
|
yading@10
|
3 *
|
yading@10
|
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
|
yading@10
|
5 * of this software and associated documentation files (the "Software"), to deal
|
yading@10
|
6 * in the Software without restriction, including without limitation the rights
|
yading@10
|
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
yading@10
|
8 * copies of the Software, and to permit persons to whom the Software is
|
yading@10
|
9 * furnished to do so, subject to the following conditions:
|
yading@10
|
10 *
|
yading@10
|
11 * The above copyright notice and this permission notice shall be included in
|
yading@10
|
12 * all copies or substantial portions of the Software.
|
yading@10
|
13 *
|
yading@10
|
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
yading@10
|
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
yading@10
|
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
yading@10
|
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
yading@10
|
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
yading@10
|
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
yading@10
|
20 * THE SOFTWARE.
|
yading@10
|
21 */
|
yading@10
|
22
|
yading@10
|
23 /**
|
yading@10
|
24 * @file
|
yading@10
|
25 * Shows how the metadata API can be used in application programs.
|
yading@10
|
26 * @example doc/examples/metadata.c
|
yading@10
|
27 */
|
yading@10
|
28
|
yading@10
|
29 #include <stdio.h>
|
yading@10
|
30
|
yading@10
|
31 #include <libavformat/avformat.h>
|
yading@10
|
32 #include <libavutil/dict.h>
|
yading@10
|
33
|
yading@10
|
34 int main (int argc, char **argv)
|
yading@10
|
35 {
|
yading@10
|
36 AVFormatContext *fmt_ctx = NULL;
|
yading@10
|
37 AVDictionaryEntry *tag = NULL;
|
yading@10
|
38 int ret;
|
yading@10
|
39
|
yading@10
|
40 if (argc != 2) {
|
yading@10
|
41 printf("usage: %s <input_file>\n"
|
yading@10
|
42 "example program to demonstrate the use of the libavformat metadata API.\n"
|
yading@10
|
43 "\n", argv[0]);
|
yading@10
|
44 return 1;
|
yading@10
|
45 }
|
yading@10
|
46
|
yading@10
|
47 av_register_all();
|
yading@10
|
48 if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
|
yading@10
|
49 return ret;
|
yading@10
|
50
|
yading@10
|
51 while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
|
yading@10
|
52 printf("%s=%s\n", tag->key, tag->value);
|
yading@10
|
53
|
yading@10
|
54 avformat_close_input(&fmt_ctx);
|
yading@10
|
55 return 0;
|
yading@10
|
56 }
|