# streambridge **Repository Path**: suoten/streambridge ## Basic Information - **Project Name**: streambridge - **Description**: ๐Ÿ”Œ Single-binary streaming gateway: RTSP/RTMP/GB28181 โ†’ WebSocket-FLV/HLS/WebRTC. ่ฎฉๆ‘„ๅƒๅคดไธ€้”ฎ่ฟžไธŠๆต่งˆๅ™จใ€‚ - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-25 - **Last Updated**: 2026-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: RTSP, RTMP, GB28181, webrtc, hls ## README # StreamBridge > **One file, connect cameras to browsers** โ€” Single-binary, zero-dependency, full-protocol streaming gateway [็ฎ€ไฝ“ไธญๆ–‡](README.md) | **English** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Go Version](https://img.shields.io/badge/Go-1.22+-00ADD8.svg)](https://golang.org) [![Edition](https://img.shields.io/badge/Edition-Community-blue)](#-community-vs-enterprise-edition) [![GitHub Release](https://img.shields.io/github/v/release/suoten/streambridge?label=Release&logo=github)](https://github.com/suoten/streambridge/releases) [![GitHub Stars](https://img.shields.io/github/stars/suoten/streambridge?style=social)](https://github.com/suoten/streambridge) [![GitHub Downloads](https://img.shields.io/github/downloads/suoten/streambridge/total?label=Downloads&logo=github)](https://github.com/suoten/streambridge/releases) [![Build](https://github.com/suoten/streambridge/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/suoten/streambridge/actions) [![Gitee Release](https://img.shields.io/badge/Gitee-Release-C71D23?logo=gitee)](https://gitee.com/suoten/streambridge/releases) - ๐Ÿ™ GitHub Repository: - ๐Ÿฏ Gitee Repository (faster for users in mainland China): > ๐ŸŒŸ **If StreamBridge helps you, please [give it a Star](https://github.com/suoten/streambridge)!** ### ๐ŸŽฏ Use Cases | Scenario | Description | |------|------| | ๐Ÿ“ท Security Monitoring | Hikvision/Dahua/Uniview cameras โ†’ browser viewing | | ๐Ÿญ Industrial Visualization | Production-line cameras โ†’ dashboard display | | ๐Ÿ”— GB28181 Platform | Browser playback gateway (RTP/PS only, no SIP) | | ๐Ÿ“ฑ IoT Devices | RTSP devices โ†’ Web/MiniProgram/Android/iOS playback | | ๐ŸŽฌ Live Transcoding | RTMP push โ†’ HLS/WebRTC distribution | ### ๐Ÿ“ธ Demo Screenshots > Screenshots coming soon. After first launch, visit `http://localhost:8080` to see the actual UI. --- StreamBridge converts video streams from industrial / security cameras (RTSP / RTMP / RTP / PS) into formats that browsers can play directly (WebSocket-FLV / HLS / WebRTC). **Not a Platform**: StreamBridge does NOT include GB28181 SIP signaling, PTZ control, recording management, or ONVIF discovery โ€” these are handled by upstream platforms. StreamBridge does one thing: transcode / remux the upstream-negotiated video streams into browser-playable formats. --- ## โœจ Key Features - ๐Ÿš€ **Zero-config startup**: Download a single binary, double-click to run, ready in 5 minutes - ๐Ÿ“ฆ **Single-file deployment**: No Docker / FFmpeg / ZLMediaKit dependencies, 20+ 1080P streams on a 1C1G server - ๐Ÿ”„ **Full protocol input**: RTSP / RTMP / RTP/PS / MP4 file / HTTP-FLV / HLS - ๐Ÿ“บ **Browser-friendly**: WebSocket-FLV (recommended) / HLS / WebRTC WHEP outputs - ๐ŸŽฅ **H265 compatibility**: Built-in H265โ†’H264 software transcoding for browser H265 incompatibility - ๐Ÿ“ฑ **Full-platform SDK**: JavaScript / WeChat MiniProgram / Android / iOS, all free in Community Edition - ๐ŸŒ **Cross-platform**: Windows / Linux / macOS / Docker / K8s - ๐Ÿ”“ **Permanently free**: MIT license, commercial use allowed, no feature limitations --- ## ๐Ÿ“– Table of Contents - [Download & Install](#-download--install) - [60-Second Quick Start](#-60-second-quick-start) - [Client SDK](#-client-sdk) - [Configuration](#๏ธ-configuration) - [REST API Reference](#-rest-api-reference) - [Working with GB28181 Platforms](#-working-with-gb28181-platforms) - [Production Deployment (BaoTa / 1Panel / K8s / etc.)](#-production-deployment) - [Build from Source](#-build-from-source) - [FAQ](#-faq) - [Architecture](#-architecture) - [Community vs Enterprise Edition](#-community-vs-enterprise-edition) - [License](#-license) --- ## ๐Ÿ“ฆ Download & Install ### Option 1: Direct Binary Download (Recommended for Beginners) Open the Releases page of either repository and download the file matching your OS: | OS | Architecture | Filename | GitHub | Gitee (Faster in China) | |------|------|--------|------------|---------------------| | Windows | x86_64 | `streambridge-windows-amd64.exe` | [GitHub Release](https://github.com/suoten/streambridge/releases/latest) | [Gitee Release](https://gitee.com/suoten/streambridge/releases/latest) | | Linux | x86_64 | `streambridge-linux-amd64` | [GitHub Release](https://github.com/suoten/streambridge/releases/latest) | [Gitee Release](https://gitee.com/suoten/streambridge/releases/latest) | | Linux | ARM64 | `streambridge-linux-arm64` | [GitHub Release](https://github.com/suoten/streambridge/releases/latest) | [Gitee Release](https://gitee.com/suoten/streambridge/releases/latest) | | macOS | Apple Silicon | `streambridge-darwin-arm64` | [GitHub Release](https://github.com/suoten/streambridge/releases/latest) | [Gitee Release](https://gitee.com/suoten/streambridge/releases/latest) | > ๐Ÿ’ก **Users in mainland China: prefer Gitee** โ€” download speed is 10x faster than GitHub. No installation needed, just run it: ```bash # Linux / macOS (needs execute permission) chmod +x streambridge-linux-amd64 ./streambridge-linux-amd64 # Windows # Double-click streambridge-windows-amd64.exe โ€” a black console window will appear (do not close it) ``` ### Option 2: One-Line Command Download (For Linux Servers) ```bash # International server (GitHub) LATEST_URL=$(curl -s https://api.github.com/repos/suoten/streambridge/releases/latest \ | grep "browser_download_url.*streambridge-linux-amd64\"" \ | cut -d '"' -f 4) # China server (Gitee) # LATEST_URL=$(curl -s https://gitee.com/api/v5/repos/suoten/streambridge/releases/latest \ # | grep -oP '"browser_download_url"\s*:\s*"\K[^"]*streambridge-linux-amd64"' \ # | head -1 | tr -d '"') curl -L -o /usr/local/bin/streambridge "$LATEST_URL" chmod +x /usr/local/bin/streambridge streambridge ``` ### Option 3: Docker (For Containerized Deployment) ```bash # Quick try docker run -d --name streambridge -p 8080:8080 --restart unless-stopped \ --pull always \ suoten/streambridge:latest # Full features (with RTMP / RTP) docker run -d --name streambridge \ -p 8080:8080 -p 1935:1935 \ -p 20000-30000:20000-30000/udp \ --restart unless-stopped \ suoten/streambridge:latest ``` Image sources: - Docker Hub: `suoten/streambridge:latest` - Aliyun mirror (China): `registry.cn-hangzhou.aliyuncs.com/suoten/streambridge:latest` ### Option 4: Build from Source (Requires Go 1.22+) ```bash git clone https://github.com/suoten/streambridge.git cd streambridge make build # Current platform make build-all # Cross-compile all platforms ``` See [Build from Source](#-build-from-source) section. --- ## ๐Ÿš€ 60-Second Quick Start ### First Visit After downloading and running, open `http://localhost:8080` (local) or `http://SERVER_IP:8080` (remote) in your browser: - **Player Test Page**: Paste an RTSP URL to play - **Demo Stream Button**: Click to see a demo without a camera - **Stream List**: Active streams and viewer counts - **API Docs**: `http://localhost:8080/api/docs` ### Play a Camera for the First Time (Zero Code) 1. Open `http://localhost:8080` in your browser 2. Paste an RTSP URL (e.g., Hikvision `rtsp://admin:abc12345@192.168.1.64:554/Streaming/Channels/101`) 3. Click the "Play" button โœ… #### Common Camera RTSP URLs | Brand | Default URL | |------|---------| | Hikvision | `rtsp://admin:@:554/Streaming/Channels/101` | | Dahua | `rtsp://admin:@:554/cam/realmonitor?channel=1&subtype=0` | | Uniview | `rtsp://admin:@:554/media/video1` | | Generic ONVIF | Get from NVR | ### One-Click Diagnostics ```bash streambridge doctor # Auto-checks ports, config, browser compatibility, network reachability ``` Or visit `http://localhost:8080/doctor` in your browser. ### Health Check ```bash curl http://localhost:8080/api/health # {"status":"ok","version":"v1.0.0","uptime":123,"streams":0,"viewers":0} ``` --- ## ๐Ÿ“ฑ Client SDK Community Edition provides all-platform SDKs for free, see [sdk/README.md](sdk/README.md). | Platform | File | Playback Method | |------|------|---------| | Browser | [sdk/javascript/streambridge.js](sdk/javascript/streambridge.js) | WebSocket-FLV (MSE) / HLS / WebRTC | | WeChat MiniProgram | [sdk/wechat-miniprogram/streambridge.js](sdk/wechat-miniprogram/streambridge.js) | HLS | | Android | [sdk/android/StreamBridgeView.java](sdk/android/StreamBridgeView.java) | HLS (ExoPlayer) | | iOS | [sdk/ios/StreamBridgePlayerView.swift](sdk/ios/StreamBridgePlayerView.swift) | HLS (AVPlayer) | ### One-Line Browser Playback ```html
``` --- ## โš™๏ธ Configuration StreamBridge supports zero-config startup, or specify a config file with `-c config.yaml`. Full example at [configs/streambridge.yaml](configs/streambridge.yaml). ```yaml server: http_port: 8080 # HTTP port rtmp_port: 1935 # RTMP push port whep_port: 1985 # WebRTC signaling port bind_addr: "0.0.0.0" # Listen address log: level: info # debug | info | warn | error performance: max_streams: 500 # Max concurrent streams max_viewers_per_stream: 50 # Max viewers per stream enable_h265_transcode: false # Enable H265->H264 transcoding input: rtp: listen: "0.0.0.0" port_range: [20000, 30000] # RTP media port range mode: passive # Passive (forwarded by GB28181 platform) security: enable_auth: false # Enable Token auth secret_key: "change-me-to-random-string" allow_origins: ["*"] # CORS whitelist ``` ### Command-Line Flags ```bash streambridge # Zero-config startup streambridge -c /etc/streambridge/config.yaml # Specify config file streambridge --http-port 9090 --log-level debug streambridge doctor # Run diagnostics streambridge version # Show version ``` --- ## ๐Ÿ“ก REST API Reference ### Start Stream (Returns WebSocket/HLS URL) ```http GET /api/play?url=&format=flv ``` Response: ```json { "wsUrl": "ws://localhost:8080/ws/abc123", "streamId": "abc123", "format": "flv", "source": "rtsp://..." } ``` ### Start HLS Stream ```http GET /hls/play?url= ``` Response: ```json { "streamId": "abc123", "hlsUrl": "http://localhost:8080/hls/abc123.m3u8" } ``` ### Stop Stream ```http POST /api/stop?id= ``` ### List Active Streams ```http GET /api/streams ``` ### Health Check ```http GET /api/health ``` ### File Playback ```http POST /api/file/play Content-Type: application/json {"path": "/data/video.mp4", "loop": true} ``` ### RTP Listener (For GB28181 Integration) ```http POST /api/rtp/listen Content-Type: application/json {"port": 20000, "mode": "ps"} ``` ### Prometheus Metrics ```http GET /metrics ``` ### Full Endpoint List | Endpoint | Method | Description | |------|------|------| | `/api/health` | GET | Health check | | `/api/ready` | GET | Readiness check | | `/api/version` | GET | Version info | | `/api/play` | GET | Start stream (returns ws/flv URL) | | `/api/stop` | POST | Stop stream | | `/api/streams` | GET | Active streams list | | `/api/stats?id=` | GET | Per-stream stats | | `/api/file/play` | POST | File playback | | `/api/rtp/listen` | POST | RTP listener | | `/api/demo` | GET | Demo stream URL | | `/api/logs` | GET | Log event stream (SSE) | | `/metrics` | GET | Prometheus metrics | | `/ws/` | WS | WebSocket-FLV push | | `/live/` | GET | HTTP-FLV direct | | `/hls/.m3u8` | GET | HLS playlist | | `/hls//.ts` | GET | HLS segment | | `/whep/` | POST | WebRTC WHEP signaling | --- ## ๐Ÿ”— Working with GB28181 Platforms StreamBridge does **NOT** participate in SIP signaling / PTZ / recording. It only receives RTP/PS media forwarded by upstream platforms: ``` [Camera] โ”€โ”€SIPโ”€โ”€โ†’ [GB28181 Platform] โ”€โ”€RTP/PSโ”€โ”€โ†’ [StreamBridge] โ”€โ”€WebSocket-FLVโ”€โ”€โ†’ [Browser] โ”‚ โ””โ”€โ”€ PTZ / Intercom / Recording handled by platform ``` ### Configuration Steps 1. Enable RTP reception in StreamBridge config: ```yaml input: rtp: listen: "0.0.0.0" port_range: [20000, 30000] mode: passive ps_depacketize: true ``` 2. Configure on the GB28181 platform side: - Media server IP = StreamBridge IP - Media port range = 20000-30000 3. On platform INVITE, streams are automatically forwarded to StreamBridge, which auto-decapsulates PS โ†’ H264/AAC โ†’ FLV output. --- ## ๐Ÿญ Production Deployment StreamBridge's single binary is production-ready. Choose any of the scenarios below. ### Scenario 1: Linux systemd Service (Recommended) For Linux servers, cloud hosts, VPS โ€” auto-start on boot + auto-restart on crash. ```bash # 1. Create dedicated user sudo useradd -r -s /bin/false streambridge # 2. Prepare directories and files sudo mkdir -p /etc/streambridge /var/log/streambridge sudo cp configs/streambridge.yaml /etc/streambridge/config.yaml sudo cp bin/streambridge-linux-amd64 /usr/local/bin/streambridge sudo chown -R streambridge:streambridge /etc/streambridge /var/log/streambridge # 3. Write systemd service sudo tee /etc/systemd/system/streambridge.service > /dev/null <<'EOF' [Unit] Description=StreamBridge Gateway After=network.target [Service] Type=simple User=streambridge ExecStart=/usr/local/bin/streambridge -c /etc/streambridge/config.yaml Restart=always RestartSec=5 LimitNOFILE=65535 StandardOutput=append:/var/log/streambridge/streambridge.log StandardError=append:/var/log/streambridge/streambridge.log [Install] WantedBy=multi-user.target EOF # 4. Start and enable auto-start sudo systemctl daemon-reload sudo systemctl enable --now streambridge sudo systemctl status streambridge # Common commands sudo systemctl restart streambridge # Restart sudo systemctl stop streambridge # Stop sudo journalctl -u streambridge -f # Tail logs ``` ### Scenario 2: Windows NSSM Service (Recommended for Windows Users) For Windows Server, Windows 10/11 desktops โ€” auto-start after reboot, no accidental console closure. ```powershell # 1. Download NSSM: https://nssm.cc/download # 2. Place nssm.exe in C:\Windows\System32\ or current directory # 3. Install service nssm install StreamBridge "C:\Program Files\StreamBridge\streambridge.exe" nssm set StreamBridge AppDirectory "C:\Program Files\StreamBridge" nssm set StreamBridge AppParameters "-c C:\Program Files\StreamBridge\config.yaml" nssm set StreamBridge AppStdout "C:\Program Files\StreamBridge\logs\stdout.log" nssm set StreamBridge AppStderr "C:\Program Files\StreamBridge\logs\stderr.log" nssm set StreamBridge AppRotateFiles 1 nssm set StreamBridge AppRotateBytes 104857600 # 4. Start nssm start StreamBridge # Common commands nssm restart StreamBridge # Restart nssm stop StreamBridge # Stop nssm remove StreamBridge # Uninstall service ``` ### Scenario 3: BaoTa Panel (BT Panel) For users of China cloud servers โ€” uses BaoTa's "Process Guardian Manager" plugin + reverse proxy, fully visual. **Step 1: Install StreamBridge** ```bash # SSH into your server and run: mkdir -p /www/wwwroot/streambridge cd /www/wwwroot/streambridge # Download binary (via Gitee) curl -L -o streambridge https://gitee.com/suoten/streambridge/releases/latest/download/streambridge-linux-amd64 chmod +x streambridge # Copy default config curl -L -o config.yaml https://gitee.com/suoten/streambridge/raw/main/configs/streambridge.yaml # Test startup ./streambridge -c config.yaml # After you see "listening on :8080", press Ctrl+C to stop ``` **Step 2: Install Process Guardian Manager in BaoTa** 1. BaoTa Panel โ†’ App Store โ†’ Search "**่ฟ›็จ‹ๅฎˆๆŠค็ฎก็†ๅ™จ** (Process Guardian Manager)" โ†’ Install 2. Open Process Guardian Manager โ†’ Add guardian process: - **Name**: `StreamBridge` - **Run User**: `root` - **Working Dir**: `/www/wwwroot/streambridge` - **Start Command**: `/www/wwwroot/streambridge/streambridge -c /www/wwwroot/streambridge/config.yaml` - **Process Count**: `1` 3. Click "Save" and start **Step 3: Configure Reverse Proxy + HTTPS (Optional, for public access)** 1. BaoTa Panel โ†’ Website โ†’ Add Site - Domain: `stream.example.com` (must resolve to your server first) - Root directory: any (can be empty) - PHP version: Pure static 2. Site Settings โ†’ Reverse Proxy โ†’ Add reverse proxy - Proxy name: `StreamBridge` - Target URL: `http://127.0.0.1:8080` - Send domain: `$host` 3. Site Settings โ†’ SSL โ†’ Let's Encrypt โ†’ Apply for free cert โ†’ Force HTTPS 4. Site Settings โ†’ Config file, add WebSocket support after `location /` (otherwise ws-flv fails): ```nginx location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # WebSocket support (REQUIRED, otherwise ws-flv won't play) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } # HLS segment cache optimization location /hls/ { proxy_pass http://127.0.0.1:8080; expires 10s; add_header Cache-Control "public"; } ``` 5. Save โ†’ Restart Nginx **Step 4: Open Firewall Ports in BaoTa** BaoTa Panel โ†’ Security โ†’ Open ports: - `8080` TCP (direct access; can close after reverse proxy is configured) - `1935` TCP (for RTMP push) - `20000-30000` UDP (for GB28181 integration) ### Scenario 4: 1Panel 1Panel is a modern open-source Linux server management panel โ€” for users who prefer a modern UI. ```bash # 1. Install 1Panel (see 1panel.cn docs) curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh ``` **Option A: Docker App Store** 1Panel โ†’ App Store โ†’ Search `StreamBridge` โ†’ Install (if listed) Or use "Containers" โ†’ "Compose" โ†’ paste the Compose file below: ```yaml version: '3.8' services: streambridge: image: suoten/streambridge:latest container_name: streambridge restart: unless-stopped ports: - "8080:8080" - "1935:1935" - "20000-30000:20000-30000/udp" volumes: - ./config.yaml:/etc/streambridge/config.yaml:ro - ./logs:/var/log/streambridge ``` **Option B: Binary + systemd** Follow [Scenario 1: Linux systemd Service](#scenario-1-linux-systemd-service-recommended). 1Panel coexists with systemd; 1Panel mainly provides visual log/file viewing and Nginx reverse proxy. **1Panel Reverse Proxy Configuration** 1Panel โ†’ Websites โ†’ Create Website โ†’ Reverse Proxy - Primary Domain: `stream.example.com` - Proxy Address: `http://127.0.0.1:8080` - Enable HTTPS: auto-apply Let's Encrypt cert - Advanced Settings โ†’ Custom Nginx config: add the WebSocket upgrade config from BaoTa Scenario 3 Step 4 ### Scenario 5: Docker Compose (For Multi-Container Orchestration) ```yaml # docker-compose.yml version: '3.8' services: streambridge: image: suoten/streambridge:latest # For China servers, use Aliyun mirror: # image: registry.cn-hangzhou.aliyuncs.com/suoten/streambridge:latest container_name: streambridge restart: unless-stopped ports: - "8080:8080" - "1935:1935" - "20000-30000:20000-30000/udp" volumes: - ./config.yaml:/etc/streambridge/config.yaml:ro - ./logs:/var/log/streambridge healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:8080/api/health"] interval: 30s timeout: 5s retries: 3 ``` ```bash docker compose up -d # Start docker compose logs -f # View logs docker compose restart # Restart docker compose down # Stop and remove ``` ### Scenario 6: Kubernetes (For Cluster Deployment) ```yaml # k8s-deploy.yaml apiVersion: v1 kind: Namespace metadata: name: streambridge --- apiVersion: apps/v1 kind: Deployment metadata: name: streambridge namespace: streambridge spec: replicas: 1 selector: matchLabels: app: streambridge template: metadata: labels: app: streambridge spec: containers: - name: streambridge image: suoten/streambridge:latest ports: - containerPort: 8080 name: http - containerPort: 1935 name: rtmp - containerPort: 1985 name: whep resources: requests: cpu: "500m" memory: "512Mi" limits: cpu: "4000m" memory: "4Gi" readinessProbe: httpGet: path: /api/ready port: 8080 initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: httpGet: path: /api/health port: 8080 initialDelaySeconds: 15 periodSeconds: 20 --- apiVersion: v1 kind: Service metadata: name: streambridge namespace: streambridge spec: type: ClusterIP selector: app: streambridge ports: - name: http port: 8080 targetPort: 8080 - name: rtmp port: 1935 targetPort: 1935 - name: whep port: 1985 targetPort: 1985 ``` ```bash kubectl apply -f k8s-deploy.yaml kubectl get pods -n streambridge kubectl logs -f deploy/streambridge -n streambridge ``` With Ingress: ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: streambridge namespace: streambridge annotations: nginx.ingress.kubernetes.io/proxy-read-timeout: "86400" nginx.ingress.kubernetes.io/proxy-send-timeout: "86400" nginx.ingress.kubernetes.io/websocket-services: streambridge spec: rules: - host: stream.example.com http: paths: - path: / pathType: Prefix backend: service: name: streambridge port: number: 8080 ``` ### Scenario 7: PM2 Process Manager (For Node.js Users) PM2 is a cross-platform process manager, works on Windows / Linux / macOS โ€” no service file needed. ```bash # 1. Install PM2 (requires Node.js) npm install -g pm2 # 2. Start StreamBridge pm2 start ./streambridge --name streambridge -- -c config.yaml # 3. Enable auto-start on boot pm2 save pm2 startup # Linux/macOS: auto-generates systemd / launchd service # Windows requires extra: npm install -g pm2-windows-startup && pm2-startup install # Common commands pm2 status # Show status pm2 logs streambridge # View logs pm2 restart streambridge # Restart pm2 stop streambridge # Stop pm2 delete streambridge # Remove ``` ### Scenario 8: Supervisor Process Manager (For Python Users) ```bash # 1. Install Supervisor sudo apt install -y supervisor # Debian/Ubuntu # sudo yum install -y supervisor # CentOS/RHEL # 2. Write config sudo tee /etc/supervisor/conf.d/streambridge.conf > /dev/null <<'EOF' [program:streambridge] command=/usr/local/bin/streambridge -c /etc/streambridge/config.yaml directory=/etc/streambridge user=streambridge autostart=true autorestart=true startsecs=5 stopwaitsecs=10 stdout_logfile=/var/log/streambridge/supervisor.log stdout_logfile_maxbytes=100MB stdout_logfile_backups=7 redirect_stderr=true EOF # 3. Start sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl status streambridge ``` ### Scenario 9: Nginx Reverse Proxy + HTTPS (Manual Config) For users without BaoTa / 1Panel โ€” direct Nginx: ```nginx server { listen 443 ssl http2; server_name stream.example.com; ssl_certificate /etc/letsencrypt/live/stream.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/stream.example.com/privkey.pem; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } # WebSocket-FLV (REQUIRED, otherwise ws-flv won't play) location /ws/ { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } # HLS segment cache optimization location /hls/ { proxy_pass http://127.0.0.1:8080; expires 10s; add_header Cache-Control "public"; } } # Force HTTP โ†’ HTTPS redirect server { listen 80; server_name stream.example.com; return 301 https://$host$request_uri; } ``` Apply for a free cert (Let's Encrypt): ```bash sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d stream.example.com ``` ### Scenario 10: Caddy Reverse Proxy (Automatic HTTPS) Caddy automatically obtains and renews HTTPS certificates โ€” simplest config: ```caddyfile # /etc/caddy/Caddyfile stream.example.com { reverse_proxy 127.0.0.1:8080 # WebSocket is auto-supported, no extra config needed # HLS cache (optional) @hls path /hls/* handle @hls { reverse_proxy 127.0.0.1:8080 header Cache-Control "public" expire 10s } } ``` ```bash sudo systemctl reload caddy ``` ### Firewall Port Reference | Port | Protocol | Purpose | Required? | |------|------|------|---------| | 8080 | TCP | HTTP / WebSocket | โœ… Required | | 443 | TCP | HTTPS (with reverse proxy) | Recommended for public | | 1935 | TCP | RTMP push | For RTMP usage | | 1985 | TCP | WebRTC WHEP | For WebRTC usage | | 20000-30000 | UDP | RTP/PS reception | For GB28181 integration | ### Deployment Scenario Selection Guide | Scenario | Recommended For | Difficulty | |------|---------|---------| | Windows NSSM | Windows desktop / Server users | โญ | | Linux systemd | Linux server ops | โญโญ | | BaoTa Panel | China cloud servers, visual console fans | โญโญ | | 1Panel | Modern UI console fans | โญโญ | | Docker / Compose | Containerized deployment, CI/CD | โญโญ | | Kubernetes | Large-scale clusters, DevOps teams | โญโญโญโญ | | PM2 | Node.js full-stack users | โญ | | Supervisor | Python full-stack users | โญโญ | | Nginx / Caddy Reverse Proxy | HTTPS edge for any scenario | โญโญ | --- ## ๐Ÿ”ง Build from Source ### Requirements - Go 1.22+ (download: ) ### Build ```bash # Current platform make build # Cross-compile all platforms make build-all # Docker image make docker # Output goes to bin/ directory ``` ### Run Tests ```bash make test make lint ``` ### Project Structure ``` StreamBridge/ โ”œโ”€โ”€ cmd/streambridge/ # Entry point (main.go, CLI) โ”œโ”€โ”€ internal/ โ”‚ โ”œโ”€โ”€ config/ # Config parsing & CLI flags โ”‚ โ”œโ”€โ”€ input/ # Input protocol adapter layer โ”‚ โ”‚ โ”œโ”€โ”€ rtsp/ # RTSP client (gortsplib v4) โ”‚ โ”‚ โ”œโ”€โ”€ rtmp/ # RTMP client โ”‚ โ”‚ โ”œโ”€โ”€ rtp/ # RTP/PS receiver & depacketizer โ”‚ โ”‚ โ”œโ”€โ”€ file/ # File playback โ”‚ โ”‚ โ””โ”€โ”€ http/ # HTTP-FLV / HLS input passthrough โ”‚ โ”œโ”€โ”€ media/ # Media processing layer โ”‚ โ”‚ โ”œโ”€โ”€ flv/ # FLV muxer โ”‚ โ”‚ โ”œโ”€โ”€ hls/ # HLS slicer โ”‚ โ”‚ โ”œโ”€โ”€ h264.go # H264 NALU parsing โ”‚ โ”‚ โ”œโ”€โ”€ h265.go # H265 NALU parsing โ”‚ โ”‚ โ””โ”€โ”€ aac.go # AAC handling โ”‚ โ”œโ”€โ”€ server/ # HTTP/WS server โ”‚ โ”‚ โ”œโ”€โ”€ web/ # Embedded static assets (player pages) โ”‚ โ”‚ โ”œโ”€โ”€ http.go # Routing & REST API โ”‚ โ”‚ โ””โ”€โ”€ flv_writer.go # FLV writer โ”‚ โ”œโ”€โ”€ session/ # Session management (muxing / auth / stats) โ”‚ โ””โ”€โ”€ webrtc/ # WebRTC WHEP implementation โ”œโ”€โ”€ sdk/ # Client SDK (all platforms) โ”‚ โ”œโ”€โ”€ javascript/ โ”‚ โ”œโ”€โ”€ wechat-miniprogram/ โ”‚ โ”œโ”€โ”€ android/ โ”‚ โ””โ”€โ”€ ios/ โ”œโ”€โ”€ configs/ # Config examples โ”œโ”€โ”€ Dockerfile # Containerization โ”œโ”€โ”€ Makefile # Build scripts โ””โ”€โ”€ go.mod ``` --- ## โ“ FAQ ### Q1: Browser can't open after startup? - Check if port 8080 is in use: `streambridge doctor` - Windows users: check if firewall is blocking - Linux/macOS: ports below 80 require `sudo` - Cloud servers: open port 8080 in security groups ### Q2: Black screen / stuttering when playing RTSP? - Verify the RTSP URL is correct (test with VLC) - Ensure network reachability between camera and StreamBridge server - For H265 streams, enable `enable_h265_transcode: true` (consumes CPU) - Check logs: `streambridge --log-level debug` ### Q3: How many concurrent streams can it handle? - 1C1G server: 20+ 1080P streams (pure remuxing) - 4C8G server: 200+ 1080P streams (pure remuxing) - With H265 transcoding: ~1 CPU core per stream (software encoding) - For large-scale (โ‰ฅ100 H265 transcodes), consider Enterprise GPU hardware transcoding ### Q4: Can it be accessed over the public internet? Yes. Recommended to configure Nginx + HTTPS, see [Production Deployment](#-production-deployment). ### Q5: Does it support H265? - Browsers have poor MSE H265 compatibility - StreamBridge Community Edition has built-in H265โ†’H264 software transcoding (off by default) - Enable with: `enable_h265_transcode: true` ### Q6: How is it different from ZLMediaKit? - ZLMediaKit is a comprehensive streaming platform โ€” more features but complex deployment - StreamBridge focuses on "protocol conversion + browser playback", single binary, zero dependencies - StreamBridge does **NOT** do SIP / PTZ / recording / ONVIF โ€” those are upstream platform's job ### Q7: Can it be used for live streaming / SaaS? Yes, but for live scenarios we recommend: - Configure HLS output (3-10s latency, but best compatibility) - Public deployment with Nginx + HTTPS - For large scale, consider Enterprise cluster HA ### Q8: Is commercial use free? Community Edition is **permanently free, MIT license, commercial use allowed**. Enterprise Edition only provides scale/compliance/support features โ€” no feature crippling. ### Q9: WebSocket-FLV playback fails after BaoTa / 1Panel reverse proxy? Reverse proxy config MUST include WebSocket upgrade headers (`Upgrade` / `Connection`). See the Nginx config in [Scenario 3: BaoTa Panel](#scenario-3-baota-panel-bt-panel) Step 4. ### Q10: How to upgrade? - Binary: re-download the new binary, replace the old file, restart service - Docker: `docker compose pull && docker compose up -d` - systemd: `sudo systemctl restart streambridge` - Config files are backward compatible โ€” no need to modify on upgrade ### Q11: How to uninstall? - Binary: stop service โ†’ delete binary and config directory - Docker: `docker compose down -v` - systemd: `sudo systemctl disable --now streambridge && sudo rm /etc/systemd/system/streambridge.service && sudo systemctl daemon-reload` --- ## ๐Ÿ—๏ธ Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ StreamBridge Gateway โ”‚ โ”‚ Single Binary ยท Zero External Dependencies โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ GB28181 Platform / NVR / Camera / Live Push โ”‚ โ”‚ โ”‚ โ”‚ (Upstream handles SIP/PTZ/Recording; โ”‚ โ”‚ โ”‚ โ”‚ StreamBridge does NOT participate) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ Media Stream โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Input Protocol Adapter Layer โ”‚ โ”‚ โ”‚ โ”‚ RTSP Client โ”‚ RTMP Server โ”‚ RTP/PS โ”‚ File โ”‚ HLS โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Unified Media Processing Layer โ”‚ โ”‚ โ”‚ โ”‚ H264/H265 NALU Parsing โ”‚ AAC Extract โ”‚ H265โ†’264 โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Output Muxer Layer โ”‚ โ”‚ โ”‚ โ”‚ WebSocket-FLV โ”‚ HLS Slicing โ”‚ WebRTC WHEP โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ Browser / MiniProgram / Android / iOS โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Key Designs 1. **Unified Media Model**: All input protocols are demuxed into a unified `media.Frame`; output layer doesn't care about input source 2. **Stream Multiplexing**: Multiple browsers viewing the same source only pull 1 input โ€” saves bandwidth 3. **Zero-Copy Forwarding**: H264 streams are not re-encoded โ€” directly remuxed to FLV, very low CPU 4. **Embedded Static Assets**: Web player pages are embedded into the binary via `embed.FS` โ€” true single-file deployment --- ## ๐Ÿ’Ž Community vs Enterprise Edition | Category | Community (Free) | Enterprise (Paid) | |------|--------------|--------------| | Protocol Conversion | โœ… All | โœ… All | | H264/H265 Processing | โœ… Software transcoding | โœ… + GPU hardware transcoding (NVENC/QSV) | | Client SDK | โœ… All platforms | โœ… All platforms | | REST API | โœ… Full | โœ… Full | | Single-Node Concurrency | โœ… 200+ streams | โœ… Cluster HA (thousands) | | Transport Encryption | TLS/HTTPS | + National Crypto SM4 / HLS DRM | | Monitoring & Alerting | Prometheus metrics | + Grafana dashboard + alerts | | Operation Audit | Basic logs | + Full audit reports | | Commercial Support | Community issues | 7x24 SLA + dedicated engineer | > Community Edition is fully functional, no feature crippling, can be used commercially standalone. Enterprise Edition only provides "scale, compliance, support" capabilities. --- ## ๐Ÿค Contributing & Feedback - File Issues: - GitHub: - Gitee: - Submit Pull Requests: Bug fixes and new features welcome โ€” please discuss in an Issue first --- ## ๐Ÿ“„ License [MIT License](LICENSE) - Community Edition is permanently free, commercial use allowed. Copyright (c) 2026 StreamBridge Contributors