脚本宝典收集整理的这篇文章主要介绍了Visual Studio2019集成ffmpeg之hello world,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
tITle: 音视频系列二:Visual Studio2019集成ffmPEg之hello world categories:[ffmpeg] tags:[音视频编程] date: 2021/11/25
下载地址为:https://visualstudio.microsoft.COM/zh-hans/downloads/
然后进行安装,安装时选择C/C++开发的选项进行安装,安装时选择如下:
选好就,点击下一步,等待安装就OK了。
GitHub下载地址:https://github.com/BTbN/FFmpeg-Builds/releases
下载最新的带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 #源码目录
将项目创建到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
#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 logn"); //打印日志
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.%dn", FFMPEG_VERSION, codecVer, ver_major, ver_minor, ver_micro);
System("pause"); //窗口等待
return 0;
}
运行结果:
如果在运行代码的时候,IDE提示,***声明已被否决,这时可以通过修改项目的配置方式来解决:
C/C++ ->常规-> SDL检查关掉
C/C++ ->代码生成-> 多线程调试(/MTD)
我是加班猿,我们下期见
以上是脚本宝典为你收集整理的Visual Studio2019集成ffmpeg之hello world全部内容,希望文章能够帮你解决Visual Studio2019集成ffmpeg之hello world所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。