多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ### **打印音视频信息** ***** ``` 1.av_register_all() 注册函数 //所有ffmpeg程序必经的一个函数 2.avformat_open_input()/avformat_close_input() 拿到格式上下文 AVFormatContext 3.av_dump_format(); ``` ### 示例代码 ***** ``` extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libswscale/swscale.h" #include "libavdevice/avdevice.h" #include "libavutil/time.h" }; #include <stddef.h> #include <stdint.h> #include <tchar.h> int main() { int ret; //返回值 调用成功与否 //定义一个上下文 AVFormatContext* fmt_ctx = NULL; av_log_set_level(AV_LOG_INFO); av_register_all(); //打开一个多媒体文件 ret = avformat_open_input(&fmt_ctx,"test.mp4", NULL, NULL); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "cant open file"); goto __fatl; } av_dump_format(fmt_ctx, 0, "./test.mp4", 0);//最后一个1代表输出 0代表输入 avformat_close_input(&fmt_ctx); __fatl: printf("open error "); system("pause"); return 0; }` ```