Ubuntu12.04.3 配置nginx-rtmp支持HLS
来源:互联网 发布:下载淘宝帐号注册账号 编辑:程序博客网 时间:2024/04/30 14:10
之前编译配置过 ngix-rtmp 来支持HLS.
linux和windows都有。 http://blog.csdn.net/commshare/article/details/17652171
今天需要测试下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:
用播放器吧:
- Ubuntu12.04.3 配置nginx-rtmp支持HLS
- NGINX配置rtmp服务器实现rtmp以及hls直播
- NGINX配置rtmp服务器实现rtmp以及hls直播
- Nginx Intro - RTMP HLS
- nginx hls rtmp 环境搭建
- Mac直播服务器Nginx配置对HLS的支持
- Mac直播服务器Nginx配置对HLS的支持
- 使用Nginx-rtmp-module搭建hls直播
- Nginx RTMP配置文件种HLS部分
- HLS/MPEG-DASH/RTMP with nginx
- HLS/MPEG-DASH/RTMP with nginx
- HLS/MPEG-DASH/RTMP with nginx
- hls直播nginx配置
- nginx支持HLS 起始篇
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- CentOS6下基于Nginx搭建mp4/flv流媒体服务器(可随意拖动)并支持RTMP/HLS协议(含转码工具)
- ngxin-rtmp-module 搭建及rtmp & hls 配置简单分享
- Speex 回声消除
- camera 模组驱动优化
- 智能指针的实现
- Java 开发 2.0: 现实世界中的 Redis
- CentOS 6.4 简单方法升级PHP到PHP 5.3.3
- Ubuntu12.04.3 配置nginx-rtmp支持HLS
- 云计算之现状
- iOS Crash文件分析
- 【cv】使用opencv的FeatureDetector,DescriptorExtractor,DescriptorMatcher
- python 多进程通信模块
- 虚拟化技术系列--openvswitch介绍
- Objective-C – 关联引用
- 1489 求二叉树的先序遍历 1291 数据结构上机测试4.1:二叉树的遍历与应用1【二叉树遍历顺序转换】
- Spring 3.0 注解注入详解