Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <libavformat/avformat.h>
  3. #include <libavutil/opt.h>
  4. #include <libavutil/dict.h>
  5.  
  6. int main (int argc, char **argv) {
  7.     AVFormatContext *fmt_ctx = NULL;
  8.     AVDictionary** tags = NULL;
  9.     AVDictionaryEntry *tag = NULL;
  10.     int ret;
  11.     char err_msg[1024];
  12.  
  13.     if (argc != 2) {
  14.         printf("usage: %s <input_file>\n"
  15.                "example program to demonstrate the use of the libavformat metadata API.\n"
  16.                "\n", argv[0]);
  17.         return 1;
  18.     }
  19.  
  20.     av_register_all();
  21.  
  22.     ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL);
  23.     if (ret != 0) {
  24.         printf("%s", av_err2str(ret));
  25.         return ret;  // fails here
  26.     }
  27.  
  28.     printf("Opened file.\n");
  29.    
  30.     ret = av_opt_get_dict_val(fmt_ctx, "metadata", AV_OPT_SEARCH_CHILDREN, tags);
  31.     if (ret != 0) {
  32.         printf("%s", av_err2str(ret));
  33.         return ret;  // fails here
  34.     }
  35.  
  36.     printf("Copied metadata\n");
  37.  
  38.     while ((tag = av_dict_get(*tags, "", tag, AV_DICT_IGNORE_SUFFIX)))
  39.         printf("%s=%s\n", tag->key, tag->value);
  40.  
  41.     avformat_close_input(&fmt_ctx);
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement