title: 音视频系列二:Visual Studio2019集成ffmpeg之hello world
categories:[ffmpeg]
tags:[音视频编程]
date: 2021/11/25
<div align = 'right'>作者:hackett</div>
<div align = 'right'>微信公众号:加班猿</div>
一、下载安装Visual Studio
下载地址为:https://visualstudio.microsof...
而后进行装置,装置时抉择C/C++开发的选项进行装置,装置时抉择如下:
选好就,点击下一步,期待装置就OK了。
二、下载ffmpeg开发包
GitHub下载地址:https://github.com/BtbN/FFmpe...
下载最新的带share版本的,就是曾经编译好了的,不必本人再编译 ffmpeg-n4.4.1-2-gcc33e73618-win64-gpl-shared-4.4.zip
├─bin #可执行程序├─doc #参考文档├─include #头文件目录│ ├─libavcodec│ ├─libavdevice│ ├─libavfilter│ ├─libavformat│ ├─libavutil│ ├─libpostproc│ ├─libswresample│ └─libswscale├─lib #链接库文件└─presets
三、创立我的项目目录
├─bin #程序执行和调试目录├─include #头文件目录├─lib #动态链接库目录└─src #源码目录
四、关上Visual Studio 2019创立我的项目
将我的项目创立到src目录上面
文件->新建->我的项目 抉择C++空我的项目
我的项目地位抉择到src,而后创立我的项目。留神:将我的项目解决方案和我的项目放在同一目录中后面的勾要选上,不然默认会多创立一层目录
五、开发环境配置
选中我的项目右键抉择属性:
- C/C++->惯例->附件蕴含目录 【$(ProjectDir)....\include】
- 链接器->惯例->附加库目录 【$(ProjectDir)....\lib】
链接器->输出->附加依赖项
avcodec.lib
avformat.lib
avutil.lib
avdevice.lib
avfilter.lib
postproc.lib
swresample.lib
swscale.lib- 我的项目->配置管理器抉择x64
六、创立hello world程序
#include<iostream>using namespace std;extern "C" {//蕴含C头文件#include "libavutil/log.h" #include "libavcodec/avcodec.h"#include "libavfilter/avfilter.h"#include "libavformat/avformat.h" #include "libavutil/avutil.h"#include "libavutil/ffversion.h"#include "libswresample/swresample.h"#include "libswscale/swscale.h"#include "libpostproc/postprocess.h"};int main(int argc, char* argv[]) { av_log_set_level(AV_LOG_DEBUG); //设置日志级别 av_log(NULL, AV_LOG_DEBUG, "hello world log\n"); //打印日志 unsigned int codecVer = avcodec_version(); int ver_major, ver_minor, ver_micro; ver_major = (codecVer >> 16) & 0xff; ver_minor = (codecVer >> 8) & 0xff; ver_micro = (codecVer) & 0xff; printf("Current ffmpeg version is: %s ,avcodec version is: %d=%d.%d.%d\n", FFMPEG_VERSION, codecVer, ver_major, ver_minor, ver_micro); system("pause"); //窗口期待 return 0;}
运行后果:
补充:
如果在运行代码的时候,IDE提醒,*申明已被否决,这时能够通过批改我的项目的配置形式来解决:
- C/C++ ->惯例-> SDL查看关掉
- C/C++ ->代码生成-> 多线程调试(/MTD)
如果你感觉文章还不错,能够给个"三连"
我是加班猿,咱们下期见