Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/recording/src/output_pipeline/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl Muxer for WindowsMuxer {
_media_foundation_session = Some(session);
trace!("Running native encoder with frame pacing");
let mut pacer = FramePacer::new(config.frame_rate);
let mut last_texture: Option<windows::Win32::Graphics::Direct3D11::ID3D11Texture2D> = None;
let mut last_frame: Option<screen_capture::ScreenFrame> = None;
let mut first_timestamp: Option<Duration> = None;
let mut frame_count: u64 = 0;
let mut frames_reused: u64 = 0;
Expand All @@ -369,11 +369,12 @@ impl Muxer for WindowsMuxer {
let (texture, timestamp) = match pacer.next(&video_rx, &pause_flag) {
Paced::Frame(frame, timestamp) => {
let texture = frame.texture().clone();
last_texture = Some(texture.clone());
// Retain the pool lease through the encoder's copy and any paced repeats.
last_frame = Some(frame);
(texture, timestamp)
}
Paced::Repeat(timestamp) => {
let Some(texture) = &last_texture else {
let Some(frame) = &last_frame else {
continue;
};
frames_reused += 1;
Expand All @@ -384,7 +385,7 @@ impl Muxer for WindowsMuxer {
"Frame pacing: reusing frames due to slow capture"
);
}
(texture.clone(), timestamp)
(frame.texture().clone(), timestamp)
}
Paced::End => {
trace!("End of stream signal received");
Expand Down
3 changes: 3 additions & 0 deletions crates/recording/src/output_pipeline/win_segmented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ impl WindowsSegmentedMuxer {
either::Left((mut encoder, mut muxer)) => {
trace!("Running native encoder for segment");
let mut first_timestamp: Option<Duration> = None;
let mut last_frame: Option<screen_capture::ScreenFrame> = None;
let result = encoder.run(
Arc::new(AtomicBool::default()),
|| {
Expand All @@ -547,6 +548,8 @@ impl WindowsSegmentedMuxer {
};
let frame_time = duration_to_timespan(relative);

// The encoder queues its texture copy before requesting the next frame.
let frame = last_frame.insert(frame);
Ok(Some((frame.texture().clone(), frame_time)))
},
|output_sample| {
Expand Down
Loading
Loading