Repository navigation
feat: record into rotating segments and keep a replay buffer - #578
Merged
Merged
Conversation
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
force-pushed
the
feat/segmented-recording
branch
from
November 9, 2026 17:00
aa3dd05 to
c807bca
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two recording modes on top of
MediaRecorder, both writing the encoded frames without re-encoding:new MediaRecorder(SegmentOptions)rotates files by duration and/or size at video key frames, keeps the newest segments withinmaxSegments/maxTotalSize, and reports each finished file toMediaRecorderListener.onSegmentFinished.ReplayBufferkeeps the last N seconds in memory (bounded in bytes) and saves them into a file on demand withsave(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.