3、测试
       在ffmpeg-3.4.2-win64-dev\examples目录下复制metagata.c源码到新建的tutorial02.cpp文件中,这是一个独立的demo,作用是打印音视频媒体文件基本信息。
       注意!!!有些人下载的metadata.c里面的头文件如下左图所示,需要修改为右图所示
      (why? C++工程直接调用ffmpeg的c函数库会导致c函数无法解析,用extern "C"进行声明即可)
 
 
      测试代码(metadata.c):
#ifndef INT64_C
#define INT64_C (c)  (c ## LL)
#define UINT64_C (c) (c ## ULL)
#endif
 
#include <stdio.h>
#include "stdafx.h"
#include <stdlib.h>
//#include <libavformat/avformat.h>
//#include <libavutil/dict.h>
 
extern "C"
{
#include <libavformat/avformat.h>
#include <libavutil/dict.h>
}
 
#pragma comment (lib, "avformat.lib")
#pragma comment (lib, "avutil.lib")
 
int main(int argc, char ** argv)
{
                 AVFormatContext *fmt_ctx = NULL ;
                 AVDictionaryEntry *tag = NULL ;
                 int ret;
 
                 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();
                 if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL )))
                                 return ret;
 
                 while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
                                printf( "%s=%s\n", tag->key, tag->value);
 
                avformat_close_input(&fmt_ctx);
                 return 0;
}
       运行结果:
        
4、出现的错误
4.1  编译出现---error LNK2019: 无法解析的外部符号                                                                                                                                                                                            
 
    解决方法:
         1) ffmpeg的环境已经配置好(第2部分)
         2)配置管理器--平台由Win32修改为x64(原因未知)参考 https://blog.csdn.net/ljh0302/article/details/50011587
4.2  运行程序,弹如下错误
     解决方法:将文件夹内的dll文件拷贝到工程——工程文件夹内
4.3
错误 4 error C4996: ‘av_register_all‘: 被声明为已否决 

 
解决办法:禁用SDL      右击工程-属性-c/c++-SDL检查
