A lightweight open-source video cloud based on Nodejs, SRS, FFmpeg, WebRTC, etc.
- Getting Started.
- Live Streaming.
- Realtime SRT Streaming.
- DVR to Cloud Storage or VoD.
- Support WordPress Plugin or here.
- Support Typecho Plugin.
- Support aaPanel to install on any linux.
- Support DVR to local disk.
- Support Virtual Live Streaming.
- Automatical HTTPS.
- Dashboard by Prometheus.
Other more use scenarios is on the way, please read this post.
The architecture of srs-cloud by mermaid
flowchart LR;
nginx --> mgmt(mgmt<br/>by nodejs);
mgmt --> SRS --> Hooks(platform/hooks) --> StreamAuth & DVR & VoD;
DVR --> COS;
mgmt --> FFmpeg(platform/ffmpeg);
mgmt --- platform;
SRS --- FFmpeg(platform/ffmpeg);
mgmt --> Upgrade --> Release;
mgmt --> TencentCloud(platform/TencentCloud) --> CAM[CAM/COS/VoD];
mgmt --> Prometheus --- NodeExporter;
mgmt --> Docker;
mgmt --> Env[(.env<br/>credentials.txt)];
mgmt --> Redis[(Redis KV)];
Note: It's a single node, also light-weighted, video cloud for tiny company, personal user and starter.
flowchart LR;
nginx --> mgmt(mgmt<br/>by nodejs);
aaPanel --> mgmt;
aaPanel --> nginx;
Note: This is an optional workflow for user to use aaPanel to deploy srs-cloud.
The ports allocated:
| Module | TCP Ports | UDP Ports | Notes |
|---|---|---|---|
| SRS | 1935, 1985, 8080, 8088, 1990, 554, 8936 |
8000, 8935, 10080, 1989 |
See SRS ports |
| platform | 2024 | - | Mount at /terraform/v1/mgmt/, /terraform/v1/hooks/, /terraform/v1/ffmpeg/ and /terraform/v1/tencent/ |
| releases | 2023 | - | Mount at /terraform/v1/releases |
| mgmt | 2022 | - | Mount at /mgmt/ and /terraform/v1/mgmt/ |
| node-exporter | 9100 | - | - |
| redis | 56379 | - | - |
Note: Hooks(2021) has been migrated to platform(2024).
Note: FFmpeg(2019) has been migrated to platform(2024).
Note: TencentCloud(2020) has been migrated to platform(2024).
The features that we're developing:
- A mgmt support authentication and automatic updates.
- Run SRS in docker, query status by docker and SRS API.
- Support publish by RTMP/WebRTC, play by RTMP/HTTP-FLV/HLS/WebRTC.
- SRS container use docker logs
json-fileand rotate for logging. - Support high-resolution and realtime(200~500ms) live streaming by SRT.
- Run SRS hooks in docker, to callback by SRS server.
- Support publish by SRT, play by RTMP/HTTP-FLV/HLS/WebRTC/SRT.
- Support DVR to tencent cloud storage, see #1193.
- Change redis port and use randomly password.
- Support integrity with tencent cloud VoD.
- Forward stream to multiple platforms, see #2676.
- Support WordPress Plugin or here.
- Support Typecho Plugin.
- Support aaPanel to install on any linux.
- Support DVR to local disk.
- Support upgrade to latest version manually.
- Support HTTPS by let's encrypt with certbot.
- Support GB28181 by SRS 5.0 container.
- Support live streaming transcoding by FFmpeg, see #2869.
- Support virtual live streaming, covert file or other resource to live.
- Support WebRTC face to face chat, see #2857.
- Support WebRTC video chat room, see #2924.
- Support a set of tools for developer, see #2891.
- Collect logs of mgmt and containers together.
- Stop, restart and upgrade containers.
- Support logrotate to manage the logs.
- Enhance prometheus API with authentication.
- Integrate with prometheus and node-exporter.
Mgmt:
/terraform/v1/host/versionsPublic version api./terraform/v1/host/execExec command sync, response the stdout and stderr./terraform/v1/releasesVersion management for all components.
Platform:
/terraform/v1/mgmt/versionsPublic version api./terraform/v1/mgmt/initWhether mgmt initialized./terraform/v1/mgmt/checkCheck whether system is ok./terraform/v1/mgmt/tokenSystem auth with token./terraform/v1/mgmt/loginSystem auth with password./terraform/v1/mgmt/statusQuery the version of mgmt./terraform/v1/mgmt/envsQuery the envs of mgmt./terraform/v1/mgmt/containersQuery and upgrade SRS container./terraform/v1/mgmt/bilibiliQuery the video information./terraform/v1/mgmt/beian/queryQuery the beian information./terraform/v1/mgmt/beian/updateUpdate the beian information./terraform/v1/mgmt/secret/queryQuery the api secret for OpenAPI./terraform/v1/mgmt/secret/tokenCreate token for OpenAPI./terraform/v1/mgmt/nginx/hlsUpdate NGINX config, to enable HLS delivery./terraform/v1/mgmt/upgradeUpgrade the mgmt to latest version.
Also by platform module:
/terraform/v1/hooks/srs/verifyHooks: Verify the stream request URL of SRS./terraform/v1/hooks/srs/secret/queryHooks: Query the secret to generate stream URL./terraform/v1/hooks/srs/secret/updateHooks: Update the secret to generate stream URL./terraform/v1/hooks/srs/secret/disableHooks: Disable the secret for authentication./terraform/v1/hooks/srs/hlsHooks: Handle theon_hlsevent./terraform/v1/hooks/record/queryHooks: Query the Record pattern./terraform/v1/hooks/record/applyHooks: Apply the Record pattern./terraform/v1/hooks/record/removeHooks: Remove the Record files./terraform/v1/hooks/record/filesHooks: List the Record files./terraform/v1/hooks/record/hls/:uuid.m3u8Hooks: Generate HLS/m3u8 url to preview or download./terraform/v1/hooks/record/hls/:uuid/index.m3u8Hooks: Serve HLS m3u8 files./terraform/v1/hooks/record/hls/:dir/:m3u8/:uuid.tsHooks: Serve HLS ts files./terraform/v1/hooks/dvr/applyHooks: Apply the DVR pattern./terraform/v1/hooks/dvr/queryHooks: Query the DVR pattern./terraform/v1/hooks/dvr/filesHooks: List the DVR files./terraform/v1/hooks/dvr/hls/:uuid.m3u8Hooks: Generate HLS/m3u8 url to preview or download./terraform/v1/hooks/vod/queryHooks: Query the VoD pattern./terraform/v1/hooks/vod/applyHooks: Apply the VoD pattern./terraform/v1/hooks/vod/filesHooks: List the VoD files./terraform/v1/hooks/vod/hls/:uuid.m3u8Hooks: Generate HLS/m3u8 url to preview or download./terraform/v1/tencent/cam/secretTencent: Setup the CAM SecretId and SecretKey./terraform/v1/ffmpeg/forward/secretFFmpeg: Setup the forward secret to live streaming platforms./terraform/v1/ffmpeg/forward/streamsFFmpeg: Query the forwarding streams.
Market:
/api/SRS: HTTP API of SRS media server./rtc/SRS: HTTP API for WebERTC of SRS media server./*/*.(flv|m3u8|ts|aac|mp3)SRS: Media stream for HTTP-FLV, HLS, HTTP-TS, HTTP-AAC, HTTP-MP3.
Static Files:
/tools/A set of H5 tools, like simple player, xgplayer, etc, serve by mgmt./console/The SRS console, serve by mgmt./players/The SRS player, serve by mgmt./mgmt/The ui for mgmt, serve by mgmt.
Removed API:
/terraform/v1/mgmt/strategyToggle the upgrade strategy./prometheusPrometheus: Time-series database and monitor./terraform/v1/mgmt/nginx/proxySetup a reverse proxy location./terraform/v1/mgmt/dns/lbHTTP-DNS for hls load balance./terraform/v1/mgmt/dns/backend/updateHTTP-DNS: Update the backend servers for hls load balance./terraform/v1/mgmt/nginx/homepageSetup the homepage redirection./terraform/v1/mgmt/window/queryQuery the upgrade time window./terraform/v1/mgmt/window/updateUpdate the upgrade time window./.well-known/acme-challenge/HTTPS verify mount for letsencrypt./terraform/v1/mgmt/sslConfig the system SSL config./terraform/v1/mgmt/letsencryptConfig the let's encrypt SSL./terraform/v1/mgmt/pubkeyUpdate the access for platform administrator pubkey.
The software we depend on:
- Docker,
apt-get install -y docker.io- Redis,
apt-get install -y redis - Nginx,
apt-get install -y nginx- SSL:
mgmt/containers/ssl
- SSL:
- Redis,
- Certbot,
docker --name certbot- Verify webroot:
mgmt/containers/www/.well-known/acme-challenge/ - Cert files:
mgmt/containers/etc/letsencrypt/live/
- Verify webroot:
- SRS,
docker --name srs-server- Config:
mgmt/containers/conf/srs.confmount as/usr/local/srs/conf/lighthouse.conf - Volume:
mgmt/containers/objs/nginx/htmlmount as/usr/local/srs/objs/nginx/html
- Config:
- srs-hooks,
docker --name srs-hooks- Volume:
mgmt/containers/objs/nginx/htmlmount as/usr/local/mgmt/containers/objs/nginx/html
- Volume:
- tencent-cloud,
docker --name tencent-cloud- CAM Authentication by secretId and secretKey.
- ffmpeg,
docker --name ffmpeg- FFmpeg and ffprobe tools in
ossrs/srs:node-av
- FFmpeg and ffprobe tools in
The optional environments defined by mgmt/.env:
MGMT_PASSWORD: The mgmt administrator password.CLOUD: The cloud platform name, DEV for development.REGION:ap-guangzhou|ap-singapore|sgp1, The region for upgrade source.SOURCE:github|gitee, The source code for upgrading.REGISTRY:docker.io|registry.cn-hangzhou.aliyuncs.com, The docker registry.MGMT_LISTEN: The listen port for mgmt HTTP server. Default: 2022PLATFORM_LISTEN: The listen port for platform HTTP server. Default: 2024SRS_DOCKERIZED:true|falseIndicates the OS is in docker.
For mgmt to start platform in docker, because it can't access redis which is started by platform:
PLATFORM_DOCKER: Whether run platform in docker. Default: trueMGMT_DOCKER: Whether run mgmt in docker. Default: false
For testing the specified service:
NODE_ENV:development|production, if development, use local redis; otherwise, usemgmt.srs.localin docker.LOCAL_RELEASE:true|false, whether use local release service.
For github actions to control the containers:
SRS_DOCKER:srsto enfore useossrs/srsdocker image.USE_DOCKER:true|false, if false, disable all docker containers.SRS_UTEST:true|false, if true, running in utest mode.
For mgmt and containers to connect to redis:
REDIS_PASSWORD: The redis password.REDIS_PORT: The redis port.
Environments for react ui:
PUBLIC_URL: The mount prefix.BUILD_PATH: The output build path, default tobuild.REACT_APP_LOCALE: The i18n config for ui,enorzh, default tozh.
Note: The env for react must start with
REACT_APP_, please read this post.
Removed variables in .env:
SRS_PLATFORM_SECRET: The mgmt api secret for token generating and verifying.
Please restart service when .env changed.
Run srs-cloud in one docker:
docker run --rm -it -p 2022:2022 -p 1935:1935/tcp -p 1985:1985/tcp \
-p 8080:8080/tcp -p 8000:8000/udp -p 10080:10080/udp \
ossrs/srs-cloud:platform-1Then open http://localhost:2022/mgmt in browser.
All data will be reset when restarting, so please mount volumes if want to save data to local disk:
docker run --rm -it -p 2022:2022 -p 1935:1935/tcp -p 1985:1985/tcp \
-p 8080:8080/tcp -p 8000:8000/udp -p 10080:10080/udp \
-v $HOME/db:/data ossrs/srs-cloud:platform-1The volumes for srs-cloud:
/dataThe global data directory.redisThe redis data directory, the publish secret and record configuration.srs-cloudThe data directory for srs-cloudconfigThe mgmt password and cloud configuration.recordThe record storage directory, save record files.vliveThe storage directory for virtual live, save video files.
You can change the volumes to other directories.
Start redis by brew:
brew services start redisStart SRS in macOS:
(cd platform && ~/git/srs/trunk/objs/srs -c containers/conf/srs.release-local.conf)Run the mgmt backend, or run in GoLand:
(cd mgmt && bash auto/init_global && PLATFORM_DOCKER=false go run .)
Run the platform backend, or run in GoLand:
(cd platform && go run .)
Run the platform react ui, or run in WebStorm:
(cd platform/ui && npm install && npm start)
Access the browser: http://localhost:3000
Run srs-cloud in a docker.
First, build image:
docker build -t platform-dev -f platform/Dockerfile.dev .Then start the development docker:
docker run --rm -it -p 2022:2022 -p 2024:2024 --name platform \
-v $(pwd):/usr/local/srs-cloud -v $HOME/db:/data \
--add-host redis:127.0.0.1 --env REDIS_HOST=127.0.0.1 --add-host mgmt.srs.local:127.0.0.1 \
--env CLOUD=DOCKER --env MGMT_DOCKER=true --env SRS_DOCKERIZED=true --env NODE_ENV=development \
-p 1935:1935/tcp -p 1985:1985/tcp -p 8080:8080/tcp -p 8000:8000/udp -p 10080:10080/udp \
platform-dev bashStart redis and SRS only in docker:
bash auto/init_mgmt && bash auto/start_redis && bash auto/start_srsBuild and run mgmt only in docker:
cd /usr/local/srs-cloud/mgmt && make && ./mgmtBuild and run platform only in docker:
docker exec -it platform bash -c 'make && ./platform'Stop redis and SRS:
docker exec -it platform bash -c 'bash auto/stop_redis && bash auto/stop_srs'It's the same as production online.
Release bugfix:
- For mgmt:
./auto/mgmt_platform_pub.sh - Then test the specified version of mgmt.
- Finally, run
./auto/releases_pub.shif test ok.
Note: The features might need to be updated.
Release version for BT and aaPanel:
- MUST update the version manually in
auto/bt_aapanel_pub.sh,scripts/setup-bt/info.jsonandscripts/setup-aapanel/info.json - Then run
./auto/bt_aapanel_pub.sh - Finally, download bt-srs_cloud.zip then submit to bt.cn
To refresh current tag for mgmt:
- Run
./scripts/refresh-current-tag.sh
Note: It does not update the tag for release.
Release stable version:
- MUST update the stable version manually in
releases/version.go - Then run
./auto/releases_pub.sh
Note: We disable the upgrade feature, so should never update the stable version.
2022.11