RTSP直播搭建

Docs | Description&Proxy​streamedian.com图标

 

使用streamdian开源框架搭建监控摄像头在浏览器上显示。

 

架构图如下:

 

操作

在Fedora/CentOS Installer

1)下载

https://streamedian.com/​streamedian.com

Streamedian

https://streamedian.com/​streamedian.com

 

2)安装

 
 

rpm -i websock_rtsp_proxy-1-8-3.el7.centos.x86_64.rpm

 

3)修改配置文件

 
 

#!/bin/bash # You must have the superuser permissions to run the current script #if [ "$EUID" -ne 0 ] # then echo "Please run as root" # exit #fi #dnf update -y # Create a folder for NGINX configuration files mkdir -p -m0755 /etc/nginx/conf.d/ # Copy our configuration file to the folder #cp -rp /usr/share/wsp/nginx/ws_rtsp_proxy_stream.conf /etc/nginx/conf.d/ # Install the NGINX web server #dnf install -y nginx #if [ $? -ne 0 ] #then # echo "Error: to install NGINX." # exit 1 #fi # Open port 8088 #firewall-cmd --add-port=8088/tcp --permanent # And reload the firewall #firewall-cmd --reload #if [ $? -ne 0 ] #then # echo "Error: to reload the firewall." # exit 1 #fi # Check if selinux was installed #if [ ! -x "$(command -v semanage)" ] #then # Okay, install it # dnf install -y policycoreutils-python-utils # if [ $? -ne 0 ] # then # echo "Error: to install selinux." # exit 1 # fi #fi # Add selinux permission to athe new nginx port: #semanage port -a -t http_port_t -p tcp 8088 #setsebool httpd_can_network_connect on -P #if [ $? -ne 0 ] #then # echo "Error: to set bool for httpd_can_network_connect." # exit 1 #fi systemctl stop nginx >/dev/null systemctl start nginx #if [ $? -ne 0 ] #then # echo "Error: to start nginx." # exit 1 #fi echo "Done" exit 0 # If you would like to cancel all these changes, please use the following commands: #systemctl stop nginx #rm -rf /etc/nginx/conf.d/ws_rtsp_proxy_stream.conf #rmdir -p --ignore-fail-on-non-empty /etc/nginx/conf.d/ #dnf remove nginx #firewall-cmd --remove-port=8088/tcp --permanent #firewall-cmd --reload #semanage port -d -t http_port_t -p tcp 8088 #setsebool httpd_can_network_connect off -P #dnf remove policycoreutils-python-utils

去掉防火墙等其他配置,保留一个nginx启动就可以。否则会跑不起来。

 

4)启动nginx-websocket-proxy

启动proxy

 
 

systemctl start nginx

 

报错了,因为我的服务器已经搭建了nginx 作为官网的发布地址,所以提示绑定端口80失败了。

思路:把nginx的端口配置成其他就可以了.

 

原来网站搭建的nginx地址:

/usr/local/nginx

 

nginx-websocket-proxy

安装后配置文件在:/etc/nginx/nginx.conf

安装路径:/usr/sbin/nginx

 

如果不知道安装路径可以使用:命令ps -ef |grep nginx 获取信息

 

修改/etc/nginx/nginx.conf,注释到80端口防止冲突。

 
 

[root@VM_0_14_centos nginx]# vim nginx.conf # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; # server { # listen 80 default_server; # listen [::]:80 default_server; # server_name _; # root /usr/share/nginx/html; # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # location / { # } # error_page 404 /404.html; # location = /40x.html { # } # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; "nginx.conf" 90L, 2482C written

保存

输入下面命令开启nginx,就不会冲突了。

 

systemctl start nginx

 

5)访问Streamedian RTSP player example

不能进去,问题是nginx上没有配置外网IP,默认配置了localhost。修改成外网IP地址。

 

cd /etc/nginx/conf.d

顺利进入

 

 

6)输入测试rtsp地址,发现出错。

 
 

rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov

提示缺少证书。

这是因为官方对内网可以免费使用,对外网的就需要购买证书。

开发者也是挣点外快,比较花了时间,精力去开发,维护。

 

7)激活证书

上面是官方激活账号的说明。可以先使用试用版本,等程序能调通的情况下,再去购买。

我使用了在线激活方式使用试用版本。下面是我激活的key。它有时间,数量,域名的限制。

 

8)修改index.html的ws地址

 

为什么修改?

这个地址就是服务端地址,负责把RTSP流转成websocket流。现在让118这台机器负责转流。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值