开箱即用的的28181协议视频平台
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HcH0Aobk-1674895367480)(null)] [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EmrNYHcL-1674895367646)(null)] [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-40aBxGbL-1674895367515)(null)] [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-aMLQ4era-1674895369952)(null)] [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-71nGuB3y-1674895366971)(null)]
WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康、大华、宇视等品牌的IPC、NVR接入。支持国标级联,支持将不带国标功能的摄像机/直播流/直播推流转发到其他国标平台。
流媒体服务基于@夏楚 ZLMediaKit https://github.com/ZLMediaKit/ZLMediaKit
播放器使用@dexter jessibuca https://github.com/langhuihui/jessibuca/tree/v3
前端页面基于@Kyle MediaServerUI https://gitee.com/kkkkk5G/MediaServerUI 进行修改.
流媒体部署文档
一,启动Mysql,Redis
1.启动Mysql
运行mysql
$ docker pull mysql:8.0.29
docker run -p 33060:3306 --name mysql -v mysqlData:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.29
docker run -it -p 33060:3306 --name mysql -v mysqlData:/var/lib/mysql -v /root/home/zhangcn3/wvp.sql:/docker-entrypoint-initdb.d/wvp.sql -e MYSQL_ROOT_PASSWORD=root mysql:8.0.29
docker exec mysql sh -c 'exec mysqldump --databases wvp -uroot -p"$MYSQL_ROOT_PASSWORD"' > /root/wvp.sql
导入sql文件
- 创建 wvp 库
- 执行 wvp.sql 文件创建数据库表
1. $ docker run -d -p 33060:3306 --name mysql -v mysqlData:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=1qaz2wsx3edc mysql:8.0.29
2. $ docker cp /root/wvp.sql mysql:/root/
3. $ docker exec -it mysql /bin/bash
4. $ mysql -uroot -proot
5. $ create database wvp;
6. $ use wvp;
7. $ source /root/wvp.sql
8. $ ctrl + pq
9. # 删除容器,保留数据卷
docker exec -it my /bin/bash
2.配置启动Redis
$ docker pull redis:4.0.14
$ docker run --name redis -d -p 6379:6379 -v redisData:/data redis:4.0.14 redis-server --appendonly yes
二,将WVP项目构建镜像
官方镜像 https://hub.docker.com/r/648540858/wvp_pro
编写Dockerfile
FROM openjdk:8u171
WORKDIR /app
COPY ./wvp-pro-2.3.2.jar wvp-pro-2.3.2.jar
EXPOSE 18081/tcp
EXPOSE 5060/tcp
EXPOSE 5060/udp
EXPOSE 18082/tcp
ENTRYPOINT ["/bin/sh", "-c", "cd /app && java ${JAVA_OPTS} -jar wvp-pro-2.3.2.jar"]
映射配置文件构建镜像
FROM openjdk:8u171
COPY ./wvp-pro-2.3.2.jar wvp-pro-2.3.2.jar
COPY ./application.yml /data/java/config/application.yml
EXPOSE 18081/tcp
EXPOSE 5060/tcp
EXPOSE 5060/udp
EXPOSE 18082/tcp
ENTRYPOINT ["java","-jar","wvp-pro-2.3.2.jar","--spring.config.location=/data/java/config/application.yml"]
构建镜像
docker build -t hub.brain.zcn.com/wvp/wvp-pro-release:v1.0 .
运行镜像
docker run -it -P --network host --rm hub.brain.zcn.com/wvp/wvp-pro-release:v1.0
docker run -it -p 18081:18081 -p 18082:18082 -p 5060:5060 -p 5060:5060/udp --name wvp hub.brain.zcn.com/wvp/wvp-pro-release:v1.0
docker run -it -p 18081:18081 -p 18082:18082 -p 5060:5060 -p 5060:5060/udp --name wvp -e JAVA_OPTS="-Dwvp.ip=10.110.156.68 -Dwvp.mysql.ip=10.110.156.68 -Dwvp.redis.ip=10.110.156.68 -Dwvp.extranet.ip=10.110.156.68" hub.brain.zcn.com/wvp/wvp-pro-release:v1.0
使用的端口
端口 | 类型 | 描述 |
---|---|---|
6080 | tcp | zlm的http端口 |
554 | tcp&udp | zlm的rtsp端口,非必须 |
1935 | tcp | zlm的rtmp端口,非必须 |
5060 | tcp&udp | 28181 sip信令端口 |
18081 | tcp | wvp的http端口 |
18082 | tcp | 录像管理服务端口,非必须 |
30000-30500 | tcp&udp | zlm接收视频推流端口 |
摄像头视频管理平台 WVP地址:http://ip:18081/#/streamProxyList
用户名/密码:超级管理员:admin/QAZwsx123…
普通管理员:guest/guest
三.部署ZLMediaKit流媒体服务
1.获取代码
# 国内用户推荐从同步镜像网站gitee下载
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
# 千万不要忘记执行这句命令
git submodule update --init
2.构建镜像
Dockerfile
CentOs
ARG Version=7
FROM centos:${Version} As build
ARG HTTP_PROXY=${NO_PROXY}
ARG HTTPS_PROXY=${NO_PROXY}
ARG PKG_CONFIG_VERSION=0.29.2
ARG CMAKE_VERSION=3.18
ARG CMAKE_FULL_VERSION=3.18.4
ARG YASM_VERSION=1.3.0
ARG NASM_VERSION=2.15.05
ARG X265_VERSION=3.4
RUN yum install -y \
gcc \
gcc-c++ \
kernel-devel \
kernel-headers \
openssl \
openssl-devel \
git \
wget \
which
WORKDIR /opt
RUN wget --no-check-certificate -e "https_proxy=${HTTPS_PROXY}" https://pkgconfig.freedesktop.org/releases/pkg-config-${PKG_CONFIG_VERSION}.tar.gz \
&& tar -zxvf pkg-config-${PKG_CONFIG_VERSION}.tar.gz \
&& cd pkg-config-${PKG_CONFIG_VERSION} \
&& ./configure --with-internal-glib \
&& make -j8 \
&& make install
RUN wget -e "https_proxy=${HTTPS_PROXY}" https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_FULL_VERSION}.tar.gz \
&& tar -zxvf cmake-${CMAKE_FULL_VERSION}.tar.gz \
&& cd cmake-${CMAKE_FULL_VERSION} \
&& ./bootstrap \
&& gmake -j8 \
&& gmake install
RUN cd /opt \
&& wget -e "https_proxy=${HTTPS_PROXY}" http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz \
&& tar zxvf yasm-${YASM_VERSION}.tar.gz \
&& cd yasm-${YASM_VERSION} \
&& ./configure \
&& make -j8 \
&& make install
RUN wget --no-check-certificate -e "https_proxy=${HTTPS_PROXY}" https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-${NASM_VERSION}.tar.xz \
&& tar -xvJf nasm-${NASM_VERSION}.tar.xz \
&& cd nasm-${NASM_VERSION} \
&& ./configure --disable-shared --enable-static \
&& make -j8 \
&& make install
RUN cd /opt \
&& git clone https://code.videolan.org/videolan/x264.git \
&& cd x264 \
&& git checkout -b stable origin/stable \
&& git pull --rebase \
&& ./configure --enable-pic --enable-shared --disable-asm \
&& make -j8 \
&& make install \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
RUN cd /opt \
&& wget -e "https_proxy=${HTTPS_PROXY}" https://github.com/videolan/x265/archive/Release_${X265_VERSION}.tar.gz \
&& tar zxvf Release_${X265_VERSION}.tar.gz \
&& cd x265-Release_${X265_VERSION}/build/linux \
&& cmake ../../source \
&& make -j8 \
&& make install \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
RUN cd /opt \
&& git clone https://gitee.com/xia-chu/FFmpeg.git \
&& cd /opt/FFmpeg \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH \
&& ./configure \
--disable-debug \
--disable-doc \
--disable-shared \
--enable-gpl \
--enable-version3 \
--enable-static \
--enable-nonfree \
--enable-pthreads \
--enable-libx264 \
--enable-libx265 \
--enable-small \
--pkgconfigdir=/usr/local/lib/pkgconfig \
--pkg-config-flags="--static" \
&& make -j8 \
&& make install
RUN cd /opt \
&& git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit.git \
&& cd ZLMediaKit \
&& git submodule update --init \
&& mkdir -p build release/linux/Release/ \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& make -j8
RUN mkdir -p /opt/build/opt/zlm/ /opt/build/usr/local/bin/ /opt/build/usr/bin/ /opt/build/usr/local/lib/ /opt/build/etc/localtime \
&& cd /opt/build \
&& /usr/bin/cp -ip /usr/local/lib/libx26* ./usr/local/lib \
&& /usr/bin/cp -ip /usr/local/bin/ffmpeg ./usr/local/bin \
&& /usr/bin/cp -ip /opt/ZLMediaKit/release/linux/Release/MediaServer ./opt/zlm/ \
&& /usr/bin/cp -irp /opt/ZLMediaKit/release/linux/Release/www ./opt/zlm/ \
&& /usr/bin/cp -ip /usr/bin/which ./usr/bin/
## /usr/bin/cp -ip /opt/ZLMediaKit/tests/ssl.p12 ./opt/zlm/ \
FROM centos:${Version}
LABEL maintainer="chengxiaosheng <kevin__cheng@outlook.com>" project-url="https://github.com/xia-chu/ZLMediaKit" description="一个基于C++11的高性能运营级流媒体服务框架"
EXPOSE 9000/tcp \
1935/tcp \
19350/tcp \
554/tcp \
322/tcp \
80/tcp \
443/tcp \
10000/udp \
10000/tcp
WORKDIR /opt/zlm
VOLUME [ "/opt/zlm/conf/","/opt/zlm/log/","opt/zlm/ffmpeg/"]
COPY --from=build /opt/build /
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH TZ=Asia/Shanghai
CMD ./MediaServer -c ./conf/config.ini
ubuntu
FROM ubuntu:18.04
#shell,rtmp,rtsp,rtsps,http,https,rtp
EXPOSE 9000/tcp
EXPOSE 1935/tcp
EXPOSE 554/tcp
EXPOSE 322/tcp
EXPOSE 80/tcp
EXPOSE 443/tcp
EXPOSE 10000/udp
EXPOSE 10000/tcp
EXPOSE 30000-30500/tcp
EXPOSE 30000-30500/udp
RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" \
apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
curl \
vim \
ca-certificates \
tzdata \
libssl-dev \
libmysqlclient-dev \
libx264-dev \
libfaac-dev \
ffmpeg \
libmp4v2-dev && \
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /opt/media
WORKDIR /opt/media
RUN git clone --depth=1 https://gitee.com/xia-chu/ZLMediaKit && \
cd ZLMediaKit && git submodule update --init --recursive && \
mkdir -p build release/linux/Release/
WORKDIR /opt/media/ZLMediaKit/build
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \
make
ENV PATH /opt/media/ZLMediaKit/release/linux/Release:$PATH
CMD MediaServer
构建镜像
== CentOs ==
docker build -t hub.brain.lenovo.com/wvp/zlmediakit:1.0.0
== ubuntu ==
docker build -t hub.brain.lenovo.com/wvp/zlmediakit:1.0.0-ubuntu18.04
3.修改配置
config.ini
; auto-generated by mINI class {
[api]
apiDebug=1
defaultSnap=./www/logo.png
secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
snapRoot=./www/snap/
[cluster]
origin_url=
retry_count=3
timeout_sec=15
[ffmpeg]
bin=/usr/bin/ffmpeg
cmd=%s -fflags nobuffer -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s
log=./ffmpeg/ffmpeg.log
restart_sec=0
snap=%s -i %s -y -f mjpeg -t 0.001 %s
[general]
addMuteAudio=1
check_nvidia_dev=1
continue_push_ms=3000
enableVhost=0
enable_audio=1
enable_ffmpeg_log=0
flowThreshold=1024
fmp4_demand=0
hls_demand=0
maxStreamWaitMS=15000
mediaServerId=FQ3TF8yT83wh5Wvz
mergeWriteMS=0
modifyStamp=0
publishToHls=1
publishToMP4=0
resetWhenRePlay=1
rtmp_demand=0
rtsp_demand=0
streamNoneReaderDelayMS=15000
ts_demand=0
unready_frame_cache=100
wait_add_track_ms=3000
wait_track_ready_ms=3000
[hls]
broadcastRecordTs=0
deleteDelaySec=0
fileBufSize=65536
filePath=./www
segDur=2
segKeep=0
segNum=3
segRetain=5
[hook]
admin_params=secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
alive_interval=10.0
enable=1
on_flow_report=http://10.110.131.204:18081/index/hook/on_flow_report
on_http_access=http://10.110.131.204:18081/index/hook/on_http_access
on_play=http://10.110.131.204:18081/index/hook/on_play
on_publish=http://10.110.131.204:18081/index/hook/on_publish
on_record_mp4=http://127.0.0.1:18082/api/record/on_record_mp4
on_record_ts=http://10.110.131.204:18081/index/hook/on_record_ts
on_rtsp_auth=http://10.110.131.204:18081/index/hook/on_rtsp_auth
on_rtsp_realm=http://10.110.131.204:18081/index/hook/on_rtsp_realm
on_send_rtp_stopped=http://10.110.131.204:18081/index/hook/on_send_rtp_stopped
on_server_keepalive=http://10.110.131.204:18081/index/hook/on_server_keepalive
on_server_started=http://10.110.131.204:18081/index/hook/on_server_started
on_shell_login=http://10.110.131.204:18081/index/hook/on_shell_login
on_stream_changed=http://10.110.131.204:18081/index/hook/on_stream_changed
on_stream_none_reader=http://10.110.131.204:18081/index/hook/on_stream_none_reader
on_stream_not_found=http://10.110.131.204:18081/index/hook/on_stream_not_found
retry=1
retry_delay=3.0
timeoutSec=20
[http]
charSet=utf-8
dirMenu=1
forbidCacheSuffix=
forwarded_ip_header=
keepAliveSecond=30
maxReqSize=40960
notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit(git hash:00c9749,branch:master,build time:Sep 5 2022 06:45:26)</center></body></html>
port=6080
rootPath=./www
sendBufSize=65536
sslport=8443
virtualPath=
[multicast]
addrMax=239.255.255.255
addrMin=239.0.0.0
udpTTL=64
[record]
appName=record
fastStart=0
fileBufSize=65536
filePath=./www
fileRepeat=0
fileSecond=3600
mp4_as_player=0
sampleMS=500
[rtc]
externIP=
port=8000
preferredCodecA=PCMU,PCMA,opus,mpeg4-generic
preferredCodecV=H264,H265,AV1X,VP9,VP8
rembBitRate=0
timeoutSec=15
[rtmp]
handshakeSecond=15
keepAliveSecond=15
modifyStamp=0
port=1935
sslport=0
[rtp]
audioMtuSize=600
rtpMaxSize=10
videoMtuSize=1400
[rtp_proxy]
dumpDir=
g711a_pt=8
g711u_pt=0
h264_pt=98
h265_pt=99
opus_pt=100
port=10000
port_range=30000-30500
ps_pt=96
timeoutSec=15
ts_pt=33
[rtsp]
authBasic=0
directProxy=1
handshakeSecond=15
keepAliveSecond=15
port=554
sslport=0
[shell]
maxReqSize=1024
port=0
[srt]
latencyMul=4
pktBufSize=8192
port=9000
timeoutSec=5
; } ---
4.运行镜像
== CentOs ==
docker run -it -p 1935:1935 -p 6080:6080 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 9000:9000/udp -p 30000-30500:30000-30500/udp -p 30000-30500:30000-30500/tcp -v zlmConfig:/opt/zlm/conf --name zlm hub.brain.lenovo.com/wvp/zlmediakit:1.0.0
== ubuntu ==
docker run -it -p 1935:1935 -p 6080:6080 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 9000:9000/udp -p 30000-30500:30000-30500/udp -p 30000-30500:30000-30500/tcp -v zlmConfig:/opt/media/ZLMediaKit/release/linux/Release --name zlm hub.brain.lenovo.com/wvp/zlmediakit:1.0.0-ubuntu18.04
== 加授权 ==
docker run -it -p 1935:1935 -p 6080:6080 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 9000:9000/udp -p 30000-30500:30000-30500/udp -p 30000-30500:30000-30500/tcp -v zlmConfig:/opt/media/ZLMediaKit/release/linux/Release -v /root/.hasplm/hasp_33090.ini:/root/.hasplm/hasp_33090.ini --name zlm hub.brain.lenovo.com/wvp/zlmediakit:1.0.1-ubuntu18.04
四,配置摄像头
1.配置摄像头
2.配置nvr
3.级联平台配置
五,Docker compose
1.安装compose
# 2-1.修改文件名
$ mv docker-compose-Linux-x86_64 docker-compose
# 2-2.将dockedr-compose 移动到/usr/local/bin/目录下
$ mv docker-compose /usr/local/bin/
# 2-3.将docker-compose赋予执行权限
$ chmod +x /usr/local/bin/docker-compose
# 2-4.查看版本
$ docker-compose -v
2.编写 docker compose.yml
version: "3.0"
services:
mysql:
image: mysql:8.0.29
container_name: mysqls
ports:
- "33060:3306"
volumes:
- mysqlData:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 1qaz2wsx3edc
networks:
- wvp
restart: always
redis:
image: redis:4.0.14
container_name: rediss
ports:
- "6379:6379"
volumes:
- redisData:/data
command: redis-server
networks:
- wvp
restart: always
zlm:
#image: zlmediakit:latest
image: hub.brain.zcn.com/wvp/zlmediakit:1.0.0
container_name: zlms
ports:
- "1935:1935"
- "6080:6080"
- "8443:443"
- "8554:554"
- "8554:554/udp"
- "10000:10000"
- "10000:10000/udp"
- "9000:9000/udp"
- "30000-30500:30000-30500"
- "30000-30500:30000-30500/udp"
volumes:
- zlmConfig:/root/ZLMediaKit/release/linux/Debug/
networks:
- wvp
restart: always
wvp:
image: hub.brain.zcn.com/wvp/wvp-pro-release:v1.0
container_name: wvps
ports:
- "18081:18081"
- "18082:18082"
- "5060:5060"
- "5060:5060/udp"
environment:
- JAVA_OPTS:'-Dwvp.ip=10.110.131.204'
networks:
- wvp
depends_on:
- mysql
- redis
- zlm
restart: always
networks:
wvp:
volumes:
mysqlData:
external:
true
redisData:
external:
true
zlmConfig:
external:
true
lz docker-conpose
version: "3.0"
services:
mysql:
image: mysql:8.0.29
container_name: mysqls
ports:
- "33060:3306"
volumes:
- mysqlData:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
networks:
- wvp
restart: always
redis:
image: redis:4.0.14
container_name: rediss
ports:
- "6379:6379"
volumes:
- redisData:/data
command: redis-server
networks:
- wvp
restart: always
zlm:
image: zlmediakit:latest
container_name: zlms
ports:
- "1935:1935"
- "6080:6080"
- "443:443"
- "554:554"
- "554:554/udp"
- "10000:10000"
- "10000:10000/udp"
- "9000:9000/udp"
- "30000-30500:30000-30500"
- "30000-30500:30000-30500/udp"
volumes:
- /data/zlm/data/Debug:/root/ZLMediaKit/release/linux/Debug
networks:
- wvp
restart: always
wvp:
image: wvp-pro:2.3.25
container_name: wvps
ports:
- "18081:18081"
- "18082:18082"
- "5060:5060"
- "5060:5060/udp"
environment:
- JAVA_OPTS:'-Dwvp.ip=172.16.122.125'
networks:
- wvp
depends_on:
- mysql
- redis
- zlm
restart: always
networks:
wvp:
volumes:
mysqlData:
external:
true
redisData:
external:
true
zlmConfig:
external:
true
3.启动docker-compose
1. $ mkdir sip
2. $ mv /root/docker-compose.yml sip
3. # !!!---修改wvp.environment ip为本机ip--- !!!
4. $ docker-compose up -d
4.启动容器监控portainer
$ docker run -d -p 9001:9000 -v /root/portainer:/data -v /var/run/docker.sock:/var/run/docker.sock --name dev-portainer portainer/portainer
#参数说明:
-v /var/run/docker.sock:/var/run/docker.sock # 把宿主机的Docker守护进程(docker daemon)默认监听的Unix域套接字挂载到容器中
-v /root/portainer:/data # 把宿主机目录 /root/portainer 挂载到容器 /data 目录;
5.外网开放端口
服务 | 端口 | 类型 | 描述 | 必须 |
---|---|---|---|---|
wvp | 18081 | tcp | wvp的http端口 | 是 |
wvp | 5060 | tcp&udp | 28181sip信令端口 | 是 |
wvp | 18082 | tcp | 录像管理服务端口 | 是 |
zlm | 6080 | tcp | 流媒体服务的http端口 | 是 |
zlm | 1935 | tcp | 流媒体服务的rtmp端口 | 是 |
zlm | 554 | tcp&udp | 流媒体服务的rtsp端口 | 是 |
zlm | 30000-30500 多端口开放 | tcp&udp | 流媒体服务接收视频推流端口 | 是 |
zlm | 443 | tcp | 否 | |
wvp | 9001 | tcp | 查看Docker容器管理端口 | 否 |
zlm | 8000 | rtc端口 | 否 | |
zlm | 9000 | srt端口 | 否 | |
zlm | 10000 单端口开放 | tcp&udp | zlm服务器单端口收流端口 | 否 |
PS: wvp之所以不需要zlm配置这么多, 是因为wvp会在连接上zlm后,自动配置zlm. 尽量简化大家的配置. wiki更新可能不是很及时。大家可以参考all-application.yml, 里面有所有的配置项以及注释。
十,注意事项
1.外网端口必须开放多端口模式
30000~30500
2.ip配置要求
sip.ip #必须为外网IP地址,摄像头通过外网访问wvp
media.stream-ip #必须为外网IP地址,视频流通过此ip访问流媒体服务zlm
3.测试udp端口
telnet -nupl 无法测试udp端口
测试udp端口命令【需要关闭该端口的tcp】
$ nc -vuz 10.110.131.64 8080