Skip to content

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.

PropertyValue
Transport LayerHTTP (shares the engine HTTP port)
Publish❌ Not supported
Subscribe✅ Supported
Latency1-3 seconds
Feature Flagflv
Cargo.toml
[features]
flv = ["dep:plugin-flv"]
flv:
enable: true
OptionTypeDefaultDescription
enablebooltrueWhether to enable the FLV plugin
http://host:port/flv/{streamPath}.flv
  • {streamPath}: Stream path, e.g., live/test
  • The .flv suffix is optional

Examples:

http://localhost:8080/flv/live/test.flv
http://localhost:8080/flv/live/test

The FLV plugin also supports transmitting FLV data via WebSocket, suitable for browser-based playback:

ws://host:port/flv/{streamPath}.flv
Terminal window
ffplay http://localhost:8080/flv/live/test.flv
Terminal window
# Subscribe to HTTP-FLV stream and save to file
ffmpeg -i http://localhost:8080/flv/live/test.flv -c copy output.flv
# Subscribe and remux to MP4
ffmpeg -i http://localhost:8080/flv/live/test.flv -c copy output.mp4

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,
});

The FLV plugin supports recording streams as FLV files:

Terminal window
# Start recording
curl -X POST http://localhost:8080/flv/record/start/live/test
# Stop recording
curl -X POST http://localhost:8080/flv/record/stop/live/test
# List recordings
curl http://localhost:8080/flv/record/list
# Check recording status
curl http://localhost:8080/flv/record/status/live/test

HTTP-FLV supports the following audio codecs:

CodecDescription
AACStandard support
G.711ASupported (commonly used in security surveillance)
G.711USupported (commonly used in security surveillance)
Terminal window
# 1. Publish via RTMP
ffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost:1935/live/test
# 2. Subscribe via HTTP-FLV for playback
ffplay http://localhost:8080/flv/live/test.flv