Day01 Qt5+ffmpeg环境搭建

一、版本选择:

  ffmpeg: ffmpeg-5.1.2-full_build-shared  ffmpeg Old Versions Downloads - VideoHelp

  Qt: 5.14.2

二、环境配置:

  ffmpeg下载下来是库的形式,也带有执行文件,配置好环境变量也可以使用

  Qt 中随便新建一个工程,打开.pro配置文件,增加下面配置,把ffmpeg库解压放在指定路径,确保路径没问题

win32: {
    FFMPEG_LIB=$$PWD/ffmpeg-5.1.2-full_build-shared
    INCLUDEPATH += $$FFMPEG_LIB/include
    LIBS+= -L$$FFMPEG_LIB/lib \
            -lavcodec   \
            -lavdevice    \
            -lavfilter    \
            -lavformat    \
            -lavutil      \
            -lpostproc    \
            -lswresample  \
            -lswscale     \
}

  包含ffmepg基本头文件:

extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavdevice/avdevice.h>
#include <libavformat/version.h>
#include <libavutil/time.h>
#include <libavutil/mathematics.h>
#include <libavutil/imgutils.h>
#include <libavutil/log.h>
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    const char* version = av_version_info();

    printf("ffmpeg close pro\n");
    printf("ffmpeg version: %s\n", version);


    return a.exec();
}

  上面配置结束,如果一切顺利运行也应该没问题,可以打印出ffmpeg版本号

posted @ 2025-04-25 19:53  笑不出花的旦旦  阅读(58)  评论(0)    收藏  举报