LiveForge

April 14, 2026 ยท View on GitHub

LiveForge

High-performance multi-protocol live streaming server written in Go

Go License Tests

English | ไธญๆ–‡


๐Ÿ“– Wiki Documentation (EN) | ๐Ÿ“– Wiki ๆ–‡ๆกฃ (ไธญๆ–‡)

Full guides on deployment, configuration, cluster topologies, GB28181, audio transcoding, and more.


LiveForge is a modular live streaming media server that ingests, transmuxes, and delivers audio/video in real time. It supports RTMP, RTSP, SRT, WebRTC (WHIP/WHEP), HLS, LL-HLS, DASH, HTTP-FLV, FMP4, GB28181, and WebSocket streaming โ€” all from a single binary with zero external dependencies.

Highlights

FeatureDescription
๐Ÿ”€Any-to-any protocol bridgePush RTMP, pull via WebRTC; push WebRTC, pull via HLS โ€” any combination works
๐ŸŽตOn-demand audio transcodingAutomatic codec bridging (AAC โ†” Opus โ†” G.711 โ†” MP3) between protocols, powered by FFmpeg/libav
๐Ÿ“กGB28181 video surveillanceFull SIP signaling stack, device registration, live invite, playback, PTZ control, alarm handling โ€” plus a built-in device simulator for testing
๐ŸŒMulti-protocol clusterOrigin-edge cascading via RTMP / SRT / RTSP / RTP / GB28181 with HTTP scheduler callback for dynamic topology
โšกLL-HLSLow-Latency HLS with fMP4 partial segments, blocking playlist reload (_HLS_msn/_HLS_part), and delta playlist updates
๐Ÿ–ฅ๏ธWeb consoleBuilt-in real-time dashboard with stream stats, multi-protocol preview, and browser WHIP publish
๐Ÿ›ก๏ธProduction-readySlow consumer protection (EWMA frame dropping), GCC congestion control, per-IP rate limiting, Prometheus metrics

Features

Protocols

  • Multi-protocol ingest โ€” Publish via RTMP, RTSP (TCP + UDP), SRT, WebRTC WHIP, or GB28181
  • Multi-protocol playback โ€” Pull via RTMP, RTSP, SRT, WebRTC WHEP, HLS, LL-HLS, DASH, HTTP-FLV, HTTP-TS, FMP4, or WebSocket
  • SRT โ€” Secure Reliable Transport with AES encryption, low-latency MPEG-TS delivery (pure Go via datarhei/gosrt)
  • WebRTC โ€” WHIP/WHEP with ICE Lite, GCC send-side bandwidth estimation, and browser-based publish
  • Codec support โ€” H.264, H.265/HEVC, VP8, VP9, AV1, AAC, Opus, G.711 (ฮผ-law/A-law), MP3

Audio Transcoding

LiveForge transparently bridges audio codecs between protocols. When a subscriber requires a different audio codec than the publisher provides, on-demand transcoding kicks in automatically โ€” zero configuration needed.

Publisher โ†’ SubscriberCodec PathUse Case
RTMP (AAC) โ†’ WebRTC (Opus)AAC โ†’ PCM โ†’ OpusBrowser playback of RTMP streams
WebRTC (Opus) โ†’ RTMP (AAC)Opus โ†’ PCM โ†’ AACRe-stream browser input to CDN
GB28181 (G.711) โ†’ HLS (AAC)G.711 โ†’ PCM โ†’ AACSurveillance camera to web player
Any โ†’ AnyDecode โ†’ Resample โ†’ EncodeFull codec matrix supported

Transcoding is shared per target codec โ€” multiple subscribers requesting the same codec share one transcode pipeline. When the publisher's codec matches the subscriber's, frames pass through with zero overhead.

Requires FFmpeg/libav libraries at build time (CGO_ENABLED=1). See Wiki: Audio Transcoding for build instructions and details.

GB28181 Video Surveillance

Full GB/T 28181 national standard support for connecting IP cameras and NVRs:

  • SIP signaling โ€” Device registration, keepalive monitoring, digest authentication
  • Catalog query โ€” Automatic device and channel discovery
  • Live invite โ€” Server-initiated INVITE to pull live video from cameras
  • Recording playback โ€” Time-range playback of device-side recordings
  • PTZ control โ€” Pan/tilt/zoom and preset commands per GB28181 Annex A
  • Alarm handling โ€” Receive and process device alarm notifications
  • MPEG-PS demuxing โ€” RTP/PS stream receiving with H.264 + AAC extraction
  • REST API โ€” Full device/channel/session management via /api/v1/gb28181/*
  • Streams as first-class citizens โ€” GB28181 streams appear in the stream hub and can be played via any output protocol (HLS, RTMP, WebRTC, etc.)

See Wiki: GB28181 Guide for configuration and usage details.

GB28181 Device Simulator

A built-in simulator (tools/gb28181-sim) emulates a GB28181 IPC camera for acceptance testing:

# Build and run the simulator
go run ./tools/gb28181-sim -server 127.0.0.1:5060 -fps 25

# Customizable: device ID, domain, transport, keepalive, audio toggle
go run ./tools/gb28181-sim \
  -device-id 34020000001110000001 \
  -domain 3402000000 \
  -transport udp \
  -keepalive 30s \
  -no-audio

The simulator performs: SIP REGISTER โ†’ periodic keepalive โ†’ responds to catalog queries โ†’ streams RTP/PS (H.264+AAC) on INVITE โ†’ handles BYE.

Cluster

Multi-protocol forwarding and on-demand origin pull for building CDN-like topologies:

  • Forward (push) โ€” Automatically push streams to downstream nodes when published
  • Origin pull โ€” Lazily pull from upstream when a subscriber arrives, with idle timeout
  • Multi-protocol relay โ€” RTMP, SRT, RTSP, RTP, and GB28181 transports
  • HTTP scheduler โ€” Dynamic target resolution via external HTTP callback, or static target lists
  • Topologies โ€” Origin-edge, origin-multi-edge, origin-center-edge (three-tier)
  • Retry & resilience โ€” Configurable retry count, interval, and backoff

See Wiki: Cluster Deployment for topology examples and configuration.

LL-HLS (Low-Latency HLS)

Apple LL-HLS implementation for sub-second latency HLS delivery:

  • Partial segments โ€” Configurable part duration (default 200ms) for fine-grained delivery
  • Blocking playlist reload โ€” _HLS_msn and _HLS_part query parameters for server-push style updates
  • Delta playlist โ€” _HLS_skip=YES support to reduce playlist transfer size
  • fMP4 container โ€” Default fMP4 with TS fallback option
  • Legacy player compat โ€” Graceful degradation for players without LL-HLS support (buffered segment delivery)

Management & Operations

  • Web console โ€” Real-time dashboard: stream list, codecs, bitrate, FPS, GOP cache, multi-protocol preview, WebRTC browser publish
  • REST API โ€” List/inspect/delete streams, kick publishers, server stats, health checks
  • Auth โ€” JWT token verification and HTTP callback authentication for publish and subscribe
  • Recording โ€” FLV file recording with duration-based segmentation and path templates
  • Notifications โ€” HTTP webhook (HMAC-SHA256 signed) and WebSocket real-time events
  • Prometheus metrics โ€” Server-level and per-stream gauges: connections, bitrate, FPS, GOP cache, subscribers by protocol
  • Rate limiting โ€” Per-IP token bucket for connection flood protection
  • Slow consumer protection โ€” EWMA-based lag detection with progressive frame dropping
  • GCC congestion control โ€” Send-side bandwidth estimation for WebRTC WHEP with adaptive bitrate pacing
  • GOP cache โ€” New subscribers receive the latest keyframe group instantly for fast startup

Architecture

graph LR
    subgraph Ingest
        OBS[OBS / FFmpeg] -->|RTMP| RTMP_MOD[RTMP Module]
        CAM[IP Camera] -->|RTSP| RTSP_MOD[RTSP Module]
        SRT_PUB[SRT Source] -->|SRT| SRT_MOD[SRT Module]
        BROWSER_PUB[Browser] -->|WHIP| WEBRTC_MOD[WebRTC Module]
        GB_DEV[GB28181 Device] -->|SIP+RTP| GB_MOD[GB28181 Module]
    end

    subgraph Core
        RTMP_MOD --> STREAM[Stream + GOP Cache + Ring Buffer]
        RTSP_MOD --> STREAM
        SRT_MOD --> STREAM
        WEBRTC_MOD --> STREAM
        GB_MOD --> STREAM
        STREAM --> TRANSCODE[Audio Transcode Manager]
        STREAM --> MUXER[Muxer Manager]
    end

    subgraph Delivery
        MUXER -->|HLS / LL-HLS / DASH| HTTP_MOD[HTTP Stream Module]
        MUXER -->|HTTP-FLV / TS / FMP4| HTTP_MOD
        MUXER -->|WebSocket| HTTP_MOD
        STREAM -->|RTMP| RTMP_SUB[RTMP Subscriber]
        STREAM -->|RTSP| RTSP_SUB[RTSP Subscriber]
        STREAM -->|SRT| SRT_SUB[SRT Subscriber]
        TRANSCODE -->|WHEP| WEBRTC_SUB[WebRTC Subscriber]
    end

    subgraph Cluster
        STREAM -->|Forward| FWD[Forward Manager]
        FWD -->|RTMP/SRT/RTSP/RTP/GB| EDGE[Edge Nodes]
        ORIGIN[Origin Servers] -->|Pull| OPL[Origin Pull Manager]
        OPL --> STREAM
    end

    subgraph Management
        API[REST API + Web Console]
        AUTH[Auth Module]
        NOTIFY[Webhook + WS Notifications]
        RECORD[FLV Recording]
        METRICS[Prometheus Metrics]
    end

Quick Start

docker run -d --name liveforge \
  -p 1935:1935 -p 8554:8554 -p 8080:8080 -p 8443:8443 \
  -p 6000:6000 -p 5060:5060/udp -p 8090:8090 \
  impingo/liveforge:latest

Or with docker compose:

git clone https://github.com/im-pingo/liveforge.git
cd liveforge
docker compose up -d

Open http://localhost:8090/console to access the web console.

To use a custom config:

docker run -d --name liveforge \
  -v /path/to/liveforge.yaml:/etc/liveforge/liveforge.yaml:ro \
  -p 1935:1935 -p 8554:8554 -p 8080:8080 -p 8443:8443 \
  -p 6000:6000 -p 5060:5060/udp -p 8090:8090 \
  impingo/liveforge:latest

Build from Source

git clone https://github.com/im-pingo/liveforge.git
cd liveforge
go build -o liveforge ./cmd/liveforge
./liveforge -c configs/liveforge.yaml

To enable audio transcoding, build with CGO and FFmpeg/libav:

CGO_ENABLED=1 go build -tags audiocodec -o liveforge ./cmd/liveforge

Publish a Stream

RTMP (OBS / FFmpeg):

ffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost:1935/live/stream1

RTSP:

ffmpeg -re -i input.mp4 -c copy -f rtsp rtsp://localhost:8554/live/stream1

SRT:

ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://localhost:6000?streamid=publish:/live/stream1"

WebRTC (Browser): Open http://localhost:8090/console, click "+ WebRTC Publish", select camera/mic, and start streaming.

GB28181: Configure your IP camera's SIP server to point at localhost:5060, or use the built-in simulator:

go run ./tools/gb28181-sim -server 127.0.0.1:5060

Play a Stream

ProtocolURL
RTMPrtmp://localhost:1935/live/stream1
RTSPrtsp://localhost:8554/live/stream1
SRTsrt://localhost:6000?streamid=subscribe:/live/stream1
HLShttp://localhost:8080/live/stream1.m3u8
LL-HLShttp://localhost:8080/live/stream1.m3u8 (auto when enabled)
DASHhttp://localhost:8080/live/stream1.mpd
HTTP-FLVhttp://localhost:8080/live/stream1.flv
HTTP-TShttp://localhost:8080/live/stream1.ts
FMP4http://localhost:8080/live/stream1.mp4
WebRTCOpen console โ†’ Preview โ†’ WebRTC tab

Web Console

Open http://localhost:8090/console for the real-time management dashboard:

  • Live stream list with state, codecs, bitrate, FPS
  • GOP cache visualization
  • Multi-protocol preview player (HTTP-FLV, WS-FLV, HTTP-TS, FMP4, WebRTC)
  • WebRTC publish with camera/mic and outbound stats
  • Stream management (kick publisher, delete stream)

Configuration

LiveForge uses a single YAML configuration file. See configs/liveforge.yaml for the full reference.

Key sections:

SectionPurpose
rtmpRTMP ingest/playback (default :1935)
rtspRTSP ingest/playback with TCP + UDP (default :8554)
http_streamHLS, LL-HLS, DASH, HTTP-FLV, HTTP-TS, FMP4, WebSocket (default :8080)
webrtcWHIP/WHEP with ICE servers and UDP port range (default :8443)
srtSRT ingest/playback with AES encryption (default :6000)
sipSIP signaling server for GB28181 (default :5060)
gb28181GB28181 device management, RTP port range, keepalive, auto-invite
audio_codecEnable/disable on-demand audio transcoding
apiREST API and web console (default :8090)
authJWT and HTTP callback authentication
recordFLV recording with segmentation
notifyHTTP webhook and WebSocket notifications
clusterMulti-protocol forwarding and origin pull with scheduler
metricsPrometheus metrics endpoint (default :9090)
limitsGlobal connection, stream, and subscriber limits
tlsTLS certificate and key for HTTPS/secure protocols
streamGOP cache, ring buffer, idle timeout, slow consumer, simulcast settings

Environment variable expansion is supported: ${API_TOKEN}, ${AUTH_JWT_SECRET}.

Testing Tools

lf-test CLI

A comprehensive integration testing tool (tools/lf-test) for validating all server features:

# Push test (supports: rtmp, rtsp, srt, whip, gb28181)
go run ./tools/lf-test push --protocol rtmp --target rtmp://localhost:1935/live/test

# Play test (supports: rtmp, rtsp, srt, whep, httpflv, wsflv, hls, llhls, dash)
go run ./tools/lf-test play --protocol hls --url http://localhost:8080/live/test.m3u8

# Cluster topology test (auto-launches multi-node cluster)
go run ./tools/lf-test cluster \
  --topology origin-edge \
  --relay-protocol srt \
  --push-protocol rtmp \
  --play-protocol hls

# Auth test
go run ./tools/lf-test auth --target rtmp://localhost:1935/live/test --token <jwt>

All commands support --assert expressions and --output json for CI integration.

gb28181-sim

See GB28181 Device Simulator above.

Project Structure

liveforge/
โ”œโ”€โ”€ cmd/liveforge/       # Entry point
โ”œโ”€โ”€ config/              # YAML config loader
โ”œโ”€โ”€ core/                # Server, Stream, EventBus, StreamHub, MuxerManager, TranscodeManager
โ”œโ”€โ”€ module/
โ”‚   โ”œโ”€โ”€ api/             # REST API + web console
โ”‚   โ”œโ”€โ”€ auth/            # JWT / HTTP callback auth
โ”‚   โ”œโ”€โ”€ cluster/         # Multi-protocol forwarding + origin pull (RTMP/SRT/RTSP/RTP/GB28181)
โ”‚   โ”œโ”€โ”€ gb28181/         # GB28181 protocol (SIP signaling, device registry, invite, PTZ, playback, alarm)
โ”‚   โ”œโ”€โ”€ httpstream/      # HLS, LL-HLS, DASH, HTTP-FLV, HTTP-TS, FMP4, WebSocket
โ”‚   โ”œโ”€โ”€ metrics/         # Prometheus metrics endpoint
โ”‚   โ”œโ”€โ”€ notify/          # HTTP webhook + WebSocket notifications
โ”‚   โ”œโ”€โ”€ record/          # FLV stream recording
โ”‚   โ”œโ”€โ”€ rtmp/            # RTMP protocol (handshake, chunks, AMF0)
โ”‚   โ”œโ”€โ”€ rtsp/            # RTSP protocol (TCP + UDP transport)
โ”‚   โ”œโ”€โ”€ sip/             # SIP transport layer (used by GB28181)
โ”‚   โ”œโ”€โ”€ srt/             # SRT protocol (via datarhei/gosrt)
โ”‚   โ””โ”€โ”€ webrtc/          # WebRTC WHIP/WHEP + GCC (via pion/webrtc)
โ”œโ”€โ”€ pkg/
โ”‚   โ”œโ”€โ”€ audiocodec/      # Audio transcode: FFmpeg-backed decode/encode/resample (AAC, Opus, G.711, MP3)
โ”‚   โ”œโ”€โ”€ avframe/         # Audio/video frame types
โ”‚   โ”œโ”€โ”€ codec/           # H.264, H.265, AAC, AV1, Opus, MP3 parsers
โ”‚   โ”œโ”€โ”€ logger/          # Structured logging
โ”‚   โ”œโ”€โ”€ muxer/           # FLV, TS, FMP4, MPEG-PS muxers and demuxers
โ”‚   โ”œโ”€โ”€ portalloc/       # Port range allocator for RTP
โ”‚   โ”œโ”€โ”€ ratelimit/       # Per-IP token bucket rate limiter
โ”‚   โ”œโ”€โ”€ rtp/             # Full RTP/RTCP stack with 12+ codec packetizers
โ”‚   โ”œโ”€โ”€ sdp/             # SDP parser and builder
โ”‚   โ””โ”€โ”€ util/            # Lock-free SPMC ring buffer
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ gb28181-sim/     # GB28181 device simulator
โ”‚   โ”œโ”€โ”€ lf-test/         # Integration test CLI (push, play, auth, cluster)
โ”‚   โ””โ”€โ”€ testkit/         # Reusable test components (push, play, cluster, analyzer, report)
โ””โ”€โ”€ test/integration/    # End-to-end integration tests

Testing

30 test packages, all passing:

go test ./...
go test -race ./...     # with race detector
go test -cover ./...    # with coverage

Comparison

FeatureLiveForgeMediaMTXSRSMonibuca
LanguageGoGoC++Go
RTMPYesYesYesYes
RTSPYes (TCP+UDP)YesYesPlugin
SRTYes (pure Go)YesYesPlugin
WebRTC WHIP/WHEPYesYesYesPlugin
HLS/DASHYesYesYesPlugin
LL-HLSYes (fMP4 + blocking reload)NoYesNo
HTTP-FLVYesNoYesPlugin
FMP4 streamingYesNoNoNo
GB28181Yes (full SIP + live/playback/PTZ)NoYesPlugin
Audio transcodingYes (AACโ†”Opusโ†”G.711โ†”MP3)NoYesPlugin
Cluster relayYes (RTMP/SRT/RTSP/RTP/GB28181)NoYesPlugin
Web consoleYes (built-in)NoYesYes
Browser publishYes (WHIP)NoNoNo
Auth (JWT + callback)YesYesYesPlugin
RecordingYes (FLV)YesYesPlugin
WebhooksYes (HMAC-signed)NoYesNo
ICE LiteYesNoNoNo
Prometheus metricsYesNoYesPlugin
GCC congestion controlYesNoNoNo
Testing toolsYes (lf-test CLI + GB28181 sim)NoNoNo
Single binaryYesYesYesNo
LicenseMITMITMITMIT

Documentation

๐Ÿ“– Full documentation is on the GitHub Wiki.

TopicENไธญๆ–‡
HomeWiki HomeWiki ้ฆ–้กต
Audio TranscodingAudio Transcoding้Ÿณ้ข‘่ฝฌ็ 
GB28181 GuideGB28181GB28181 ๆŒ‡ๅ—
Cluster DeploymentCluster Deployment้›†็พค้ƒจ็ฝฒ
LL-HLSLL-HLSไฝŽๅปถ่ฟŸ HLS
Testing ToolsTesting Toolsๆต‹่ฏ•ๅทฅๅ…ท
Configuration ReferenceConfiguration้…็ฝฎๅ‚่€ƒ
REST APIREST APIREST API

Roadmap

  • TLS / HTTPS
  • SRT protocol
  • Multi-protocol cluster relay (RTMP, SRT, RTSP, RTP, GB28181)
  • WebRTC ICE Lite
  • WebSocket notifications
  • Prometheus metrics
  • LL-HLS (partial segments + blocking reload)
  • Slow consumer protection (EWMA frame dropping)
  • GCC congestion control for WebRTC
  • Rate limiting
  • GB28181 (SIP + live + playback + PTZ + alarm)
  • Audio transcoding (AAC, Opus, G.711, MP3)
  • SIP gateway
  • Simulcast layer selection
  • Admin UI enhancements

License

MIT โ€” Copyright (c) 2026 Pingos