1.ffmpeg编译
1.1 编译准备
windows下
方法一:
- minGW
下载地址
配置到系统的环境变量中 - msys
下载地址
可能下载比较慢 - ffmpeg源码
git clone https://github.com/FFmpeg/FFmpeg.git
https://www.ffmpeg.org/releases/
方法二:
安装msys2
linux下
- 源码同上
- 暂无
1.2 编译ffmpeg
WINDOWS
-
进入mysy安装文件夹
-
运行
mysy.bat
-
切换到ffmpeg目录
./configure --enable-shared --enable-static --disable-x86asm --enable-pic --enable-gpl --prefix=/D/github/ffmpeg4.4
make -j8
make install
注意如果make出现错误"ffbuild/common.mak:181: *** missing separator. Stop."
需要重新更新ffmpeg源码
git config --global core.autocrlf false
git rm --cached -r .
git reset --hard
官方配置参数./Configuration \ --enable-gpl \ --enable-version3 \ --enable-sdl2 \ --enable-fontconfig \ --enable-gnutls \ --enable-iconv \ --enable-libass \ --enable-libbluray \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopencore-amrnb \ --enable-libopencore-amrwb \ --enable-libopenjpeg \ --enable-libopus \ --enable-libshine \ --enable-libsnappy \ --enable-libsoxr \ --enable-libtheora \ --enable-libtwolame \ --enable-libvpx \ --enable-libwavpack \ --enable-libwebp \ --enable-libx264 \ --enable-libx265 \ --enable-libxml2 \ --enable-libzimg \ --enable-lzma \ --enable-zlib \ --enable-gmp \ --enable-libvidstab \ --enable-libvorbis \ --enable-libvo-amrwbenc \ --enable-libmysofa \ --enable-libspeex \ --enable-libxvid \ --enable-libaom \ --enable-appkit \ --enable-avfoundation \ --enable-coreimage \ --enable-audiotoolbox \ Libraries: SDL 2.0.9 <https://libsdl.org> Fontconfig 2.13.0 <http://freedesktop.org/wiki/Software/fontconfig> GnuTLS 3.6.8 <https://gnutls.org/> libiconv 1.15 <http://gnu.org/software/libiconv> libass 0.14.0 <https://github.com/libass/libass> libbluray 20180913-2d18c70 <https://www.videolan.org/developers/libbluray.html> FreeType 2.10.1 <http://freetype.sourceforge.net> LAME 3.100 <http://lame.sourceforge.net> OpenCORE AMR 20170731-07a5be4 <https://sourceforge.net/projects/opencore-amr> OpenJPEG 20190615-8db9d25 <https://github.com/uclouvain/openjpeg> Opus 20190604-ad8fe90 <https://opus-codec.org> shine 3.1.1 <https://github.com/savonet/shine> Snappy 1.1.7 <https://github.com/google/snappy> libsoxr 20180224-945b592 <http://sourceforge.net/projects/soxr> Theora 20171023-e5d205b <http://theora.org> TwoLAME 0.3.13 <http://twolame.org> vpx 20190715-d749bc7 <http://webmproject.org> WavPack 5.1.0 <http://wavpack.com> WebP 1.0.3 <https://developers.google.com/speed/webp> x264 20190314-5493be8 <https://www.videolan.org/developers/x264.html> x265 20190708-147fb92 <https://bitbucket.org/multicoreware/x265/wiki/Home> libxml2 2.9.8 <http://xmlsoft.org> z.lib 20190712-e655cd4 <https://github.com/sekrit-twc/zimg> XZ Utils 5.2.4 <http://tukaani.org/xz> zlib 1.2.11 <http://zlib.net> vid.stab 20190213-aeabc8d <http://public.hronopik.de/vid.stab> Vorbis 20180705-46e70fa <http://vorbis.com> VisualOn AMR-WB 20141107-3b3fcd0 <https://sourceforge.net/projects/opencore-amr> libmysofa 20181220-50ee637 <https://github.com/hoene/libmysofa> Speex 20181021-6e04bfa <http://speex.org> Xvid 1.3.5 <https://labs.xvid.com> aom 20190716-c41e3e1 <https://aomedia.googlesource.com/aom>
LINUX
-
编辑编译脚本
#!/bin/bash ./configure \ --disable-programs \ --enable-cross-compile \ --arch=aarch64 \ --target-os=linux \ --cc=aarch64-linux-gnu-gcc \ --strip=aarch64-linux-gnu-strip \ --enable-shared \ --prefix=/home/thz/ffmpeg_install make -j4 make install make clean
-
以上编译会导致
avcodec_find_decoder_by_name("libx264")报错
,返回值为0x00
,原因是缺少libx264.so
库,需要重新编译
1. 下载x264源码 –git clone https://code.videolan.org/videolan/x264.git
2. 编译(交叉编译)--./configure --prefix=/home/*/x264_install --enable-shared --enable-static --host=arm-linux --cross-prefix=aarch64-linux-gnu- --disable-opencl --enbale-pic --disable-asm
3. 重新编译ffmpeg#!/bin/bash ./configure \ --disable-programs \ --enable-cross-compile \ --enable-gpl \ --enable-encoder=libx264 \ --enable-libx264 \ --extra-cflags="-I/home/*/x264_install/include" --extra-ldflags="-L/home/*/x264_install/lib" --arch=aarch64 \ --target-os=linux \ --cc=aarch64-linux-gnu-gcc \ --strip=aarch64-linux-gnu-strip \ --enable-shared \ --prefix=/home/*/ffmpeg_install make -j4 make install make clean
注意: 第三条非错误,都是版本不对导致,请选择好指定版本,选择好编译参数!!!!!
-
ffmpeg使用时,报错
Input #0, jpeg_pipe, from 'null'
,using cpu capabilities: none!
需要添加编译参数--enable-libopenjpeg
- 下载openjpeg
- 交叉编译–在CMakeLists.txt文件中追加以下信息
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
SET(CMAKE_CXX_COMPILE "aarch64-linux-gnu-g++")
(添加到PROJECT(< project_name>) 之后)
编译 - 重新编译ffmpeg(失败) – 报错
ERROR: libopenjp2 >= 2.1.0 not found using pkg-config
#!/bin/bash ./configure \ --disable-programs \ --disable-x86asm \ --enable-cross-compile \ --enable-version3 \ --enable-gpl \ --enable-encoder=libx264 \ --enable-libx264 \ --enable-muxers \ --enable-encoders \ --enable-demuxers \ --enable-decoders \ --enable-parsers \ --extra-cflags="-I/home/*/x264_install/include" \ --extra-ldflags="-L/home/*/x264_install/lib" \ --extra-libs="-lm -ldl -lpthread -lz" \ --arch=aarch64 \ --target-os=linux \ --cc=aarch64-linux-gnu-gcc \ --strip=aarch64-linux-gnu-strip \ --enable-shared \ --prefix=/home/*/ffmpeg_install-4.2.2 make -j8 make install make clean