您的位置:首页 > 理论基础 > 计算机网络

nginx搭建支持http和rtmp协议的流媒体服务器之四

2014-07-02 14:15 309 查看
五、配置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,并新建网页

<html>

<head>

<script src="/smzy_jwplayer_v6.6/jwplayer.js"></script>

</head>

<body>

<div id='my-video'></div>

<script type='text/javascript'>

jwplayer('my-video').setup({

file:'rtmp://192.168.1.4/live/test',

width:'50%',

aspectratio:'3:2',

fallback:'false',

primary:'flash'

});

</script>

</body>

</html>

4. 在浏览器输中输入
http://10.2.175.10/rtmp_live.html
5. 使用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

暂时没有做测试,可见其它网文;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: