安装ffmpeg+m3u8-segmenter对视频切片处理

时间:2017-03-31作者:klpeng分类:Web服务器浏览:2945评论:0

分享一个用把视频切片成TS文件流的方案,很多做视频相关开发的同学可以用到,主要采用ffmpeg+m3u8-segmenter。


安装ffmpeg

第一步: 更新源,安装必备组件

rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

yum -y update

yum -y install glibc gcc gcc-c++ autoconf automake libtool git make nasm pkgconfig

yum -y install SDL-devel a52dec a52dec-devel alsa-lib-devel faac faac-devel faad2 faad2-devel

yum -y install freetype-devel giflib gsm gsm-devel imlib2 imlib2-devel lame lame-devel libICE-devel libSM-devel libX11-devel

yum -y install libXau-devel libXdmcp-devel libXext-devel libXrandr-devel libXrender-devel libXt-devel

yum -y install libogg libvorbis vorbis-tools mesa-libGL-devel mesa-libGLU-devel xorg-x11-proto-devel zlib-devel

yum -y install libtheora theora-tools

yum -y install ncurses-devel

yum -y install libdc1394 libdc1394-devel

yum -y install amrnb-devel amrwb-devel opencore-amr-devel 


第二步:安装库文件,必须按照以下安装顺序编译


Install xvid

cd /opt

wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz

tar xzvf xvidcore-1.3.2.tar.gz

cd xvidcore/build/generic

./configure --prefix="$HOME/ffmpeg_build"

make

make install


Install LibOgg

cd /opt

wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz

tar xzvf libogg-1.3.1.tar.gz

cd libogg-1.3.1

./configure --prefix="$HOME/ffmpeg_build" --disable-shared

make

make install


Install Libvorbis

cd /opt

wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz

tar xzvf libvorbis-1.3.4.tar.gz

cd libvorbis-1.3.4

./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared

make

make install


Install Libtheora

cd /opt

wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz

tar xzvf libtheora-1.1.1.tar.gz

cd libtheora-1.1.1

./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-examples --disable-shared --disable-sdltest --disable-vorbistest

make

make install


Install Aacenc

cd /opt

wget http://downloads.sourceforge.net/opencore-amr/vo-aacenc-0.1.2.tar.gz

tar xzvf vo-aacenc-0.1.2.tar.gz

cd vo-aacenc-0.1.2

./configure --prefix="$HOME/ffmpeg_build" --disable-shared

make

make install


Install Yasm

yum remove yasm

cd /opt

wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz

tar xzfv yasm-1.2.0.tar.gz

cd yasm-1.2.0

./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"

make

make install

export "PATH=$PATH:$HOME/bin" 


Install Libvpx(注意这个一定要1.3.0版本,不然编译报错不通过)

cd /opt

git clone https://chromium.googlesource.com/webm/libvpx.git

cd libvpx

git checkout tags/v.1.3.0

./configure --prefix="$HOME/ffmpeg_build" --disable-examples

make

make install


Install X264

cd /opt

git clone git://git.videolan.org/x264.git

cd x264

./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static 

make

make install


Configure Libraries

export LD_LIBRARY_PATH=/usr/local/lib/

echo /usr/local/lib >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig


Compile FFmpeg (the configure options have to be on one line)

cd /opt

git clone git://source.ffmpeg.org/ffmpeg.git

cd ffmpeg

git checkout release/2.5    (必须是2.5版本,不然m3u8-segmenter编译不通过)

PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"

export PKG_CONFIG_PATH

./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin"

--extra-libs=-ldl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac

--enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libvo-aacenc --enable-libxvid --disable-ffplay

--enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads

make

make install


ffmpeg编译完成后才可安装m3u8-segmenter

第三步:安装m3u8-segmenter


下载包  https://codeload.github.com/johnf/m3u8-segmenter/zip/master

解压之后,执行

aclocal

automake -ac

autoconf

./configure

make

sudo make install

安装成功,如果报错,主要是ffmpeg扩展库路径不对



原创文章如转载,请注明出处,本文首发于彭超的博客

打赏
文章版权声明:除非注明,否则均为彭超的博客原创文章,转载或复制请以超链接形式并注明出处。
相关推荐

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

猜你喜欢