HTTP-FLV Protocol
HTTP-FLV is a protocol that transmits FLV audio/video data over HTTP long connections. Compared to HLS, HTTP-FLV offers lower latency; compared to RTMP, it uses standard HTTP ports, making it more friendly to firewalls and CDNs.
Basic Information
Section titled “Basic Information”| Property | Value |
|---|---|
| Transport Layer | HTTP (shares the engine HTTP port) |
| Publish | ❌ Not supported |
| Subscribe | ✅ Supported |
| Latency | 1-3 seconds |
| Feature Flag | flv |
Configuration
Section titled “Configuration”Feature Activation
Section titled “Feature Activation”[features]flv = ["dep:plugin-flv"]Configuration File
Section titled “Configuration File”flv: enable: true| Option | Type | Default | Description |
|---|---|---|---|
enable | bool | true | Whether to enable the FLV plugin |
URL Format
Section titled “URL Format”HTTP-FLV Subscribe
Section titled “HTTP-FLV Subscribe”http://host:port/flv/{streamPath}.flv{streamPath}: Stream path, e.g.,live/test- The
.flvsuffix is optional
Examples:
http://localhost:8080/flv/live/test.flvhttp://localhost:8080/flv/live/testWebSocket-FLV Subscribe
Section titled “WebSocket-FLV Subscribe”The FLV plugin also supports transmitting FLV data via WebSocket, suitable for browser-based playback:
ws://host:port/flv/{streamPath}.flvSubscribing
Section titled “Subscribing”Subscribing with FFplay
Section titled “Subscribing with FFplay”ffplay http://localhost:8080/flv/live/test.flvRecording with FFmpeg
Section titled “Recording with FFmpeg”# Subscribe to HTTP-FLV stream and save to fileffmpeg -i http://localhost:8080/flv/live/test.flv -c copy output.flv
# Subscribe and remux to MP4ffmpeg -i http://localhost:8080/flv/live/test.flv -c copy output.mp4Browser Playback
Section titled “Browser Playback”In the browser, you can use flv.js or mpegts.js to play HTTP-FLV streams:
<script src="https://cdn.jsdelivr.net/npm/mpegts.js/dist/mpegts.js"></script><video id="player" controls></video><script> if (mpegts.isSupported()) { const player = mpegts.createPlayer({ type: 'flv', url: 'http://localhost:8080/flv/live/test.flv', isLive: true, }); player.attachMediaElement(document.getElementById('player')); player.load(); player.play(); }</script>WebSocket-FLV method:
const player = mpegts.createPlayer({ type: 'flv', url: 'ws://localhost:8080/flv/live/test.flv', isLive: true,});FLV Recording
Section titled “FLV Recording”The FLV plugin supports recording streams as FLV files:
# Start recordingcurl -X POST http://localhost:8080/flv/record/start/live/test
# Stop recordingcurl -X POST http://localhost:8080/flv/record/stop/live/test
# List recordingscurl http://localhost:8080/flv/record/list
# Check recording statuscurl http://localhost:8080/flv/record/status/live/testAudio Codec Support
Section titled “Audio Codec Support”HTTP-FLV supports the following audio codecs:
| Codec | Description |
|---|---|
| AAC | Standard support |
| G.711A | Supported (commonly used in security surveillance) |
| G.711U | Supported (commonly used in security surveillance) |
Typical Workflow
Section titled “Typical Workflow”# 1. Publish via RTMPffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost:1935/live/test
# 2. Subscribe via HTTP-FLV for playbackffplay http://localhost:8080/flv/live/test.flv