ubuntu 使用MingW交叉编译winffmpeg静态库

编译步骤

  • 1 构建MinGW编译环境

    下载MinGw工具(本人使用的mingw-w64-build-3.6.7)
    使用步骤
    1.chmod +x mingw-w64-build-3.6.7
    2../mingw-w64-build-3.6.7 按照提示进行填写即可
    下载地址1
    下载地址2

  • 2设置path路径

    export PATH=”$PATH:/home/×××/Desktop/ffmpeg282/mingw-w64-i686/bin”

  • 3.安装需要的依赖库(本人之需要几个)

    libx264 libfaac libopenjpeg libogg libspeex libvorbis libtheora ffmpeg

  • 4.依赖库的编译(我的库统一放到一个目录下面的/home/×××/Desktop/ffmpeg282/opensdk)

    4.1 libx264(需要编译和ffmpeg版本相符合的ffmpeg2.8.2git下载到h264以后要切换到commit为 d7ccd89f1bea53c8c524f8e6eb963d57defb6813)

    ./configure --enable-static --enable-win32thread --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --cross-prefix=i686-w64-mingw32-
    make
    make install
    

    264下载地址1

    4.2libfaac

    ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk  --enable-static --disable-shared --with-mp4v2=no
    make
    make install
    

    faac下载地址

    4.3libopenjpeg

    ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared
    

    openjpeg下载地址

    4.4libspeex

    ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared --disable-oggtest
    make
    make install
    

    libspeex下载地址

    4.5libvorbis

     ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared --disable-oggtest
    make
    make install
    

    libvorbis下载

    4.5 libtheora

     ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-sdltest --with-ogg-includes=/home/×××/Desktop/ffmpeg282/opensdk/include --with-ogg-libraries=/home/×××/Desktop/ffmpeg282/opensdk/lib
    make
    make install
    

    libtheora下载

    4.6 libogg

    ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared
    make
    make install
    

    libogg下载网址

    4.7 libmp3lame

    CFLAGS=-DFORCEINLINE= ./configure --host=i686-w64-mingw32 --prefix=/home/×××/Desktop/ffmpeg282/opensdk --enable-static --disable-shared --disable-frontend
    make
    make install
    

    libmp3lame

  • 5编译ffmpeg

    ../ffmpeg-2.8.2/configure  --enable-static --disable-shared --enable-version3 --enable-gpl --enable-nonfree --disable-pthreads --enable-w32threads --enable-runtime-cpudetect --enable-memalign-hack --enable-libfaac  --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264  --enable-zlib --enable-cross-compile --target-os=mingw32 --arch=x86 --prefix=/home/×××/Desktop/ffmpeg282/built_ffmpeg4/built_re  --cross-prefix=i686-w64-mingw32- --extra-cflags="-I/home/×××/Desktop/ffmpeg282/opensdk/include" --extra-ldflags="-L/home/×××/Desktop/ffmpeg282/opensdk/lib"
    make
    make install
    

- 注意

编译xvid时需要先编辑configure文件,然后删除里面的“-mno-cygwin”字段,否则make会失败,提示-mno-cygwin无效。libmp3lame命中中最前面的“CFLAGS=-DFORCEINLINE= ”是为了防止mp3lame中的一个编译错误,要记得带上。在编译库的时候如果有库报出函数类型不一致的错误只需把源文件中的代码修改一下即可。如果在make时报出x264.c的变量没有定义应该时x264版本不对
如果你需要更多的库就需要自己编译进去

如果在configure时报出not found using pkg-config 是因为没有找到.pc文件。只需把.pc文件目录加进去即可
export PKG_CONFIG_PATH=/home/×××/Desktop/ffmpeg282/x265_1.5/:$PKG_CONFIG_PATH

win 中编译ffmpeg静态库
ffmpeg所有版本的下载地址

参考文章

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值