Skip to content

feat: record into rotating segments and keep a replay buffer - #578

Merged
devopvoid merged 3 commits into
mainfrom
feat/segmented-recording
Nov 10, 2026
Merged

devopvoid merged 3 commits into
mainfrom
feat/segmented-recording

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

Adds two recording modes on top of MediaRecorder, both writing the encoded frames without re-encoding:

  • Segments: new MediaRecorder(SegmentOptions) rotates files by duration and/or size at video key frames, keeps the newest segments within maxSegments/maxTotalSize, and reports each finished file to MediaRecorderListener.onSegmentFinished.
  • Replay buffer: ReplayBuffer keeps the last N seconds in memory (bounded in bytes) and saves them into a file on demand with save(Path).

Every segment and replay begins with a key frame of each video track, starts at timestamp 0 with A/V kept in sync, and plays on its own. A codec change starts a new segment.

MediaRecorder can split a recording into segments that each begin at a key
frame, ended by duration or size, keeping as many as SegmentOptions say.
ReplayBuffer keeps the last seconds in memory and saves them on demand.
@devopvoid
devopvoid force-pushed the feat/segmented-recording branch from aa3dd05 to c807bca Compare November 9, 2026 17:00
A request repeated while a rotation was due outlived the key frame that
ended it, went out a second later, and held the next rotation's request
back by up to a second, doubling segments on slow machines.
The call kept sending video, and a key frame arriving between start and
stop put media into the recording on slow machines.
@devopvoid
devopvoid merged commit 0991163 into main Nov 10, 2026
41 of 42 checks passed
@devopvoid
devopvoid deleted the feat/segmented-recording branch November 10, 2026 07:33
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.

1 participant