1 Star 1 Fork 1

havealex / CentOS_complie_ffmpeg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

centOS_complie_ffmpeg

Compile FFmpeg on CentOS7

This guide is based on a minimal installation of the latest CentOS release, and will provide a local, non-system installation of FFmpeg with support for several common external encoding libraries. These instructions should also work for recent Red Hat Enterprise Linux (RHEL) and Fedora.

一、CentOs7下编译FFMpeg相关资料

找到一篇关于在CentOS7下编译FFMPEG源代码的文章,地址为:Compile FFmpeg on CentOS,有需要的话可以跟着做一下。另外,像编译ffmpeg源代码所需要的一些解码库x264,x265,libvpx等软件源代码包的下载,可以直接从www.linuxfromscratch.org上面下载 在Linux使用源代码安装软件时,有时候需要安装对应的依赖,从http://www.linuxfromscratch.org/blfs/view/svn/index.html这上面下载对应的软件源代码十分方便。

二、CentOS7下编译和安装ffmpeg以及相关依赖库的脚本

1、准备工作

在编译安装ffmpeg以及相关依赖包之前,需要确保安装下列编译工具:

yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel

2、一键式Shell编译脚本build_ffmpeg_all.sh

Compile FFmpeg on CentOS原文是将所有下载的ffmpeg依赖包源代码统一放置到~/ffmpeg_sources目录下,将中间的库文件放置到~/ffmpeg_build目录下,最终生成的二进制文件放在~/bin目录下。正如下面描述的仪啊杨那个: This guide is designed to be non-intrusive and will create several directories in your home directory:

  • ffmpeg_sources – Where the source files will be downloaded. This can be deleted if desired when finished with the guide.
  • ffmpeg_build – Where the files will be built and libraries installed. This can be deleted if desired when finished with the guide.
  • bin – Where the resulting binaries (ffmpeg, ffprobe, x264, x265) will be installed.

为了方便,我对脚本做了一些修改,在build_ffmpeg_all.sh脚本中增加了一个变量INSTALL_PATH,用于指定软件的安装目录,我设置成了/usr/local,当然可以根据自己的需要进行修改。

编译脚本如下:

# install required software package
#yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel

mkdir ~/ffmpeg_sources

INSTALL_PATH=/usr/local

# build and install nasm
# An assembler used by some libraries. Highly recommended or your resulting build may be very slow.
cd ~/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
tar xjvf nasm-2.14.02.tar.bz2
cd nasm-2.14.02
./autogen.sh
./configure --prefix="$INSTALL_PATH" --bindir="$INSTALL_PATH/bin"
make
make install

# build and install Yasm
# An assembler used by some libraries. Highly recommended or your resulting build may be very slow.
cd ~/ffmpeg_sources
curl -O -L 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 --prefix="$INSTALL_PATH" --bindir="$INSTALL_PATH/bin"
make
make install


# build and install libx264
# H.264 video encoder. See the H.264 Encoding Guide for more information and usage examples.
# Requires ffmpeg to be configured with --enable-gpl --enable-libx264.
cd ~/ffmpeg_sources
git clone --depth 1 https://code.videolan.org/videolan/x264.git
curl -O -L http://anduin.linuxfromscratch.org/BLFS/x264/x264-20200819.tar.xz
xz -d x264-20200819.tar.xz
tar -xvf x264-20200819.tar
mv x264-20200819 x264
cd x264
PKG_CONFIG_PATH="$INSTALL_PATH/lib/pkgconfig" ./configure --prefix="$INSTALL_PATH" --bindir="$INSTALL_PATH/bin" --enable-static
make
make install

# build and install libx265
# H.265/HEVC video encoder. See the H.265 Encoding Guide for more information and usage examples.
# Requires ffmpeg to be configured with --enable-gpl --enable-libx265.
cd ~/ffmpeg_sources
# hg clone https://bitbucket.org/multicoreware/x265
curl -O -L http://anduin.linuxfromscratch.org/BLFS/x265/x265_3.4.tar.gz
tar -xzvf x265_3.4.tar.gz
mv x265_3.4 x265
cd ~/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_PATH" -DENABLE_SHARED:bool=off ../../source
make
make install


# build and install libfdk_aac
# AAC audio encoder. See the AAC Audio Encoding Guide for more information and usage examples.
# Requires ffmpeg to be configured with --enable-libfdk_aac (and --enable-nonfree if you also included --enable-gpl).
cd ~/ffmpeg_sources
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$INSTALL_PATH" --disable-shared
make
make install

# build and install libmp3lame
# MP3 audio encoder.
# Requires ffmpeg to be configured with --enable-libmp3lame.
cd ~/ffmpeg_sources
curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="$INSTALL_PATH" --bindir="$INSTALL_PATH/bin" --disable-shared --enable-nasm
make
make install

# build and install libopus
# Opus audio decoder and encoder.
# Requires ffmpeg to be configured with --enable-libopus.
cd ~/ffmpeg_sources
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xzvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure --prefix="$INSTALL_PATH" --disable-shared
make
make install

# libvpx
# VP8/VP9 video encoder and decoder. See the VP9 Video Encoding Guide for more information and usage examples.
# Requires ffmpeg to be configured with --enable-libvpx.
cd ~/ffmpeg_sources
# git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
curl -O -L https://github.com/webmproject/libvpx/archive/v1.9.0/libvpx-1.9.0.tar.gz
tar xzvf libvpx-1.9.0.tar.gz
cd libvpx-1.9.0
./configure --prefix="$INSTALL_PATH" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install

# sdl
# for ffplay binary
cd ~/ffmpeg_sources
wget http://libsdl.org/release/SDL-1.2.15.tar.gz
tar zxvf SDL-1.2.15.tar.gz
cd SDL-1.2.15
./configure --prefix=/usr/local
sudo make
sudo make install

# build and install FFmpeg
cd ~/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$INSTALL_PATH/bin:$PATH" PKG_CONFIG_PATH="$INSTALL_PATH/lib/pkgconfig" ./configure \
  --prefix="$INSTALL_PATH" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$INSTALL_PATH/include" \
  --extra-ldflags="-L$INSTALL_PATH/lib" \
  --extra-libs=-lpthread \
  --extra-libs=-lm \
  --bindir="$INSTALL_PATH/bin" \
  --enable-gpl \
  --enable-libfdk_aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree
make
make install
hash -d ffmpeg

3、执行脚本build_ffmpeg_all.sh

执行脚本前需要保证使用root账户或者超级账户权限,然后为build_ffmpeg_all.sh添加可执行权限:

chmod +x build_ffmpeg_all.sh

最后,执行脚本

sh build_ffmpeg_all.sh

三、参考资料

空文件

简介

Compile FFmpeg on CentOS7 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/havealex/CentOS_complie_ffmpeg.git
git@gitee.com:havealex/CentOS_complie_ffmpeg.git
havealex
CentOS_complie_ffmpeg
CentOS_complie_ffmpeg
main

搜索帮助

14c37bed 8189591 565d56ea 8189591