ubuntu下编译ffmpeg

Ubuntu下编译ffmpeg

官网指导:https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

下载源代码
git clone https://git.ffmpeg.org/gitweb/ffmpeg.git
切换分支

查看远程分支,切换release版本最新的分支到本地,为了稳定,编译少bug,选择release版本的

git branch -a
git checkout -b remotes/origin/release/4.1

在当前目录创建个bin文件夹,最为编译安装文件夹

mkdir bin
安装环境
sudo apt-get update -qq && 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
sudo apt-get install nasm
sudo apt-get install yasm
安装libx264

H.264 video encoder
启用需要 configured 配置 --enable-gpl --enable-libx264

sudo apt-get install libx264-dev -y
安装libx265

H.265/HEVC video encoder.

sudo apt-get install libx265-dev libnuma-dev -y
安装libvpx

VP8/VP9 video encoder/decoder
启用需要 configured 配置 --enable-libvpx

sudo apt-get install libvpx-dev -y
libfdk-aac

AAC audio encoder.
Requires ffmpeg to be configured with --enable-libfdk-aac (and --enable-nonfree if you also included --enable-gpl)

sudo apt-get install libfdk-aac-dev -y
libmp3lame

MP3 audio encoder.
Requires ffmpeg to be configured with --enable-libmp3lame.

sudo apt-get install libmp3lame-dev -y
libopus

Opus audio decoder and encoder.
Requires ffmpeg to be configured with --enable-libopus.

sudo apt-get install libopus-dev -y

libaom
AV1 video encoder/decoder:
手动安装在ffmpeg_build文件夹下,也可以收到下载release版本编译安装

git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
mkdir aom_build && \
cd aom_build && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off -DENABLE_NASM=on ../aom && \
PATH="$HOME/bin:$PATH" make && \
make install
配置configure

生成静态库,动态库, 安装到相对目录./bin文件下

./configure --prefix=./bin--enable-static --enable-shared
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --disable-libaom \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
   --enable-shared \
  --enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j 8 && \
make install && \
hash -r

编译并安装
#-j 8 多个编译一起执行,加快变异速度。多线程?多核处理?
make -j 8
#安装
make install

在bin文件夹中lib有生成的静态库和动态库

root@ubuntu:/home/hx/Downloads/ffmpeg/bin/lib# ls
libavcodec.a             libavfilter.so.7          libswresample.a
libavcodec.so            libavfilter.so.7.40.101   libswresample.so
libavcodec.so.58         libavformat.a             libswresample.so.3
libavcodec.so.58.35.100  libavformat.so            libswresample.so.3.3.100
libavdevice.a            libavformat.so.58         libswscale.a
libavdevice.so           libavformat.so.58.20.100  libswscale.so
libavdevice.so.58        libavutil.a               libswscale.so.5
libavdevice.so.58.5.100  libavutil.so              libswscale.so.5.3.100
libavfilter.a            libavutil.so.56           pkgconfig
libavfilter.so           libavutil.so.56.22.100

你可能感兴趣的:(android,linux,java,shell,直播)