RTSPtoWeb 可将您的 RTSP 流转换为 Web 浏览器支持的格式,如 MSE(媒体源扩展)、WebRTC 或 HLS。它完全基于原生 Golang 开发,不依赖 FFmpeg 或 GStreamer!
$ git clone https://github.com/deepch/RTSPtoWeb
$ cd RTSPtoWeb/
$ GO111MODULE=on go run *.go
open web browser http://127.0.0.1:8083 work chrome, safari, firefox
$ docker run --name rtsp-to-web --network host ghcr.io/deepch/rtsptoweb:latest
open web browser http://127.0.0.1:8083 in chrome, safari, firefox
您可以覆盖配置文件 /PATH_TO_CONFIG/config.json 并作为 Docker 卷挂载:
$ docker run --name rtsp-to-web \
-v /PATH_TO_CONFIG/config.json:/config/config.json \
--network host \
ghcr.io/deepch/rtsptoweb:latest
debug - 启用调试输出
log_level - 日志级别(trace、debug、info、warning、error、fatal 或 panic)
http_demo - 提供静态文件服务
http_debug - 调试 HTTP API 服务器
http_auth - 为 HTTP 演示 GUI 启用或禁用 HTTP 基本认证
http_login - HTTP 认证用户名
http_password - HTTP 认证密码
http_port - HTTP 服务器端口
http_dir - 静态文件服务路径
ice_servers - STUN/TURN 服务器数组
ice_username - STUN/TURN 用户名
ice_credential - STUN/TURN 凭证
ice_candidates - 手动设置 ICE 候选地址
webrtc_port_min - WebRTC 最小端口(UDP)
webrtc_port_max - WebRTC 最大端口(UDP)
https - HTTPS 配置
https_auto_tls - 自动 TLS 配置
https_auto_tls_name - 自动 TLS 名称
https_cert - HTTPS 证书路径
https_key - HTTPS 密钥路径
https_port - HTTPS 服务器端口
rtsp_port - RTSP 服务器端口
name - 流名称
name - 通道名称
url - 通道 RTSP URL
on_demand - 流模式:static(始终运行)或 ondemand(仅在有查看器时运行)
debug - 启用调试输出(RTSP 客户端)
audio - 启用音频
status - 默认流状态
1 - 启用配置
"token": {
"enable": true,
"backend": "http://127.0.0.1/file.php"
}
2 - 尝试访问
rtsp://127.0.0.1:5541/demo/0?token=you_key
file.php 需要返回 JSON:
status: "1" or "0"
{
"server": {
"debug": true,
"log_level": "info",
"http_demo": true,
"http_debug": false,
"http_auth": true,
"http_login": "demo",
"http_password": "demo",
"http_port": ":8083",
"ice_servers": ["stun:stun.l.google.com:19302"],
"rtsp_port": ":5541"
},
"streams": {
"demo1": {
"name": "test video stream 1",
"channels": {
"0": {
"name": "ch1",
"url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
"on_demand": true,
"debug": false,
"audio": true,
"status": 0
},
"1": {
"name": "ch2",
"url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
"on_demand": true,
"debug": false,
"audio": true,
"status": 0
}
}
},
"demo2": {
"name": "test video stream 2",
"channels": {
"0": {
"name": "ch1",
"url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
"on_demand": true,
"debug": false,
"status": 0
},
"1": {
"name": "ch2",
"url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
"on_demand": true,
"debug": false,
"status": 0
}
}
}
},
"channel_defaults": {
"on_demand": true
}
}
./RTSPtoWeb --help
Usage of ./RTSPtoWeb:
-config string
config patch (/etc/server/config.json or config.json) (default "config.json")
-debug
set debug mode (default true)
参见 API 文档
支持的视频编解码器:H264 所有配置文件
支持的音频编解码器:无
CPU usage ≈0.2%-1% one (thread) core cpu intel core i7 per stream
另请参见参与本项目的 https://github.com/deepch/RTSPtoWeb/contributors 列表。
本项目已获得许可。许可证详情参见 LICENSE.md 文件
https://github.com/pion/webrtc 遵循 MIT 许可证 https://raw.githubusercontent.com/pion/webrtc/master/LICENSE%E3%80%82
https://github.com/nareix/joy4 遵循 MIT 许可证 https://raw.githubusercontent.com/nareix/joy4/master/LICENSE%E3%80%82
Golang 视频处理相关示例
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
不支持 push
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务