標籤:style blog http color io os 使用 ar for
作業系統:centos 6.5
必需要參考的文章:
http://blog.chinaunix.net/uid-23069658-id-4018842.html
準備工作:
安裝git
yum install git -y
安裝svn
yum install svn
Centos 準備安裝刪除已安裝包
yum erase ffmpeg x264 x264-devel
Centos 安裝各種依賴包
yum install gcc gcc-c++ make nasm pkgconfig wget curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64 pcre.i386 pcre.x86_64 pcre-devel.i386 pcre-devel.x86_64 -y
安裝nasm編譯器支援彙編最佳化(lame庫需要)
防止因為時間不對,修改一下為北京時間
1.如果提示command not found,那說明ntp沒有安裝,使用如下命令進行安裝
yum -y install ntpdate ntp
2、ntpdate us.pool.ntp.org
3、設定硬體時間和軟體時間的一致並校準
/sbin/hwclock --systoh
wget http://www.nasm.us/pub/nasm/releasebuilds/2.11.05/nasm-2.11.05.tar.bz2tar xvf nasm-2.11.05.tar.bz2cd nasm-2.11.05配置安裝目錄為/usr/bin:./configure --prefix=/usr編譯並安裝:make && make install
安裝yasm編譯器支援彙編最佳化(ffmpeg庫需要)wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz解壓:tar xvf yasm-1.2.0.tar.gzcd yasm-1.2.0配置安裝目錄為/usr/bin:./configure --prefix=/usr編譯並安裝:make && make install
安裝x264庫支援h.264視頻轉碼
安裝x264庫支援h.264視頻轉碼執行以下命令擷取x264的最新原始碼git clone git://git.videolan.org/x264.gitcd x264./configure --enable-sharedmake && make install
安裝 LibNut
安裝libnut,該軟體需要用svn擷取原始碼,svn可以直接用yum install svn來裝。先下載:# svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut下載後代碼儲存在建立立的libnut目錄下,對於64位Linux需要修改設定檔:# cd libnut# vi config.mak在最後一個CFLAGS下一行增加:CFLAGS += -fPIC然後編譯安裝:# make # make install
====================================================================================================================================================
安裝liboggyum install libogg-devel
安裝libtheora (svn擷取)
# svn co http://svn.xiph.org/trunk/theora theora# cd theora # ./autogen.sh # ./configure # make # make install
安裝libvorbis# wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz# tar xvfz libvorbis-1.2.0.tar.gz# cd libvorbis-1.2.0 # ./configure # make # make install
安裝libvpx
++++++++libvpx+++++++++++git clone http://git.chromium.org/webm/libvpx.git (本次擷取後打包為libvpx-v1.2.0.tar.gz) 其它擷取方式#wget http://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2cd libvpx./configure --enable-sharedmake && make install
++++++++Xvid+++++++++++#wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gztar zxf xvidcore-1.3.2.tar.gzcd xvidcore/build/generic./configuremake && make install
上面的媒體支援庫安裝完後,可以設定下環境準備編譯ffmpeg了。不過在此之前必須修改環境變數vim /etc/ld.so.conf在檔案末增加一行:/usr/local/lib 然後生效之:ldconfig -v
編譯ffmpeg執行以下命令擷取ffmpeg原始碼git clone git://source.ffmpeg.org/ffmpeg.gitcd ffmpeg./configure --enable-version3 --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads --enable-libnut --enable-libtheora***需要保證 --enable-libx264能執行make && make installldconfig -vTS流分割器segmenter的安裝與使用git clone https://github.com/johnf/m3u8-segmenter
cd m3u8-segmenter
gcc -Wall -g m3u8-segmenter.c -o segmenter -lavformat -lavcodec -lavutilcp segmenter /usr/bin/
直接轉成ts
ffmpeg -i vp5.flv -acodec copy -vcodec libx264 vp5.ts
150MB的一個MPG檔案,大約轉換時間:4分零7秒。
切割
segmenter -i vp5.ts -d 10 -p segmenter_test -m vp5.m3u8 -u http://127.0.0.1:8080/Video/ 這樣就可以切片出m3u8檔案 直接使用hls
在Centos 6.5 X64下切割m3u8