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 能够省略