nginx搭建支持http和rtmp协议的流媒体服务器之三 【转】
来源:互联网 发布:举报网络电子邮箱地址 编辑:程序博客网 时间:2024/05/22 01:58
来自:http://blog.chinaunix.net/uid-26000296-id-4335088.html
四、配置Nginx,实现VOD,以RTMP方式播放FLV
1. 设置configure,nginx的补充编译,增加FLV和MP4功能。# cd cd nginx-1.6.0
# vim nginx_configure.sh
#!/bin/sh
echo "configure start ..."
./configure --prefix=/opt/nginx \
--add-module=../nginx_mod_h264_streaming-2.2.7 \
--with-http_flv_module \
--with-http_ssl_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre=/opt/nginx_http_rtmp/pcre-8.12 \
--with-zlib=/opt/nginx_http_rtmp/soft_source/zlib-1.2.8 \
--user=www --group=www \
--add-module=../nginx-rtmp-module \
--with-cc-opt=-I/opt/ffmpeg/include \
--with-ld-opt=`-L/opt/ffmpeg/lib -Wl, -rpath=/opt/ffmpeg/lib`
echo "configure end!"
【保存并退出】
# chmod +x nginx_configure.sh
# ./nginx_configure.sh
# make && make install
http_flv_module和http_mp4_module即为对应的解析和seek功能支持。
2. 修改 conf/nginx.conf配置
# vim conf/nginx.conf
...
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
# RTMP点播的配置
rtmp {
server {
listen 1935;
chunk_size 4000;
application vod {
play /opt/pub/media/nginx/web/vod; #点播媒体文件存放目录
}
}
}
http
{
...
# 配置RTMP虚拟机
# VOD for FLV by RTMP
server
{
listen 8080;
location /stat
{
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl
{
root /opt/nginx_http_rtmp/nginx-rtmp-module/; #在nginx-rtmp-module源码根目录
}
}
}
3. 启动Nginx
# /opt/nginx/sbin/nginx
4. 创建嵌入播放器的HTML页面
# cd /opt/pub/media/nginx/web
# vim rtmp_player.html
【保存并退出】
5. 测试
在浏览器输入栏中输入:
http://192.168.1.10/rtmp_player.html
五、配置Nginx, 实现LIVE、以RTMP方式进行直播
1. 配置conf/nginx.conf
...
rtmp {
server {
listen 1935;
chunk_size 4000;
application vod {
play /opt/pub/media/nginx/web/vod;
}
# Setting for LIVE
application live {
live on;
}
}
}
http
{
...
# LIVE and VOD by RTMP
server
{
listen 8080;
location /stat
{
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl
{
root /opt/nginx_http_rtmp/nginx-rtmp-module/;
}
}
}
2. 重新加载Nginx
# /opt/nginx/sbin/nginx -s reload
3. 准备网页 rtmp_live.html
下载播放器jwplayer,并新建网页
4. 在浏览器输中输入
http://10.2.175.10/rtmp_live.html
5. 用nginx-rtmp-module自带的一个例子修改,在test/rtmp-publisher目录下player.html
Flash not installed
访问http://10.2.175.10/player.html
6. 使用ffmpeg推流
用ffmpeg产生一个模拟直播源,向rtmp服务器推送
# ./ffmpeg –i/usr/local/nginx/vod/flvs/a.flv-strict -2 -c:v libx264 -c:a aac -f flv rtmp://192.168.1.4/live/test
注意,
源文件必须是H.264+AAC编码的。
192.168.1.4是运行nginx的服务器IP,
live是applicatioin,
test是直播缓存流文件,需要与配置文件中的直播缓存文件名一样。
六、配置Nginx 支持HLS
暂时没有做测试,可见其它网文;
- nginx搭建支持http和rtmp协议的流媒体服务器之三 【转】
- nginx搭建支持http和rtmp协议的流媒体服务器之三
- nginx搭建支持http和rtmp协议的流媒体服务器
- nginx搭建支持http和rtmp协议的流媒体服务器之二 【转】
- nginx搭建支持http和rtmp协议的流媒体服务器之二
- nginx搭建支持http和rtmp协议的流媒体服务器之四
- nginx搭建支持http和rtmp协议的流媒体服务器之二
- nginx搭建支持http和rtmp协议的流媒体服务器之二
- nginx搭建支持http和rtmp协议的流媒体服务器之一【转】
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用Nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用nginx搭建http和rtmp协议的流媒体服务器
- 利用Nginx搭建http和rtmp协议的流媒体服务器
- 【OpenCV入门教程之八】线性邻域滤波专场:方框滤波、均值滤波与高斯滤波
- c++网络多人五子棋
- 在树莓派上使用Python实现对温度,湿度以及光照强度的实施测量
- 第十二章 迭进
- SDK4/5/6/7,相册、拍照及裁剪功能及遇见的坑
- nginx搭建支持http和rtmp协议的流媒体服务器之三 【转】
- 通讯录(链表+文件实现)+ 反思
- MySQL5.7版本无法启动服务【启动后自动停止】的解决方法
- express-generator express 调用多核CPU
- GitHub integrate with Eclipse
- Thinking in java 内部类
- java中servlet程序
- 做了一个梦:人生走了一遍
- 关于USB-Serial、USB转串口、USB-UART、PL2303、CH340等的理解