1、搭建http服務器:html
./configure --add-module=/home/andrew/Work/tools/nginx-rtmp-module --with-http_dav_module --without-http_rewrite_modulenginx
make && make install服務器
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confapp
Nginx.conf配置:code
worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; client_body_temp_path /usr/local/nginx/html/tmp; dav_methods PUT DELETE MKCOL COPY MOVE; create_full_put_path on; dav_access group:rw all:r; } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /home/andrew/Work/tools/nginx-rtmp-module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } rtmp { server { listen 1935; chunk_size 4096; application myapp { live on; record all; record_path /tmp/; recorder all { record all; record_suffix -%d-%b-%y-%T.flv; } } } }
2、拉hls點播文件server
將轉封裝後的m3u8文件存儲到/usr/local/nginx/html目錄下,經過ffmpeg能夠拉到hls文件,即htm
./ffmpeg -f hls -i http://127.0.0.1/test2.m3u8 -y test2.mp4get
3、拉hls直播文件直播
以直播的方式推流到流媒體服務器的某個路徑it
./ffmpeg -i test2.flv -y -f hls /usr/local/nginx/html/test2.m3u8
以直播的方式從流媒體服務器拉流,並轉碼後回推到該流媒體服務器
./ffmpeg -f hls -i http://192.168.40.131/test2.m3u8 -vcodec copy -f flv rtmp://192.168.40.131:1935/myapp/stream1
註釋:
-f hls 能夠省略