赞
踩
1.下载ffmpeg的dev和share包,解压
2.建立qt工程将dev中的包中的include文件夹和lib文件夹放在ffmpegsdk文件夹中放在工程目录下
3.在.pro工程配置文件中增加ffmpeg的include文件和lib文件
- TEMPLATE = app
- CONFIG += console c++11
- CONFIG -= app_bundle
- CONFIG -= qt
-
- SOURCES += \
- main.cpp
-
- INCLUDEPATH +=$$PWD/ffmpegsdk/include
-
- LIBS += $$PWD/ffmpegsdk/lib/avdevice.lib \
- $$PWD/ffmpegsdk/lib/avfilter.lib\
- $$PWD/ffmpegsdk/lib/avformat.lib\
- $$PWD/ffmpegsdk/lib/avutil.lib\
- $$PWD/ffmpegsdk/lib/avcodec.lib\
- $$PWD/ffmpegsdk/lib/postproc.lib\
- $$PWD/ffmpegsdk/lib/swresample.lib\
- $$PWD/ffmpegsdk/lib/swscale.lib
-
4.在.cpp文件中include需要使用的.h文件
extern "C"
{
#include <ffmpegsdk/include/libavcodec/avcodec.h>
#include <ffmpegsdk/include/libavformat/avformat.h>
#include <ffmpegsdk/include/libavdevice/avdevice.h>
#include <ffmpegsdk/include/libswscale/swscale.h>
}
5.在main函数中调用ffmpeg函数尝试ffmpeg是否可用
int main()
{
cout << "Hello FFmpeg!" << endl;
av_register_all();
unsigned version = avcodec_version();
cout << "version is:" << version;
return 0;
}
6.编译工程,将下载的ffmpeg_share包里的dll文件拷贝到编译生成的可执行文件的同级目录下
7.运行程序,成功
整体代码
main.cpp
- #include <iostream>
- using namespace std;
- extern "C"
- {
- #include <ffmpegsdk/include/libavcodec/avcodec.h>
- #include <ffmpegsdk/include/libavformat/avformat.h>
- #include <ffmpegsdk/include/libavdevice/avdevice.h>
- #include <ffmpegsdk/include/libswscale/swscale.h>
- }
-
- int main()
- {
- cout << "Hello FFmpeg!" << endl;
- av_register_all();
- unsigned version = avcodec_version();
- cout << "version is:" << version;
- return 0;
- }
发现大佬文章学习总结记录下~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。