# 海康威视摄像头
rtsp://<用户名>:<密码><摄像头ip>:554/Streaming/Channels/101
1
# 搭建媒体服务器 放在外网的服务器搭建 详细见搭建媒体服务器
const NodeMediaServer = require('node-media-server');
const config = {
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60
},
http: {
port: 8000,
allow_origin: '*'
}
};
var nms = new NodeMediaServer(config)
nms.run()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1.运行 node xx.js
1.地址访问 http://你的服务器ip:8000/admin
# 客户端推流
# 最后一步推送服务
- ffmpeg -rtsp_transport tcp -i rtsp://admin:whws@2023@173.16.8.5:554/Streaming/Channels/101 -vcodec libx264 -s 960x540 -f flv rtmp://nvr.nourse.cn:1935/live/testc
# 浏览效果
# 框架生成的admin
- 框架生成的是8000 端口需要nginx 转成443端口
- https://域名/admin/streams#
# 开启https etc->nginx->nginx.config
1.nginx.config 设置
server {
listen 443 ssl;
server_name duxinggj.com;
client_max_body_size 1000M;
ssl_certificate "./xxxx.pem"; //证书
ssl_certificate_key "./xxxx.key"; // 证书
set $node_port 8000;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on;
root /thinkjs;
set $node_port 8000;
index index.js index.html index.htm;
if ( -f $request_filename/index.html ){
rewrite (.*) $1/index.html break;
}
if ( !-f $request_filename ){
rewrite (.*) /index.js;
}
location = /index.js {
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:$node_port$request_uri;
proxy_redirect off;
}
location ~ / {
etag on;
expires max;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
命令端运行输入 nginx 启动nginx服务
# 单个页面播放html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style>
.kkmxertw{
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #000;
}
</style>
</head>
<body>
<script src="https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/abb/js/jquery-1.11.3.min.js"></script>
<script src="https://cdn.bootcss.com/flv.js/1.4.0/flv.min.js"></script>
<video id="videoElement" controls="controls" class="kkmxertw"></video>
<script>
let wenhse = window.location.search
const djsare = wenhse.split("url=")[1]
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement')
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'https://域名/live/'+djsare+'.flv'
})
flvPlayer.attachMediaElement(videoElement)
flvPlayer.load()
flvPlayer.play()
}
</script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39