linux 编译 ffmpeg libx264 lib265 libfdk-aac

一 、下载安装包

  • http://ffmpeg.org/download.html
  • https://www.videolan.org/developers/x264.html
  • https://www.videolan.org/developers/x265.html
  • https://pan.baidu.com/s/1hUx9Qb3KeRPwLSw35jE-Lg 提取码kkoj
  • http://www.linuxfromscratch.org/blfs/view/svn/multimedia/fdk-aac.html
    https://blog.csdn.net/qq_37275444/article/details/90511542
    https://bitbucket.org/multicoreware/x265/downloads/

二、安装gcc

  1. 查看服务器是否安装gcc
    执行 gcc --version

出现如上结果需要安装
执行 yum install gcc
装好后

三 、安装bzip2 用于解压
执行:`yum -y install bzip2'

四 、安装yasm

  1. 解压yasm
    执行: tar -zxvf yasm-1.3.0.tar.gz
  2. 进入解压目录
    执行: cd yasm-1.3.0
  3. 编译和安装
    执行1: ./configure
    执行2: make
    执行3:make install
  4. 查看安装结果
    执行 yasm --version

五 、安装nasm

  1. 解压nasm
    执行: tar jxvf nasm-2.13.tar.bz2
  2. 进入目录
    执行:cd nasm-2.13
  3. 编译和安装
    执行1:./configure
    执行2:make
    执行3:make install
  4. 查看安装结果


六 、编译libx264

  1. 解压x264
    执行: tar jxvf last_x264.tar.bz2
  2. 进入解压目录
    cd x264-snapshot-20190522-2245/
  3. 编写编译脚本
    build_x264.sh 放到 x264-snapshot-20190522-2245/ 目录里
#!/bin/bash

PREFIX=../ffmpeg/thirdparty/libx264

function build_one
{
./configure \
--enable-asm \
--prefix=$PREFIX \
--enable-static \
--enable-pic \
--enable-strip \

make 
make install

}
build_one

4.编译
执行 ./build_x264.sh

七、编译libx265

  1. 加压
    tar -xzvf x265_3.3.tar.gz
    cd x265_3.3/build/linux

2 修改脚本文件 make-Makefiles.bash

#!/bin/bash
# Run this from within a bash shell
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/root/gupan/linux-ffmpeg/ffmpeg/thirdparty/libx265 -DENABLE_LIBNUMA:bool=off -DENABLE_SHARED:bool=on ../../source

3.执行


make clean
 
sh make-Makefiles.bash
 
make
 
make install

八、编译libfdk-aac

  1. 下载fdk-aac,解压
    https://sourceforge.net/projects/opencore-amr/files/fdk-aac/

tar -xzvf fdk-aac-2.0.1.tar.gz
cd fdk-aac-2.0.1

2.编写编译脚本
build_fdk-aac.sh 放到fdk-aac/ 目录里

#!/bin/bash
PREFIX=/root/gupan/linux-ffmpeg/ffmpeg/thirdparty/libfdk-aac

function build_one
{
./configure \
--prefix=$PREFIX\

make 
make install

}

build_one

3.执行脚本
./build_fdk-aac.sh

报错


解决办法:在linux终端下执行 :autoreconf -vfi

九、编译librtmp

  1. 下载代码
    下载地址

rtmpdump-2.3.tgz

  1. 解压
    执行:tar -xzvf rtmpdump-2.3.tgz

3.安装依赖库

  • openssl

http://www.openssl.org/ 我下的是1.0.1f版本。
tar zxvf openssl-1.0.1f.tar.gz
cd openssl-1.0.1f
./config --prefix=/usr
make
sudo make install

  • zlib

然后安装zlib:
http://www.zlib.net/
tar zxvf zlib-1.2.11.tar.gz ,解压时出现一点错误,但是不要仅。


cd zlib-1.2.11
make test (参数是看了readme后加的)
sudo make install

3.进入
执行:cd rtmpdump-2.3/

4.编译


  • 修改makefile目标位置
  • LDFLAGS=-Wall $(XLDFLAGS) -ldl
  • make
    -执行脚本
    install.sh
#!/bin/bash
prefix=/root/gupan/linux-ffmpeg/ffmpeg/thirdparty/librtmp
mkdir -p $prefix $prefix/lib $prefix/include $prefix/man3 $prefix/pkgconfig
cd librtmp
cp amf.h http.h log.h rtmp.h $prefix/include
cp librtmp.a  $prefix/lib
cp librtmp.pc $prefix/pkgconfig
cp librtmp.3 $prefix/man3
cp librtmp.so $prefix/lib
cp librtmp.so.0 $prefix/lib

十、编译ffmpeg

  1. 解压fmepg
    tar jxvf ffmpeg-4.1.3.tar.bz2

  2. 移动thirdparty 文件夹到 ffmpeg-4.1.3.
    mv ./ffmpeg/thirdparty/ ffmpeg-4.1.3
    重命名文件夹为 ffmpeg

3.编写编译脚本
build_ffmpeg.sh

#!/bin/bash

basepath=$(cd `dirname $0`; pwd)
THIRDPARTYPATH=$basepath/thirdparty

LIBX264_INCLUDE=$THIRDPARTYPATH/libx264/include     
LIBX264_LIB=$THIRDPARTYPATH/libx264/lib         

LIBX265_INCLUDE=$THIRDPARTYPATH/libx265/include     
LIBX265_LIB=$THIRDPARTYPATH/libx265/lib 

LIBOPUS_INCLUDE=$THIRDPARTYPATH/libopus/include     
LIBOPUS_LIB=$THIRDPARTYPATH/libopus/lib 
#LIBMP3LAME_INCLUDE=$THIRDPARTYPATH/libmp3lame/include      
#LIBMP3LAME_LIB=$THIRDPARTYPATH/libmp3lame/lib          

#LIBSPEEX_INCLUDE=$THIRDPARTYPATH/libspeex/include      
#LIBSPEEX_LIB=$THIRDPARTYPATH/libspeex/lib  



#LIBVPX_INCLUDE=$THIRDPARTYPATH/libvpx/include      
#LIBVPX_LIB=$THIRDPARTYPATH/libvpx/lib  

#LIBILBC_INCLUDE=$THIRDPARTYPATH/libilbc/include        
#LIBILBC_LIB=$THIRDPARTYPATH/libilbc/lib    

#LIBOPENCV_INCLUDE=$THIRDPARTYPATH/libopencv/install/include        
#LIBOPENCV_LIB=$THIRDPARTYPATH/libopencv/lib    

#LIBOPENSSL_INCLUDE=$THIRDPARTYPATH/libopenssl/include      
#LIBOPENSSL_LIB=$THIRDPARTYPATH/libopenssl/lib  

function build_one
{
./configure \
--prefix=$PREFIX \
--extra-cflags="-I$LIBX264_INCLUDE -I$LIBX265_INCLUDE -I$LIBOPUS_INCLUDE -O4 -g" \
--extra-ldflags="-L$LIBX264_LIB  -L$LIBX265_LIB -L$LIBOPUS_LIB -lpthread -ldl" \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-nonfree \
--enable-version3 \
--enable-pthreads \
--disable-small \
--disable-network \
--enable-iconv \
--disable-x86asm \
--enable-libx264 \
--enable-libx265 \
--enable-libopus \
--enable-encoder=aac \
--enable-encoder=mpeg4 \
--enable-encoder=mjpeg \
--enable-encoder=png \
--enable-muxer=mov \
--enable-muxer=mp4 \
--enable-muxer=adts \
--enable-muxer=h264 \
--enable-muxer=mjpeg \
--disable-decoders \
--enable-decoder=pcm_mulaw \
--enable-decoder=aac \
--enable-decoder=aac_latm \
--enable-decoder=mp3 \
--enable-decoder=h264 \
--enable-decoder=mpeg4 \
--enable-decoder=mjpeg \
--enable-decoder=png \
--disable-demuxers \
--enable-demuxer=image2 \
--enable-demuxer=h264 \
--enable-demuxer=aac \
--enable-demuxer=mp3 \
--enable-demuxer=mpc \
--enable-demuxer=mpegts \
--enable-demuxer=mov \
--disable-parsers \
--enable-parser=aac \
--enable-parser=ac3 \
--enable-parser=h264 \
--disable-protocols \
--enable-protocol=file \
--enable-protocol=concat \
--enable-filters \
--disable-outdevs \
--disable-doc \
--disable-debug \
--disable-ffprobe \
--disable-postproc \
--disable-avdevice \
--disable-symver \
--disable-stripping \
--disable-encoder=aac \
--disable-decoder=aac \
--enable-encoder=libfdk_aac \
--enable-decoder=libfdk_aac \
--enable-encoder=libfdk_aac \
--enable-decoder=libfdk_aac \
--enable-libfdk-aac

$ADDITIONAL_CONFIGURE_FLAG

 #  make -j8
 #   make install
}
# arm v7vfp
CPU=
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=armv7-a "
OPTIMIZE_CFLAGS="-Wno-deprecated-declarations"
ADDI_CFLAGS=""
PREFIX=./out
build_one

执行脚本

你可能感兴趣的:(linux 编译 ffmpeg libx264 lib265 libfdk-aac)