Ubuntu12.04.3 配置nginx-rtmp支持HLS
2014-02-17 21:20
239 查看
之前编译配置过 ngix-rtmp 来支持HLS.
linux和windows都有。 /article/3669219.html
今天需要测试下HLS,捣鼓了下http 服务器,发送HFS有问题啊,经常不重启不能工作。
于是换用linux下的nginx-rtmp。
发现需要重新配置下,才能让nginx-rtmp工作。
nginx-rtmp 的可执行文件的路径:
sbin中是带有rtmp模块的nginx 。
conf中是配置文件。
./nginx 就可以启动nginx,没有任何输出。
之前不知道,还以为是其他的服务器占用了这个端口呢:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] still could not bind()
寻找80端口:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# sudo netstat -pan | grep ":80"tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 6048/nginx tcp 1 0 192.168.1.88:47676 91.189.94.25:80 CLOSE_WAIT 2805/ubuntu-geoip-ptcp6 0 0 :::80 :::* LISTEN 1343/apache2
发现就是nginx占用了8080.
apache2应该用的是80
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -hnginx version: nginx/1.4.3Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /home/zhangbin/streaming/hls/nginx-rtmp/home/) -c filename : set configuration file (default: conf/nginx.conf) -g directives : set global directives out of configuration file修改 以下的hls_path:
路径 /hls是指在浏览器或者播放器的 url中加入/hls,这里alias是定向到磁盘的实际路径。
修改后有俩错误,主要是没有加上;导致的:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -s reload
nginx: [emerg] invalid number of arguments in "hls_path" directive in /home/zhangbin/streaming/hls/nginx-rtmp/home/conf/nginx.conf:40
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -s reload
nginx: [emerg] invalid number of arguments in "alias" directive in /home/zhangbin/streaming/hls/nginx-rtmp/home/conf/nginx.conf:88
我最后的配置文件:
重启:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#./nginx -s reload
浏览器并不直接支持m3u8和MP4:
用播放器吧:
linux和windows都有。 /article/3669219.html
今天需要测试下HLS,捣鼓了下http 服务器,发送HFS有问题啊,经常不重启不能工作。
于是换用linux下的nginx-rtmp。
发现需要重新配置下,才能让nginx-rtmp工作。
nginx-rtmp 的可执行文件的路径:
sbin中是带有rtmp模块的nginx 。
conf中是配置文件。
./nginx 就可以启动nginx,没有任何输出。
之前不知道,还以为是其他的服务器占用了这个端口呢:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
nginx: [emerg] still could not bind()
寻找80端口:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# sudo netstat -pan | grep ":80"tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 6048/nginx tcp 1 0 192.168.1.88:47676 91.189.94.25:80 CLOSE_WAIT 2805/ubuntu-geoip-ptcp6 0 0 :::80 :::* LISTEN 1343/apache2
发现就是nginx占用了8080.
apache2应该用的是80
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -hnginx version: nginx/1.4.3Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /home/zhangbin/streaming/hls/nginx-rtmp/home/) -c filename : set configuration file (default: conf/nginx.conf) -g directives : set global directives out of configuration file修改 以下的hls_path:
application hls { live on; hls on; #hls_path /srv/nginxhls/app; hls_path /home/zhangbin/alex/Downloads/testVideos; hls_fragment 5s; }
路径 /hls是指在浏览器或者播放器的 url中加入/hls,这里alias是定向到磁盘的实际路径。
location /hls { #server hls fragments types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /home/zhangbin/alex/Downloads/testVideos; #/srv/nginxhls/app; expires -1; }
修改后有俩错误,主要是没有加上;导致的:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -s reload
nginx: [emerg] invalid number of arguments in "hls_path" directive in /home/zhangbin/streaming/hls/nginx-rtmp/home/conf/nginx.conf:40
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin# ./nginx -s reload
nginx: [emerg] invalid number of arguments in "alias" directive in /home/zhangbin/streaming/hls/nginx-rtmp/home/conf/nginx.conf:88
我最后的配置文件:
#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 1935; application myapp { live on; #record keyframes; #record_path /tmp; #record_max_size 128K; #record_interval 30s; #record_suffix .this.is.flv; #on_publish http://localhost:8080/publish; #on_play http://localhost:8080/play; #on_record_done http://localhost:8080/record_done; } application hls { live on; hls on; #hls_path /srv/nginxhls/app; hls_path /home/zhangbin/alex/Downloads/testVideos; hls_fragment 5s; } } } http { server { listen 8080; location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root <path-to-nginx-rtmp-module>; } location /control { rtmp_control all; } #location /publish { # return 201; #} #location /play { # return 202; #} #location /record_done { # return 203; #} location /rtmp-publisher { root <path-to-nginx-rtmp-module>/test; } location /hls { #server hls fragments types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /home/zhangbin/alex/Downloads/testVideos; #/srv/nginxhls/app; expires -1; } location / { root <path-to-nginx-rtmp-module>/test/rtmp-publisher; } } }
重启:
root@Ubuntu32:/home/zhangbin/streaming/hls/nginx-rtmp/home/sbin#./nginx -s reload
浏览器并不直接支持m3u8和MP4:
用播放器吧:
相关文章推荐
- Ubuntu 14.10下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- Mac直播服务器Nginx配置对HLS的支持
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- Ubuntu 配置 Nginx http2.0 支持 (二) 编译&配置Nginx 与 pagespeed
- 实时监控、直播流、流媒体、视频网站开发方案流媒体服务器搭建及配置详解:使用nginx搭建rtmp直播、rtmp点播、,hls直播服务配置详解
- Ubuntu16.04配置Nginx支持FastCGI
- Mac直播服务器Nginx配置对HLS的支持
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- NGINX配置rtmp服务器实现rtmp以及hls直播
- Ubuntu 搭建LNMP环境图文教程 配置nginx支持PHP
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- Mac直播服务器Nginx配置对HLS的支持
- ubuntu14.04 nginx-rtmp-module 配置
- 在ubuntu下为nginx配置支持cgi脚本的方案
- rtmp与hls流媒体服务器搭建:ubuntu下Nginx搭建初探与rtmp-module的添加
- ubuntu下配置nginx支持phpt(unix:/var/run/php5-fpm.sock failed (2: No such file or directory) )
- ubuntu14.04 nginx-rtmp-module 配置
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)