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:UsersSchips>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....
原文地址:https://www.cnblogs.com/schips/p/12579218.html