Skip to content

Conversation

@leszko
Copy link
Collaborator

@leszko leszko commented Nov 27, 2025

Env variables

RECORDING_ENABLED

  • Default: true
  • Description: Enable/disable recording. When false, recording is disabled.

RECORDING_MAX_LENGTH

  • Default: 1h
  • Description: Maximum total recording length (sum of all segments). Recording stops when reached.
  • Format: Supports 1h, 30m, 120s, or plain seconds (e.g., 3600)

RECORDING_STARTUP_CLEANUP_ENABLED

  • Default: true
  • Description: Enable/disable cleanup of recording files

Assumptions / Comments

  • The recording stream is sourced from the same place we send frames to the frontend.
    • This means that if a frame is dropped, it will also be missing from the recording (sorry, Ryan).
    • The main benefit is that we can piggy-back on our existing PTS calculation mechanism, and aiortc.contrib.media.MediaRecorder.
  • Temporary recordings are stored in the OS temp directory.
  • Both stream pause/resume and exporting a recording cause the backend to segment/clip the stream. The final recording is a concatenation of these segments when downloaded. This is mainly due to how pause handling works and the behavior of MediaRecorder, which needs to finalize the stream before exporting.
  • The pause/resume feature adds significant complexity to recording logic. On the backend we keep sending the same frame while paused, but we don't want repeated identical frames in the final recording.
  • Recording input may be tricky because of the pause/resume (we don't pause input stream!)
  • We use ffmpeg (as Python library) for mp4 segments concatenation; I experimented with using AV library, but it happened to be surprisingly difficult (a lot of corner cases, etc.), so I ended up with ffmpeg. AV is still an option, but required more work and maintenance. One other option is to use the moviepy library

fix #56

@leszko leszko force-pushed the rafal/recording branch 3 times, most recently from b3f5b7c to b4f5cbf Compare November 28, 2025 09:58
Signed-off-by: Rafal Leszko <rafal@livepeer.org>
Signed-off-by: Rafal Leszko <rafal@livepeer.org>
@leszko leszko marked this pull request as ready for review November 28, 2025 14:25
Signed-off-by: Rafal Leszko <rafal@livepeer.org>
@leszko leszko requested a review from yondonfu November 28, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for recording

2 participants