Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <libavformat/avformat.h>
- #include <libavutil/opt.h>
- #include <libavutil/dict.h>
- int main (int argc, char **argv) {
- AVFormatContext *fmt_ctx = NULL;
- AVDictionary** tags = NULL;
- AVDictionaryEntry *tag = NULL;
- int ret;
- char err_msg[1024];
- if (argc != 2) {
- printf("usage: %s <input_file>\n"
- "example program to demonstrate the use of the libavformat metadata API.\n"
- "\n", argv[0]);
- return 1;
- }
- av_register_all();
- ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL);
- if (ret != 0) {
- printf("%s", av_err2str(ret));
- return ret; // fails here
- }
- printf("Opened file.\n");
- ret = av_opt_get_dict_val(fmt_ctx, "metadata", AV_OPT_SEARCH_CHILDREN, tags);
- if (ret != 0) {
- printf("%s", av_err2str(ret));
- return ret; // fails here
- }
- printf("Copied metadata\n");
- while ((tag = av_dict_get(*tags, "", tag, AV_DICT_IGNORE_SUFFIX)))
- printf("%s=%s\n", tag->key, tag->value);
- avformat_close_input(&fmt_ctx);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement