1:安装相关基础依赖
sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev
2:补充安装
sudo apt-get install libasound2-dev sudo apt-get install libgl1-mesa-dev sudo apt-get install libglew-dev sudo apt-get install libglm-dev sudo apt-get install mercurial libnuma-dev
3:安装相关第三方库
用到汇编相关的程序 nasm wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 tar jxvf nasm-2.14.02.tar.bz2 cd nasm-2.14.02 ./autogen.sh ./configure --prefix="$HOME/ffmpeg6.0_build" --bindir="$HOME/ffmpeg6.0_bin" make -j4 make install ln -s $HOME/ffmpeg6.0_bin/nasm /usr/bin/nasm 同样汇编库 Yasm wget -O yasm-1.3.0.tar.gz https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar xzvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix="$HOME/ffmpeg6.0_build" --bindir="$HOME/ffmpeg6.0_bin" make make install ln -s $HOME/ffmpeg6.0_bin/yasm /usr/bin/yasm libx264 要求编译ffmpeg时配置:--enable-gpl --enable-libx264. cd ~/ffmpeg6.0_sources git clone --depth 1 https://github.com/mirror/x264.git cd x264 PKG_CONFIG_PATH="$HOME/ffmpeg6.0_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg6.0_build" --bindir="$HOME/ffmpeg6.0_bin" --enable-static --enable-shared --enable-pic make make install libx265 要求编译ffmpeg时配置:--enable-gpl --enable-libx265 cd ~/ffmpeg6.0_sources git clone https://gitee.com/mirrors_videolan/x265.git cd x265/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg6.0_build" -D ENABLE_SHARED=on -DENABLE_PIC=on -DBIN_INSTALL_DIR="$HOME/ffmpeg6.0_bin" ../../source make make install libvpx: 要求编译ffmpeg时配置: --enable-libvpx cd ~/ffmpeg6.0_sources git clone --depth 1 https://github.com/webmproject/libvpx.git cd libvpx ./configure --prefix="$HOME/ffmpeg6.0_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared make make install libfdk-aac 要求编译ffmpeg时配置:--enable-libfdk-aac ( 如果你已经配置了 --enable-gpl则需要加上-- enable-nonfree). cd ~/ffmpeg6.0_sources git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git cd fdk-aac autoreconf -fiv ./configure CFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix="$HOME/ffmpeg6.0_build" --bindir="$HOME/ffmpeg6.0_bin" make make install libmp3lame MP3⾳频编码器. 要求编译ffmpeg时配置:--enable-libmp3lame. cd ~/ffmpeg6.0_sources git clone --depth 1 https://gitee.com/hqiu/lame.git cd lame ./configure --prefix="$HOME/ffmpeg6.0_build" --bindir="$HOME/ffmpeg6.0_bin" --enable-nasm --with-pic make make install libopus Opus⾳频编解码器. 要求编译ffmpeg时配置:--enable-libopus cd ~/ffmpeg6.0_sources git clone --depth 1 https://github.com/xiph/opus.git cd opus ./autogen.sh ./configure --prefix="$HOME/ffmpeg6.0_build" -with-pic make make install ln -s $HOME/ffmpeg6.0_bin/lame /usr/bin/lame ffmpeg6.0的安装 cd ~/ffmpeg6.0_sources git clone https://github.com/FFmpeg/FFmpeg.git cd FFmpeg git checkout remotes/origin/release/6.0 PKG_CONFIG_PATH="$HOME/ffmpeg6.0_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg6.0_build" --extra-libs="-lpthread -lm" --bindir="$HOME/ffmpeg6.0_bin" --pkg-config-flags="--static" --extra-cflags="-I/home/ubuntu/ffmpeg6.0_build/include" --extra-cflags="-I/home/ubuntu/ffmpeg6.0_build/include/fdk-aac" --extra-ldflags="-L/home/ubuntu/ffmpeg6.0_build/lib" --enable-gpl --enable-libass --enable-libfreetype --enable-libvorbis --enable-pic --enable-shared --enable-static --enable-nonfree --enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-sdl2 --enable-ffplay --disable-optimizations --disable-stripping --enable-debug=3 解决ERROR: libmp3lame >= 3.98.3 not found 问题 --extra-ldflags=-L/home/ubuntu/ffmpeg6.0_build/lib 编辑和修改/etc/ld.so.conf sudo vim /etc/ld.so.conf 增加 /home/ubuntu/ffmpeg6.0_build/lib 使环境变量生效,然后: sudo ldconfig 添加环境变量,⽐如 sudo vim /etc/profile 然后加上 export PATH=$PATH:/home/ubuntu/ffmpeg6.0_bin source /etc/profile
另外的指令
#使用hash -d存入缓存,下次不再查找相关系统路径,直接访问缓存 hash -d ffmpeg ln -s /home/ubuntu/ffmpeg6.0_bin/ffmpeg /usr/bin/ffmpeg