Repository navigation
video: pause encoding while nobody is watching - #61
Merged
Merged
Conversation
The pipeline encoded 4K60 continuously even with no session attached; with no viewer rustkvm_app used ~56% of a core, ~46% of it in the encoder's output thread, all for frames that were thrown away. Put a valve in front of the encoder. It starts closed, opens when a session's video track is attached (with a forced keyframe so the viewer can decode immediately) and closes when the last one detaches; a restarted pipeline picks up the current state. The valve forwards sticky events, so the encoder stays negotiated and video state, the dynamic GOP and the screenshot probe (moved to the valve's input) keep working while paused. rustkvm_video_frames_total now only counts frames encoded for a viewer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 of 10 tasks
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.
Requested by 4c · project thread
Summary
Before: the pipeline encoded 4K60 continuously even with nobody connected; idle,
rustkvm_appused ~56% of a core, ~46% of it in the encoder's output thread, for frames that were thrown away.After: encoding pauses while no session is watching and resumes, with a forced keyframe, when a viewer's video track is attached.
How
pipeline.rs: avalvein front of the encoder, starting closed, inforward-sticky-eventsmode so caps still reach the encoder and video state, dynamic GOP and snapshots keep working. The screenshot probe moves to the valve's input so snapshots work while paused.video.rs/webrtc.rs: attaching a session's video track opens the valve; detaching the last one closes it; a restarted pipeline picks up the current state.docs/api.md:rustkvm_video_frames_totalnow counts only frames encoded for a viewer.Testing
cargo +nightly fmt --all(CI)cargo +nightly clippy --workspace --release --all-targets -- -D warnings(CI)cargo +nightly test --workspace(CI)Checklist
#[allow(...)]suppressions and no newunwrap()/expect()in production pathsMissedTickBehavior::Delayrkvm-protoPart of a set of three video PRs (#60 and the H.264 High profile PR); merges onto
devtogether with them without conflicts.🤖 Generated with Claude Code
https://claude.ai/code/session_01PbdzY6PfT28goR4BhqdsXR
Generated by Claude Code