java rtmp服务器_基于nginx搭建RTMP服务器

安装nginx

下载ngnix源码

git clone https://github.com/nginx/nginx.git

git clone https://github.com/arut/nginx-rtmp-module.git

编译安装

./configure --add-module=../nginx-rtmp-module-master

make

sudo make install

默认安装路径为/usr/local/nginx,运行./sbin/nginx

打开浏览器在地址栏输入:localhost,如果显示Welcome to nginx,说明安装成功了

配置rtmp服务

打开./conf/nginx.conf ,添加RTMP的配置

worker_processes 1;

events {

worker_connections 1024;

}

rtmp { #RTMP服务

server {

listen 6666; #//服务端口

chunk_size 4096; #//数据传输块的大小

application vod { #//点播服务

play /opt/video/vod; #//视频文件存放位置。

}

application live{ #第一处添加的直播字段

live on;

}

}

}

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 { #第二处添加的location字段。

rtmp_stat all;

rtmp_stat_stylesheet stat.xsl;

}

location /stat.xsl { #第二处添加的location字段。

root /usr/local/nginx/nginx-rtmp-module/;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

}

配置目录/opt/video/vod为存放视频文件的位置,放一个视频文件test.mp4用于测试

打开视频播放软件,播放地址填写rtmp://localhost:6666/vod/test.mp4

live是直播服务,如果打算弄多个频道的直播就可以live_2、live_2名字任意。第二处就是添加两个location字段,字段的内容请直接看文件吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值