在RedHat 6.x和7.x上用编译ffmpeg

来源:互联网 发布:黑马程序员 如何 编辑:程序博客网 时间:2024/05/16 05:31

# 参考文档
# http://trac.ffmpeg.org/wiki/CompilationGuide/Centos
# http://www.linuxfromscratch.org/blfs/view/7.8/


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


#安装SDL
wget http://www.libsdl.org/release/SDL-1.2.15-1.x86_64.rpm
wget http://www.libsdl.org/release/SDL-devel-1.2.15-1.x86_64.rpm
#官网的SDL-1.2.15比RedHat多了/usr/lib64/libSDLmain.a文件
#yum erase SDL SDL-devel
rpm -ivh SDL-1.2.15-1.x86_64.rpm --force
rpm -ivh SDL-devel-1.2.15-1.x86_64.rpm --force


#编译SDL2
wget http://www.libsdl.org/release/SDL2-2.0.3.tar.gz
tar -xzvf SDL2-2.0.3.tar.gz
cd SDL2-2.0.3
./configure --prefix=/usr/local/share/sdl2-2.0.3
make && make install && make clean
cat > sdl2-x86_64.conf <<EOF
/usr/local/share/sdl2-2.0.3/lib
EOF
ldconfig
cat >> /etc/profile
export PATH=$PATH:/usr/local/share/sdl2-2.0.3/bin


if [ $FFDIR ]
then 
    echo "\$FFDIR is already exist"
else
    cat >> /etc/profile <<EOF
export FFDIR=/usr/local/share/ffmpeg
export PATH=\$PATH:\$FFDIR/bin
EOF
    source /etc/profile
fi


mkdir -p $FFDIR/src $FFDIR/build $FFDIR/bin


#Compilation & Installation


cd $FFDIR/src
#git clone --depth 1 git://github.com/yasm/yasm.git
#cd yasm
if [ ! -f yasm-1.3.0.tar.gz ] 
then
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
    tar -xzvf yasm-1.3.0.tar.gz
fi
cd yasm-1.3.0
autoreconf -fiv
./configure --prefix=$FFDIR/build --bindir=$FFDIR/bin
make && make install && make distclean


cd $FFDIR/src
#git clone --depth 1 git://git.videolan.org/x264
#cd x264
if [ ! -f x264-snapshot-20150908-2245-stable.tar.bz2 ] 
then
    wget http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20150908-2245-stable.tar.bz2
    tar -xjvf x264-snapshot-20150908-2245-stable.tar.bz2
fi
cd x264-snapshot-20150908-2245-stable
./configure --prefix=$FFDIR/build --bindir=$FFDIR/bin --enable-static --enable-shared --enable-pic
make && make install && make distclean


cd $FFDIR/src
#hg clone https://bitbucket.org/multicoreware/x265
#cd x265/build/linux
if [ ! -f x265_1.8.tar.gz ] 
then
    wget https://bitbucket.org/multicoreware/x265/downloads/x265_1.8.tar.gz
    tar -xzvf x265_1.8.tar.gz
fi
cd x265_11047/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$FFDIR/build -DENABLE_SHARED:bool=on -DENABLE_PIC:bool=on ../../source
make && make install && make clean


cd $FFDIR/src
#git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
#cd fdk-aac
if [ ! -f fdk-aac-0.1.4.tar.gz ] 
then
    wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.4.tar.gz
    tar -xzvf fdk-aac-0.1.4.tar.gz
fi
cd fdk-aac-0.1.4
autoreconf -fiv
./configure --prefix=$FFDIR/build --enable-static --enable-shared --enable-pic
make && make install && make distclean


cd $FFDIR/src
if [ ! -f lame-3.99.5.tar.gz ] 
then
    wget http://downloads.sourceforge.net/lame/lame-3.99.5.tar.gz
    tar -xzvf lame-3.99.5.tar.gz
fi
cd lame-3.99.5
./configure --prefix=$FFDIR/build --bindir=$FFDIR/bin --enable-static --enable-shared --enable-pic --enable-nasm
make && make install && make distclean


cd $FFDIR/src
#git clone git://git.opus-codec.org/opus.git
#git clone https://github.com/xiph/opus.git
#cd opus
if [ ! -f opus-1.1.tar.gz ] 
then
    wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz
    tar -xzvf opus-1.1.tar.gz
fi
cd opus-1.1/
autoreconf -fiv
./configure --prefix=$FFDIR/build --enable-static --enable-shared --enable-pic
make && make install && make distclean


cd $FFDIR/src
if [ ! -f libogg-1.3.2.tar.gz ] 
then
    wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
    tar -xzvf libogg-1.3.2.tar.gz
fi
cd libogg-1.3.2
./configure --prefix=$FFDIR/build --enable-static --enable-shared --enable-pic
make && make install && make distclean


cd $FFDIR/src
if [ ! -f libvorbis-1.3.5.tar.gz ] 
then
    wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
    tar -xzvf libvorbis-1.3.5.tar.gz
fi
cd libvorbis-1.3.5
LDFLAGS="-L$FFDIR/build/lib" CPPFLAGS="-I$FFDIR/build/include" ./configure --prefix=$FFDIR/build --with-ogg=$FFDIR/build --enable-static --enable-shared --enable-pic
make && make install && make distclean


cd $FFDIR/src
#git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
#git clone --depth 1 https://github.com/webmproject/libvpx.git
#git clone https://github.com/webmproject/libvpx
#cd libvpx
if grep -i "release 6" /etc/redhat-release 
then
    yum install -y libvpx 
else
    if [ ! -f libvpx-1.4.0.tar.bz2 ] 
    then
        wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.4.0.tar.bz2
        tar -xjvf libvpx-1.4.0.tar.bz2
    fi 
    cd libvpx-1.4.0
    ./configure --prefix=$FFDIR/build --disable-unit-tests --enable-static --enable-shared --enable-pic 
    make && make install && make distclean
fi




cd $FFDIR/src
#git clone --depth 1 git://source.ffmpeg.org/ffmpeg
#git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
#git clone https://github.com/FFmpeg/FFmpeg.git
#cd FFmpeg/
if [ ! -f ffmpeg-2.8.1.tar.bz2 ] 
then
    wget http://ffmpeg.org/releases/ffmpeg-2.8.1.tar.bz2
    tar -xjvf ffmpeg-2.8.1.tar.bz2
fi
cd ffmpeg-2.8.1
PKG_CONFIG_PATH=$FFDIR/build/lib/pkgconfig ./configure --prefix=$FFDIR/build --extra-cflags=-I"$FFDIR/build/include" --extra-ldflags=-L"$FFDIR/build/lib" \
--bindir=$FFDIR/bin --enable-static --enable-shared --enable-pic --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
--enable-libopus --enable-libvorbis  --enable-libx264 --enable-libx265 --enable-libvpx --enable-ffplay
make && make install && make distclean
cat > /etc/ld.so.conf.d/ffmpeg-x86_64.conf <<EOF
/usr/local/share/ffmpeg/build/lib
EOF
ldconfig
hash -r

0 0
原创粉丝点击