ffmpeg6.0静态编译之Ubuntu系统

文章目录

  • 安装依赖
  • 创建目录
  • 编译第三方库
    • NASM
    • YASM
    • libx264
    • libx265
  • libvpx
    • libfdk-aac
    • libmp3lame
    • libopus
    • SDL
  • ffmpeg

安装依赖

sudo apt-get update

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

apt-get install -y libasound2-dev \
libgl1-mesa-dev \
libglew-dev \
libglm-dev \
mercurial libnuma-dev

创建目录

mkdir ffmpeg6.0_sources ffmpeg6.0_build bin6.0

编译第三方库

NASM

cd ~/workspace/ffmpeg6.0_sources
wget https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/nasm-2.16.01.tar.bz2
tar xjvf nasm-2.16.01.tar.bz2
cd nasm-2.16.01
./autogen.sh
./configure --prefix="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0"
make -j4
make install

YASM

cd ~/workspace/ffmpeg6.0_sources
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="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0"
make
make install

libx264

cd /root/workspace/ffmpeg6.0_sources
git clone --depth 1 https://github.com/mirror/x264.git
cd x264
PKG_CONFIG_PATH="/root/workspace/ffmpeg6.0_build/lib/pkgconfig" ./configure --prefix="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0" --enable-static --enable-shared --enable-pic
make
make install

libx265

cd /root/workspace/ffmpeg6.0_sources
git clone https://gitee.com/mirrors_videolan/x265.git
cd x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/root/workspace/ffmpeg6.0_build" -DENABLE_SHARED=on -DENABLE_PIC=on -DBIN_INSTALL_DIR="/root/workspace/bin6.0" ../../source
make
make install

修改x265.pc

libvpx

cd /root/workspace/ffmpeg6.0_sources
git clone --depth 1 https://github.com/webmproject/libvpx.git
cd libvpx
./configure --prefix="/root/workspace/ffmpeg6.0_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared
make
make install

libfdk-aac

cd /root/workspace/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="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0"
make
make install

libmp3lame

cd /root/workspace/ffmpeg6.0_sources
git clone --depth 1 https://gitee.com/hqiu/lame.git
cd lame
./configure --prefix="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0" --enable-nasm --with-pic
make
make install

libopus

cd /root/workspace/ffmpeg6.0_sources
git clone --depth 1 https://github.com/xiph/opus.git
cd opus
./autogen.sh
./configure --prefix="/root/workspace/ffmpeg6.0_build" -with-pic
make
make install

SDL

git clone https://github.com/libsdl-org/SDL.git -b SDL2
cd SDL
mkdir build
cd build
../configure --prefix="/root/workspace/ffmpeg6.0_build" --bindir="/root/workspace/bin6.0" 
make
make install

ffmpeg

cd /root/workspace/ffmpeg6.0_sources
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
git checkout remotes/origin/release/6.0
PKG_CONFIG_PATH="/root/workspace/ffmpeg6.0_build/lib/pkgconfig" ./configure \
--prefix="/root/workspace/ffmpeg6.0_build" \
--extra-libs="-lpthread -lm" \
--bindir="/root/workspace/bin6.0" \
--extra-cflags="-static" \
--extra-ldflags="-static" \
--pkg-config-flags="--static" \
--extra-cflags="-I/root/workspace/ffmpeg6.0_build/include" \
--extra-cflags="-I/root/workspace/ffmpeg6.0_build/include/fdk-aac" \
--extra-ldflags="-L/root/workspace/ffmpeg6.0_build/lib" \
--enable-gpl \
--enable-libfreetype \
--enable-libvorbis \
--enable-pic \
--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 

推荐一个零声学院免费教程,个人觉得老师讲得不错,分享给大家:Linux,Nginx,ZeroMQ,MySQL,Redis,
fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,
TCP/IP,协程,DPDK等技术内容,点击立即学习

你可能感兴趣的:(#,ffmpeg,ubuntu,linux,服务器)