[Ubuntu] HTTP Live Streaming 安装测试

安裝 Apache

apt-get install apache2


 /etc/apache2/mods-available/mime.conf 加入以下內容: 

# HLS file type
AddType application/x-mpegURL .m3u8
AddType video/MP2T .ts



Ubuntu 11.04 預設的 FFmpeg 是沒有啟用 h.264 的支援,所以要自己編譯。

安裝編譯時所需要的套件

apt-get update
apt-get install build-essential checkinstall subversion git libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev libx264-dev librtmp-dev



編譯 FFmpeg

cd /opt
git clone git://git.videolan.org/ffmpeg
cd ffmpeg

./configure --prefix=/usr --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-ffplay --enable-shared --enable-gpl --enable-postproc --enable-version3 --enable-nonfree --enable-avfilter --enable-pthreads --enable-vdpau --enable-librtmp 

make -j$(grep processor /proc/cpuinfo |wc -l)

checkinstall --pkgname=ffmpeg --pkgversion="5.0.1" --backup=no --deldoc=yes --default



segmenter 是用來切割 FFmpeg 轉好的 ts 檔
編譯 segmenter

cd /opt
svn co http://httpsegmenter.googlecode.com/svn/trunk
cd trunk

sed 's//local//g' Makefile.txt > Makefile

make -j$(grep processor /proc/cpuinfo |wc -l)
checkinstall --pkgname=segmenter --pkgversion="2" --backup=no --deldoc=yes --default




測試影片轉檔 

cd /var/www
ffmpeg -i gt4.avi -f mpegts -vcodec libx264 -acodec libmp3lame gt4_pre.ts

ffmpeg -i gt4.avi -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 720x480 -vcodec libx264 -b 800k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 800k -bufsize 800k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 720:480 -g 30 -async 2 gt4_pre.ts



測試 RTMP 串接轉檔 

ffmpeg -i rtmp://flashstream.adobe.com/ondemand/flash/cs5/prod/production-performance_400x224 -f mpegts -vcodec libx264 -acodec libmp3lame rtmp_pre.ts



測試影片切割 

segmenter -i gt4_pre.ts -d 10 -o gt4_pre -x stream.m3u8 -p http://192.168.0.10/



利用 pipe 從轉檔到切割 

ffmpeg -i gt4.avi -f mpegts -vcodec libx264 -acodec libmp3lame - |segmenter -i - -d 10 -o gt4_pre -x stream.m3u8 -p http://192.168.0.10/



m3u8 檔案格式 

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:11,
http://192.168.0.10/gt4_pre-1.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-2.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-3.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-4.ts
#EXTINF:5,
http://192.168.0.10/gt4_pre-5.ts
#EXT-X-ENDLIST



以 HTML5 播放影片

<html>
  <head><title>Video Test</title></head>
  <body>
    <center>
      <video tabindex="0" width="720" height="480"><source src="/stream.m3u8"></video>
    </center>
  </body>
</html>



參考文件:
How to compile and install ffmpeg in Ubuntu 11.04
Install FFmpeg and x264 on Ubuntu Lucid Lynx 10.04 LTS
iPhone HTTP Streaming with FFMpeg and an Open Source Segmenter
HTTP Live Streaming draft-pantos-http-live-streaming-08
http live streaming(m3u8 streaming)(m3u8)

来源://作者:/更新时间:2013-09-05
相关文章
评论:
验证码:
匿名评论: