FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

Windows環境搭建

FFMPEG官網:http://ffmpeg.org

4.0.2版本源碼

源碼:https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2

4.0.2編譯好的文件

下載已經編譯好的FFMPEG

網址:https://ffmpeg.zeranoe.com/builds/

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

版本選擇

32位下載地址

Shared:包含FFMPEG的dll庫文件

https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.0.2-win32-shared.zip

Static:包含了FFMPEG的官方文檔

https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-4.0.2-win32-static.zip

Dev:包含FFMPEG的lib文件/頭文件,以及example範例。

https://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-4.0.2-win32-dev.zip

我們目前主要是使用32位的版本

下面也提供了64位的版本方便大家。

64位版本下載地址

Shared:包含FFMPEG的dll庫文件

https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.0.2-win64-shared.zip

Static:包含了FFMPEG的官方文檔

https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-4.0.2-win64-static.zip

Dev:包含FFMPEG的lib文件/頭文件,以及example範例。

https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.0.2-win64-dev.zip

QT下載和安裝

QT官網:https://www.qt.io/

QT下載地址

下載版本:QT版本 5.10.1

下載地址:http://download.qt.io/official_releases/qt/5.10/5.10.1/

選擇該版本

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

QT版本

直接下載地址:http://iso.mirrors.ustc.edu.cn/qtproject/archive/qt/5.10/5.10.1/qt-opensource-windows-x86-5.10.1.exe

QT安裝

安裝安裝嚮導一步步Next(或下一步),

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

1

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

2

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

3

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

4

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

5


如果你想閱讀QT源碼,則可以勾上

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

,但比較佔用硬盤。

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

6

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

7

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

8

然後等待安裝結束。

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

9

測試QT+FFMPEG的使用

創建QT工程

  1. 剛打開QT Creator的界面
FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

  1. 新建工程
FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

  1. 選擇Non-Qt Project
FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

  1. 填寫項目名稱以及路徑,如下所示就創建了一個叫ffmpeg-version的工程。
FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

到此創建了一個基本的工程。

注意:需要使用C++時則選擇

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

引用FFMPEG庫

將ffmpeg-4.0.2-win32-dev拷貝到ffmpeg-version目錄下

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

在ffmpeg-version.pro裡面添加ffmpeg頭文件和庫文件路徑

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

即是

<code>win32 {
INCLUDEPATH += $$PWD/ffmpeg-4.0.2-win32-dev/include
LIBS += $$PWD/ffmpeg-4.0.2-win32-dev/lib/avformat.lib   \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/avcodec.lib    \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/avdevice.lib   \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/avfilter.lib   \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/avutil.lib     \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/postproc.lib   \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/swresample.lib \
        $$PWD/ffmpeg-4.0.2-win32-dev/lib/swscale.lib
}
/<code>

LIBS的多行引用一定要記得帶斜槓,否則後續的引用無效。

修改main.c文件

<code>#include 

// 包含ffmpeg頭文件
#include "libavutil/avutil.h"

int main()
{
    printf("Hello FFMPEG, av_version_info is %s\n",
           av_version_info());

    printf("avutil_configuration is \n%s\n",
           avutil_configuration());

    return 0;
}
/<code>

執行程序

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

發現顯示黑屏

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

我們需要把ffmpeg-4.0.2-win32-shared\bin的DLL文件拷貝到執行文件所在目錄

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

目前只用到avutil庫,所以只需要avutil-56.dll。

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

即是把文件拷貝到build-ffmpeg-version-Desktop_Qt_5_10_1_MinGW_32bit-Debug目錄。

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

再運行程序則打印

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

image.png

說明我們配置的環境是正確的。

對於庫文件,則在包含頭文件的時候,就知道我們會使用到哪些DLL。

庫文件 頭文件 源碼

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

到這裡,我們Windows QT+FFMPEG的開發環境就搭建完畢了。

更多音視頻免費視頻資料獲取 後臺私信【音視頻】(關注才能私信)

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

FFMPEG入門系列01-QT+FFMPEG4.0 Windows開發環境搭建

更多音視頻免費視頻資料獲取 後臺私信【音視頻】(關注才能私信)

更多音視頻免費視頻資料獲取 後臺私信【音視頻】(關注才能私信)

更多音視頻免費視頻資料獲取 後臺私信【音視頻】(關注才能私信)


分享到:


相關文章: