Export and record WebRTC sessions and tracks
WebRTC is fantastic for last-mile media delivery, but interoperability with other services can be challenging. An application may want to do things like store a session for future playback, relay a stream to a CDN, or process a track through a transcription service – workflows where media travels through a different system or protocol. LiveKit Egress is the solution to these interoperability challenges. It provides a consistent set of APIs that gives you universal export of your LiveKit sessions and tracks.
Depending on your request type, the egress service will either launch Chrome using a web template (room composite requests) or a supplied url (web requests), or it will use the Go SDK directly (track and track composite requests). Irrespective of method used, when moving between protocols, containers or encodings, LiveKit's egress service will automatically transcode streams for you using GStreamer.
| Egress Type | MP4 File | OGG File | WebM File | HLS (TS Segments) | RTMP(s) Stream | SRT Stream | WebSocket Stream | Thumbnails (JPEGs) |
|---|---|---|---|---|---|---|---|---|
| Room Composite | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ||
| Web | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ||
| Track Composite | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ||
| Track | ✅ | ✅ | ✅ | ✅ |
Files can be uploaded to any S3 compatible storage, Azure, or GCP.
Full docs available here
The Egress service takes a yaml config file:
…The config file can be added to a mounted volume with its location passed in the EGRESS_CONFIG_FILE env var, or its body can be passed in the EGRESS_CONFIG_BODY env var.
Compatibility note on
psrpc.compressionBus compression requires psrpc v0.7.6 or newer on every node sharing the redis bus. An older peer ignores the compression marker and decodes the gzipped bytes as the message payload, so the message is dropped without an error. Enabling it is therefore a two-stage operator action: roll a build with psrpc v0.7.6+ out to livekit-server, egress, ingress, SIP and any agent workers first, then raise
qualityat the publishers. It is off by default.
max_decompressed_sizeonly affects reading, so it can be set ahead ofquality.The remaining
rpc.PSRPCConfigkeys (max_attempts,timeout,backoff,buffer_size) are accepted underpsrpc:for config parity with livekit-server, but egress does not read them.
The below templates can also be used in filename/filepath parameters:
| Egress Type | {room_id} | {room_name} | {time} | {utc} | {publisher_identity} | {track_id} | {track_type} | {track_source} |
|---|---|---|---|---|---|---|---|---|
| Room Composite | ✅ | ✅ | ✅ | ✅ | ||||
| Web | ✅ | ✅ | ||||||
| Track Composite | ✅ | ✅ | ✅ | ✅ | ✅ | |||
| Track | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
"{room_name}-{time}"./, a file will be generated in that directory.Examples:
| Request filename | Resulting filename |
|---|---|
| "" | testroom-2022-10-04T011306.mp4 |
| "livekit-recordings/" | livekit-recordings/testroom-2022-10-04T011306.mp4 |
| "{room_name}/{time}" | testroom/2022-10-04T011306.mp4 |
| "{room_id}-{publisher_identity}.mp4" | 10719607-f7b0-4d82-afe1-06b77e91fe12-david.mp4 |
| "{track_type}-{track_source}-{track_id}" | audio-microphone-TR_SKasdXCVgHsei.ogg |
These changes are not recommended for a production setup.
To run against a local livekit server, you'll need to do the following:
/usr/local/etc/redis.conf and comment out the line that says bind 127.0.0.1protected-mode yes to protected-mode no in the same filews_url needs to be set using the IP as Docker sees it172.17.0.1docker run -it --rm alpine nslookup host.docker.internal and you should see something like
Name: host.docker.internal Address: 192.168.65.2These changes allow the service to connect to your local redis instance from inside the docker container.
Create a directory to mount. In this example, we will use ~/egress-test.
Create a config.yaml in the above directory.
redis and ws_url should use the above IP instead of localhostinsecure should be set to truelog_level: debug
api_key: your-api-key
api_secret: your-api-secret
ws_url: ws://192.168.65.2:7880
insecure: true
redis:
address: 192.168.65.2:6379Then to run the service:
docker run --rm \
-e EGRESS_CONFIG_FILE=/out/config.yaml \
-v ~/egress-test:/out \
livekit/egressYou can then use our cli to submit egress requests to your server.
By default, Room Composite and Web egresses run with Chrome sandboxing disabled. This is because the default docker security settings prevent Chrome from switching to a different kernel namespace, which is needed by Chrome to setup its sandbox.
Chrome sandboxing within Egress can be reenabled by setting the the enable_chrome_sandbox option to true in the egress configuration, and launching docker using the provided
seccomp security profile:
docker run --rm \
-e EGRESS_CONFIG_FILE=/out/config.yaml \
-v ~/egress-test:/out \
--security-opt seccomp=chrome-sandboxing-seccomp-profile.json \
livekit/egressThis profile is based on the default docker seccomp security profile and allows
the 2 extra system calls (clone and unshare) that Chrome needs to setup the sandbox.
Note that kubernetes disables seccomp entirely by default, which means that running with Chrome sandboxing enabled is possible on a kubernetes cluster with the default security settings.
docker run command (e.g. -v ~/livekit-egress:/out/), and use the mounted
directory in your filenames (e.g. /out/my-recording.mp4). Since egress is not run as the root user, write permissions
will need to be enabled for all users."no response from egress service" error when sending a requestTo run the test against your own LiveKit rooms, a deployed LiveKit server with a secure websocket url is required.
First, create egress/test/config.yaml:
log_level: debug
api_key: your-api-key
api_secret: your-api-secret
ws_url: wss://your-livekit-url.com
redis:
address: 192.168.65.2:6379
room_only: false
web_only: false
track_composite_only: false
track_only: false
file_only: false
stream_only: false
segments_only: false
dot_files: false
short: falseJoin a room using https://example.livekit.io or your own client, then run mage integration test/config.yaml.
This will test recording different file types, output settings, and streams against your room.
LiveKit Ecosystem
Agents SDKsPython · Node.js
LiveKit SDKsBrowser · Swift · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32 · C++
Starter AppsPython Agent · TypeScript Agent · React App · SwiftUI App · Android App · Flutter App · React Native App · Web Embed
UI ComponentsReact · Android Compose · SwiftUI · Flutter
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
ResourcesDocs · Docs MCP Server · CLI · LiveKit Cloud
LiveKit Server OSSLiveKit server · Egress · Ingress · SIP
CommunityDeveloper Community · Slack · X · YouTube
No open issues yet, or sync has not completed.