ubuntu+nginx+rtmp搭建简易直播环境

1、ubuntu打开摄像头
虚拟机打开Camare功能,查看/dev/video1设备
ffmpeg  -f video4linux2 -framerate 20 -video_size 640*480 -i /dev/video0 -f flv rtmp://192.168.27.129/live

2、nginx部署,
/usr/local/nginx/sbin/nginx -s reload

其中nginx和rtmp模块源码下载到如下。

编译ngx+rtmp,

./configure --with-debug --prefix=/usr/local/nginx --add-module=/opt/nginx-rtmp-module --with-http_ssl_module 
make 
make install

nginx启动,

/usr/local/nginx/sbin/nginx -c  /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -s reload

3、电脑端/手机端打开vlc,访问。手机端如果访问,需要在虚拟机增加NAT配置,其中192.168.27.129为虚拟机IP。

手机端访问电脑的192.168.7.41

rtmp://192.168.7.41:8091/live

4、当电脑端和手机端同时访问时,观察nginx日志,ps -ef | grep nginx

查看21221进程的socket信息,fd11是电脑打开vlc时的socket,fd12是手机打开vlc时的socket。

2020/09/01 08:03:35 [debug] 21221#0: *20 RTMP send nmsg=1, priority=2 #201
2020/09/01 08:03:35 [debug] 21221#0: *20 send: fd:12 272 of 272
2020/09/01 08:03:35 [error] 21221#0: *20 try send data len[272],sendlen[272] (110: Connection timed out), client: 192.168.1.144, server: 0.0.0.0:1935

2020/09/01 08:03:35 [debug] 21221#0: *17 RTMP send nmsg=1, priority=2 #185
2020/09/01 08:03:35 [debug] 21221#0: *17 send: fd:11 272 of 272
2020/09/01 08:03:35 [error] 21221#0: *17 try send data len[272],sendlen[272] (110: Connection timed out), client: 192.168.27.1, server: 0.0.0.0:1935

2020/09/01 08:03:35 [error] 21221#0: *17 s->out_queue[256],out_pos[184] (110: Connection timed out), client: 192.168.27.1, server: 0.0.0.0:1935

可以看到,两个链接fd,接收数据时的队列不同,fd11队列已经累计到201,fd12队列累计到185

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值