Windows 編譯 FFMpeg


Windows 編譯 FFMpeg

背景:

為了提高公司產品的質量,對FFMPEG進行優化,需要重新編譯。

Host    :Windows-10,core-i7

MinGW  :網絡版

pkg-config:0.23

編譯前准備

安裝下列軟件時,路徑最好不要帶有空格

安裝 MinGW

下載好MinGW以后,安裝時勾選以下選項

  • mingw-devloper-toolkit
  • mingw32-base
  • mingw32-gcc-g++
  • msys-base

安裝完成以后按住Win+R 打開cmd,輸入gcc --version 測試是否成功

C:\Users\Schips>gcc --version

gcc (x86_64-posix-seh, Built by strawberryperl.com project) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

安裝pkg-config

pkg-config是一個輔助的配置、鏈接工具,可以方便的支持gcc自動配置。

下載這兩個包:pkg-config-0.23-2.zipglib_2.18.4-1_win32.zip

把glib_2.18.4-1_win32.zip中的libglib-2.0-0.dllpkg-config.exe放某個地方,可以是下面的兩種辦法中的一種:

  • 都放在$path(例如/bin)目錄下;雖然不太合理,但可以不設置環境變量(我選擇了這一種)

  • 合理地放在對應的位置,並設置以下的環境變量:

# pkg-config.exe 所在路徑
export PKG_CONFIG=/路徑/pkg-config.exe
# pkg-config默認的庫依賴項查找目錄
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/$(libglib-2.0-0.dll)所在路徑/

編譯 FFMpeg

運行msys,進入ffmpeg源碼的目錄

# 進入FFmpeg源碼目錄
cd FFmpeg 
# 配置編譯參數
./configure --prefix=../ffmpeg_buildout --disable-static --enable-shared --enable-version3  --disable-ffplay --enable-ffmpeg --disable-x86asm
# 編譯
make -j4
make install -j4

若編譯過程中出現如下錯誤,打開libavformat/os_support.h,添加#include<winerror.h>,即可。錯誤內容:

CC      libavformat/paf.o
In file included from libavformat/os_support.h:112:0,
                 from libavformat/os_support.c:29:
libavformat/os_support.c: In function 'ff_gai_strerror':
libavformat/os_support.c:194:10: error: 'ERROR_NOT_ENOUGH_MEMORY' undeclared (first use in this function)
     case EAI_MEMORY:
          ^
libavformat/os_suppCCort.clibavformat/pcm.o:1
:10: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libavformat/os_support.o] Error 1
make: *** Waiting for unfinished jobs....


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM