nginx+ nginx-http-flv-module模块实现rtmp/flv取流
步骤一:获取nginx和 flv模块的资源
git clone https://github.com/winshining/nginx-http-flv-module.git
wget http://nginx.org/download/nginx-1.24.0.tar.gz
获取后在当前目录得到如下两个文件
nginx-1.24.0.tar.gz nginx-http-flv-module
第二步:解压nginx-1.24.0.tar.gz,并进入目录
tar -zxvf nginx-1.24.0.tar.gz && cd nginx
第三步:配置config
./configure --prefix=/your path/ --add-module=../nginx-http-flv-module
第四步:编译
make && make install
第五步:修改配置文件支持rtmp 和flv
nginx.conf 示例如下
| #user nobody; 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; } rtmp { server { listen 1900; application app { live on; } } } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { add_header 'Access-Control-Allow-Origin' '*'; root html; index index.html index.htm; } location /live { flv_live on; } location /flv { add_header 'Access-Control-Allow-Origin' '*'; flv_live on; chunked_transfer_encoding on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } |
第六步:运行nginx
nginx -c nginx.conf
第七步:测试rtmp推流
从192.168.1.28的相机拉流并推到nginx服务器:
sudo ./pusher rtsp://admin:hello123@192.168.1.28:554/Streaming/Channels/101 rtmp://192.168.1.101:1900/app/stream
本拉流与推流基于zlmediakit; rtmp中的app,为配置文件中标红的名称
vlc从nignx取流地址:rtmp://192.168.1.101:1900/app/stream
第八步:测试flv推拉流
从相机拉流与推nginx流的操作如第七步。
vlc从nginx拉flv流地址: http://192.168.1.101/flv?port=1900&app=app&stream=stream
地址中app与stream名称如配置文件中标红的名称,需根据自己实际配置修改
更多推荐


所有评论(0)