天天看點

視訊采集伺服器部署指南

1. 環境準備

安裝wget: 

yum install wget -y

安裝git: 

yum install git -y

安裝gcc: 

yum install gcc -y

安裝

2. 安裝nginx

nginx使用源碼方式安裝,同時安裝nginx-rtmp-module, http_flv_module,http_mp4_module, http_gzip_static_module, http_ssl_module

2.1 安裝依賴

yum -y install pcre pcre-devel zlib-devel openssl openssl-devel

2.2 下載下傳nginx-rtmp-module

wget https://github.com/arut/nginx-rtmp-module/archive/v1.1.7.tar.gz

tar -xzvf v1.1.7.tar.gz

2.3 下載下傳nginx源碼

wget http://nginx.org/download/nginx-1.9.3.tar.gz

tar -xzvf nginx-1.9.3.tar.gz

2.4 編譯安裝

cd nginx-1.9.3

./configure --add-module=../nginx-rtmp-module-1.1.7 --with-http_ssl_module --with-http_mp4_module --with-http_flv_module --with-http_gzip_static_module

make

make install

3. 安裝ffmpeg

3.1 安裝ffmpeg依賴

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

3.1.1 安裝yasm
YASM是 libx264和ffmpeg要用到得一個彙編工具

git clone --depth 1 git://github.com/yasm/yasm.git

cd yasm

autoreconf -fiv

./configure

make

make install

make distclean

3.1.2 安裝Libx264解碼包

libx264 是H.264編解碼器, 編譯時需指定 

--enable-gpl

--enable-libx264

git clone --depth 1 git://git.videolan.org/x264

cd x264

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

make

make install

make distclean

3.2 安裝ffmpeg

git clone --depth 1 git://source.ffmpeg.org/ffmpeg

cd ffmpeg

PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --pkg-config-flags="--static" --enable-gpl --enable-libx264

make

make install

4. 配置nginx

 rtmp {

    server {

        listen 1935;

        application video {

            live on;

        }

        application hls {

            live on;

            hls on;

            hls_path /tmp/hls;

        }

     }  

 }

然後,針對hls,還需要在http裡面增加一個location配置

 location /hls {

     types {

         application/vnd.apple.mpegurl m3u8;

         video/mp2t ts;

     }

     root /tmp;

     add_header Cache-Control no-cache;

 }

熬夜不易,點選請老王喝杯烈酒!!!!!!!