操作系统:macOS 15.6
首先下载 ffmpeg 4.4.6 源码
编译
./configure --prefix=/Users/mac/ffmpeg-4.4.6 --disable-static --enable-shared --enable-libfdk-aac --enable-debug=3 --enable-libx264 --enable-filter=delogo --enable-gpl --enable-nonfree --enable-libopus --enable-avresample
make -j 4
make install
新建 qt 工程
修改qt 项目的 hello_qt_ffmpeg.pro 文件
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += /Users/mac/ffmpeg-4.4.6/include
LIBS += -L/Users/mac/ffmpeg-4.4.6/lib \
-lavcodec \
-lavdevice \
-lavfilter \
-lavformat \
-lavutil \
-lpostproc \
-lswscale \
-lswresample \
-lavresample
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
修改 main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
extern "C" {
#include <libavcodec/avcodec.h>
}
int main(int argc, char *argv[])
{
// 打印版本号
qDebug() << av_version_info();
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
附 mj 老师的 ffmpeg 编译选项截图
参考了 mj 老师的额博客 www.cnblogs.com/mjios/p/144…