Qt Creator中配置FFmpeg

本机配置:win10 64位+VS2017+Qt5.9.1,其中Qt安装过程不再赘述,安装时选上MSVC2017-64(因为我的电脑是64位的且VS版本为2017)。
可根据自己的实际环境下载相应的库。
可以在下面的链接下载FFMPEG build库文件,其中dev中包含.h头文件和lib库,shared包含dll文件。
[FFMPEG bulild Download]

有了库文件以后,最主要的就是在Qt工程的.pro文件中配置库的目录。
在这里插入图片描述
1.将bin目录添加到系统环境变量中
在这里插入图片描述
2.配置pro文件
Video_player.pro:

#-------------------------------------------------
#
# Project created by QtCreator 2019-04-10T10:26:28
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Video_player
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp \
    video_player.cpp

HEADERS += \
        mainwindow.h \
    video_player.h

FORMS += \
        mainwindow.ui

INCLUDEPATH += E:/ffmpeg4.1.1/include

LIBS += E:/ffmpeg4.1.1/lib/avcodec.lib \
        E:/ffmpeg4.1.1/lib/avdevice.lib \
        E:/ffmpeg4.1.1/lib/avfilter.lib \
        E:/ffmpeg4.1.1/lib/avformat.lib \
        E:/ffmpeg4.1.1/lib/avutil.lib \
        E:/ffmpeg4.1.1/lib/postproc.lib \
        E:/ffmpeg4.1.1/lib/swresample.lib \
        E:/ffmpeg4.1.1/lib/swscale.lib


至此Qt Creator中配置FFmpeg完成。


注意FFmpeg是C语言写的库,在Qt项目中包含头文件时要用extern C,示例如下:

//ffmpeg include
extern "C"
{
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libavutil/pixfmt.h"
    #include "libswscale/swscale.h"
    #include "libavutil/time.h"
    #include "libavutil/mathematics.h"
}
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值