You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨(backend) make LiveKit Egress recording encoding configurable
Expose RECORDING_ENCODING_* settings to override the default LiveKit
Egress preset (H264_720P_30). When RECORDING_ENCODING_ENABLED is True,
the provided width/height/framerate/bitrate/keyframe values are passed
as advanced EncodingOptions. Lowering framerate and bitrate reduces
recording file size and egress worker CPU load.
Disabled by default, preserving current behaviour.
Copy file name to clipboardExpand all lines: docs/features/recording.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,13 @@ sequenceDiagram
100
100
|**RECORDING_STORAGE_EVENT_TOKEN**| Secret/File |`None`| Token used to authenticate storage webhook requests, if `RECORDING_ENABLE_STORAGE_EVENT_AUTH` is enabled. |
101
101
|**RECORDING_EXPIRATION_DAYS**| Integer |`None`| Number of days before recordings expire. Should match bucket lifecycle policy. Set to `None` for no expiration. |
102
102
|**RECORDING_MAX_DURATION**| Integer |`None`| Maximum duration of a recording in milliseconds. Must be synced with the LiveKit Egress configuration. Set to None for unlimited duration. When the maximum duration is reached, the recording is automatically stopped and saved, and the user is prompted in the frontend with an alert message. |
103
+
|**RECORDING_ENCODING_ENABLED**| Boolean |`False`| When `False`, LiveKit Egress uses its built-in `H264_720P_30` preset. When `True`, the `RECORDING_ENCODING_*` values below are sent to LiveKit as advanced `EncodingOptions`. See [Tuning recording encoding](#tuning-recording-encoding). |
104
+
|**RECORDING_ENCODING_WIDTH**| Integer |`1280`| Recording video width in pixels. Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
105
+
|**RECORDING_ENCODING_HEIGHT**| Integer |`720`| Recording video height in pixels. Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
106
+
|**RECORDING_ENCODING_FRAMERATE**| Integer |`30`| Recording video framerate (fps). Directly impacts egress worker CPU (roughly linear). Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
107
+
|**RECORDING_ENCODING_VIDEO_BITRATE_KBPS**| Integer |`3000`| H.264 MAIN video bitrate in kbps. Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
108
+
|**RECORDING_ENCODING_AUDIO_BITRATE_KBPS**| Integer |`128`| AAC audio bitrate in kbps. Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
109
+
|**RECORDING_ENCODING_KEY_FRAME_INTERVAL_S**| Float |`4.0`| Keyframe interval in seconds. Drives seek granularity in the recorded MP4 (a player can only seek to keyframe boundaries). Larger values give the encoder slightly more bits for non-keyframe content at a fixed bitrate. `4.0` is a standard VOD value. Only applied when `RECORDING_ENCODING_ENABLED` is `True`. |
103
110
104
111
105
112
### Manual Storage Webhook
@@ -141,3 +148,54 @@ Using default project meet
141
148
142
149
This allows you to verify which recordings are in progress, troubleshoot egress issues, and confirm that recordings are being processed correctly.
143
150
151
+
## Tuning recording encoding
152
+
153
+
By default, LiveKit Egress records with the built-in `H264_720P_30` preset: 1280×720 at 30 fps, 3000 kbps H.264 MAIN video and 128 kbps AAC audio. For a one-hour meeting this produces a file of roughly **1.4 GB**, which is often heavier than necessary for talking-head content and screen sharing.
154
+
155
+
The `RECORDING_ENCODING_*` settings let operators override this preset without modifying the source. Values are passed straight through LiveKit's `EncodingOptions.advanced` to the GStreamer pipeline (`x264enc` for video, `faac` for audio), so there are no hidden conversions — what you set is what the encoder receives.
The H.264 profile is fixed to MAIN and the x264 `speed-preset` to `veryfast` by LiveKit (real-time constraint) — lowering the framerate is therefore the main lever to save CPU, while lowering the bitrate is the main lever to shrink the output file.
168
+
169
+
### Reference profiles
170
+
171
+
Rough 30-minute file-size estimates assume video + audio bitrate multiplied by duration. Actual sizes vary with content (static talking heads compress better than heavy screen motion). Egress CPU figures are indicative, measured on a single Ryzen laptop core saturated by the default preset (= 100 %); scaling is roughly linear with `framerate × bitrate` but the absolute numbers depend on the host hardware.
172
+
173
+
| Profile | Resolution | FPS | Video (kbps) | Audio (kbps) | Keyframe (s) | ~ size / 30 min | Egress CPU (vs. default) | Suitable for |
★ Recommended starting point for typical LaSuite Meet usage.
183
+
184
+
Environment variables for the **Low CPU / small file** profile:
185
+
186
+
```bash
187
+
RECORDING_ENCODING_ENABLED=True
188
+
RECORDING_ENCODING_WIDTH=1280
189
+
RECORDING_ENCODING_HEIGHT=720
190
+
RECORDING_ENCODING_FRAMERATE=15
191
+
RECORDING_ENCODING_VIDEO_BITRATE_KBPS=600
192
+
RECORDING_ENCODING_AUDIO_BITRATE_KBPS=64
193
+
RECORDING_ENCODING_KEY_FRAME_INTERVAL_S=4.0
194
+
```
195
+
196
+
### Caveats
197
+
198
+
-**Screen-share readability — think bits/frame, not bitrate**: at 720p, text legibility starts to break down below ~40 kbits/frame (= `bitrate ÷ framerate`). The recommended preset (600 kbps × 15 fps) sits at exactly that threshold, comfortable for talking heads with occasional slide sharing. The same 600 kbps at 30 fps would only deliver 20 kbits/frame and visibly blur dense slides — which is why **lowering framerate is a more screen-share-friendly lever than lowering bitrate**. For deck-heavy or IDE-share meetings, prefer the **Slide-heavy** profile (900 kbps × 15 fps ≈ 60 kbits/frame).
199
+
-**Motion handling**: the `veryfast` x264 preset is set by LiveKit and cannot be overridden here. Low-bitrate settings will therefore show more artefacts on fast motion than an offline re-encode with a slower preset would. This is the other reason FPS reduction is the safer tuning lever for meeting recordings.
200
+
-**Audio**: AAC at 64 kbps stereo is transparent for voice but starts to compress music noticeably. Keep 128 kbps if you expect music playback in meetings.
201
+
-**Codec choice**: H.264 MAIN is hardcoded on purpose. Switching to HEVC or VP9 would increase egress CPU cost 2×–5×, defeating the goal of this tuning.
0 commit comments