一、环境介绍
操作系统: win7 64位 家庭版
QT版本: 4.8.5 (qt-win-opensource-4.8.5-vs2010.exe)
VS版本: 2010
FFMPEG版本: 4.2.2
二、QtCreate工程
2.1 FFMPEG库下载
ffmpeg4.2.2库下载地址: https://download.csdn.net/download/xiaolong1126626497/13328939
2.2 pro工程文件
代码语言:javascript复制#-------------------------------------------------
#
# Project created by QtCreator 2021-01-09T15:25:40
#
#-------------------------------------------------
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT = widgets
TARGET = test1
TEMPLATE = app
QT = multimedia # qaxserver qaxcontainer
#CONFIG = debug qaxserver dll qaxcontainer warn_off
DEFINES = QT_DLL QAXSERVER
INCLUDEPATH = ./ffmpeg/include
LIBS = -lQAxServerd
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/avcodec
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/avformat
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/avfilter
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/avutil
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/swresample
-l$$PWD/FFMPEG_WIN32_LIB_4.2.2/lib/swscale
SOURCES = main.cpp
mainwindow.cpp
HEADERS = mainwindow.h
FORMS = mainwindow.ui
2.3 引用头文件和库文件
代码语言:javascript复制#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qdebug.h>
extern "C"{
#include <libavutil/opt.h>
#include <libavutil/mem.h>
#include <libavutil/fifo.h>
#include <libavutil/pixfmt.h>
#include <libavutil/log.h>
#include <libavutil/opt.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
#include <libavfilter/avfilter.h>
#include <libavfilter/buffersrc.h>
#include <libavfilter/buffersink.h>
}
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "swresample.lib")
#pragma comment(lib, "avfilter.lib")
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug()<<"FFMPEG:"<<av_version_info();
}
MainWindow::~MainWindow()
{
delete ui;
}