using FFMPEG to setup HLS server on Ubuntu

来源:互联网 发布:中国什么发生战争 知乎 编辑:程序博客网 时间:2024/06/09 14:38
1. environment setup in Linux OS
  1). install libx264 to support h264 encoder
      sudo apt-get install libx264-dev
      
  2). install FFMPEG with libx264 library
      sudo apt-get install ffmpeg
      
  3). install VLC into the OS
      sudo apt-get install VLC


2. setup TS server using VLC
   using the vlc transcode commond as before
   vlc -vvv udp://@239.192.58.3:1234 --network-caching=10 --sout 
   '#transcode{vcodec=h264,venc=x264{keyint=25,idrinit=25,bframes=0,
   ref=1,hrd=cbr,crf=28,vb=4500,preset=ultrafast,tune=zerolatency,vbv-maxrate=1200},
   fps=25.00,threads=48,deinterlace,audio-sync}:udp{caching=10,mux=ts,dst=192.168.0.1:5050,name="testTS1"}'
   
3. using ffmpeg to receive the TS & slice it into small TS file indexed by m3u8 file(we can also use other parameters, such as size -s)

   ffmpeg -re -i udp://@ip:port -vcodec libx264 -acodec aac -strict -2 -segment_time 10 -threads 24 -f hls webURL

比如:m3u8-segmenter -i udp://@:1234 -t 8 -d 5 -n 100 -p test -m test.m3u8 -u /test/

   
   -i --input file path or URL
   -vcodec   --video codec
   -acodec   --audio codec
   -segment_time --ts duration time
   -threads --number of threads
   -f     --hls

   webURL --the address which clients can access.such as http://192.168.0.8/videos/test.m3u8


搭建X264环境

1. x264
  1). download the newest code:
     git clone git://git.videolan.org/x264.git
   
  2). configure the x264:
     ./configure --enable-shared
     
  3). make && sudo make install
   
2. ffmpeg
  1).download the newest code:
   git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
   
  2). configure the ffmpeg(if we don't needs AAC, we don't need "--enable-libfaac --enable-libfaad --enable-libmp3lame")
   ./configure --enable-gpl --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264
   
  3).make && sudo make install

0 0
原创粉丝点击