nginx+rtmp module搭建直播+录制环境
2016-05-09 19:41
597 查看
摘要: nginx+rtmp module
1、将nginx和nginx-rtmp-module的源码包解压
nginx下载地址
http://nginx.org/en/download.html
nginx-rtmp-module网址
https://github.com/arut/nginx-rtmp-module
2、进入nginx的源代码目录,编译
使用nginx 1.7.2
错误如下:
adding module in /home/andrew/Work/tools/nginx-rtmp-module
+ ngx_rtmp_module was configured
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安装PCRE或者不支持rewrite功能
./configure --add-module=<path-to-nginx-rtmp-module> --without-http_rewrite_module
make
make install
nginx配置
启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
进入/usr/local/nginx/sbin目录,执行nginx
./nginx
打开浏览器输入http://ip可看到nginx已经启动的画面
./ffmpeg -re -i test2.flv -c:a copy -y -f flv rtmp://192.168.40.128:1935/myapp/stream1
访问http://192.168.40.128/stat,看到以下统计信息
nginx结束
./nginx-sstop或者./nginx-squit
一个是强制快速结束,一个是温柔结束.
注释:
192.168.40.128为测试内网IP
安装过程
1、将nginx和nginx-rtmp-module的源码包解压
PS:
nginx下载地址http://nginx.org/en/download.html
nginx-rtmp-module网址
https://github.com/arut/nginx-rtmp-module
2、进入nginx的源代码目录,编译
./configure --add-module=<path-to-nginx-rtmp-module>
使用nginx 1.7.2错误如下:
adding module in /home/andrew/Work/tools/nginx-rtmp-module
+ ngx_rtmp_module was configured
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安装PCRE或者不支持rewrite功能
./configure --add-module=<path-to-nginx-rtmp-module> --without-http_rewrite_module
make
make install
3、写一个测试配置文件
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; } 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; } } }
nginx配置
worker_processes 1; user root; #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 18000; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; client_body_temp_path /usr/local/nginx/html/tmp; } 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; } } } }
启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
进入/usr/local/nginx/sbin目录,执行nginx
./nginx
打开浏览器输入http://ip可看到nginx已经启动的画面
使用ffmpeg推流到服务器
例如./ffmpeg -re -i test2.flv -c:a copy -y -f flv rtmp://192.168.40.128:1935/myapp/stream1
访问http://192.168.40.128/stat,看到以下统计信息
nginx结束
./nginx-sstop或者./nginx-squit
一个是强制快速结束,一个是温柔结束.
注释:
192.168.40.128为测试内网IP
相关文章推荐
- PHP Warning: Module 'modulename' already loaded in问题解决办法
- JavaScript的Module模式编程深入分析
- Rsync ERROR: auth failed on module解决方法
- Lua中的模块(module)和包(package)详解
- PHP加密3DES报错 Call to undefined function: mcrypt_module_open() 如何解决
- php 无法加载mysql的module的时候的配置的解决方案引发的思考
- 深入浅析AngularJS中的module(模块)
- 详解AngularJS中module模块的导入导出
- AngularJS Module方法详解
- python进阶教程之模块(module)介绍
- python开发中module模块用法实例分析
- Magento文件系统目录结构
- 《Maven权威指南》学习笔记十七_一个多模块项目 3ff0
- 《Maven权威指南》学习笔记十八_多模块企业级项目 3ff0
- Ubuntu 12.04 LTS下安装Virtualbox
- VLC 关键模块结构分析
- 更新Debian内核e1000e驱动模块
- 记Nginx之echo模块的坑:echo_exec之前不能有echo
- PHP加密3DES报错 Call to undefined function: mcrypt_module_open() 如何解决
- Python中的模块和包