Skip to content

Commit 7a91ee0

Browse files
authored
fix windows border via scap + do recording fps check in init (#439)
* fix windows border via scap + do recording fps check in init * update scap * lockfile
1 parent 0136d04 commit 7a91ee0

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ specta = { version = "=2.0.0-rc.20", features = [
2525
"uuid",
2626
] }
2727

28-
scap = { git = "https://github.com/CapSoftware/scap", rev = "98a1b3c6d650" }
28+
scap = { git = "https://github.com/CapSoftware/scap", rev = "4164b9a3e7c7" }
2929
nokhwa = { git = "https://github.com/CapSoftware/nokhwa", rev = "b9c8079e82e2", features = [
3030
"input-native",
3131
"serialize",

crates/media/src/pipeline/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<T: PipelineClock> PipelineBuilder<T> {
138138
tokio::time::timeout(Duration::from_secs(5), task.ready_signal.recv_async())
139139
.await
140140
.map_err(|_| MediaError::TaskLaunch(format!("task timed out: '{name}'")))?
141-
.map_err(|e| MediaError::TaskLaunch(format!("{name} stop / {e}")))??;
141+
.map_err(|e| MediaError::TaskLaunch(format!("{name} build / {e}")))??;
142142

143143
task_handles.insert(name, task.join_handle);
144144
stop_rx.push(task.done_rx);

crates/media/src/sources/screen_capture.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
use cap_flags::FLAGS;
21
use cpal::traits::{DeviceTrait, HostTrait};
3-
use ffmpeg::{format::Sample, frame::Audio, ChannelLayout};
4-
use ffmpeg_sys_next::{AV_TIMECODE_STR_SIZE, AV_TIME_BASE_Q};
2+
use ffmpeg::{format::Sample, ChannelLayout};
3+
use ffmpeg_sys_next::AV_TIME_BASE_Q;
54
use flume::Sender;
65
use scap::{
7-
capturer::{
8-
get_output_frame_size, Area, Capturer, Options, Point, Resolution as ScapResolution, Size,
9-
},
6+
capturer::{Area, Capturer, Options, Point, Resolution as ScapResolution, Size},
107
frame::{Frame, FrameType, VideoFrame},
118
Target,
129
};
@@ -219,6 +216,10 @@ impl<TCaptureFormat: ScreenCaptureFormat> ScreenCaptureSource<TCaptureFormat> {
219216
get_target_fps(&scap_target).ok_or_else(|| "Failed to get target fps".to_string())?;
220217
let fps = fps.min(max_fps);
221218

219+
if fps > 0 {
220+
return Err("FPS must be greater than 0".to_string());
221+
}
222+
222223
let captures_audio = audio_tx.is_some();
223224

224225
let mut this = Self {
@@ -418,11 +419,6 @@ impl PipelineSourceTask for ScreenCaptureSource<AVFrameCapture> {
418419
let audio_tx = self.audio_tx.clone();
419420

420421
let start_time = self.start_time;
421-
// let start_time_nanos = self
422-
// .start_time
423-
// .duration_since(SystemTime::UNIX_EPOCH)
424-
// .unwrap()
425-
// .as_nanos() as u64;
426422

427423
inner(
428424
self,
@@ -520,25 +516,19 @@ fn inner<T: ScreenCaptureFormat>(
520516
_ => None,
521517
};
522518

523-
assert!(source.options.fps > 0);
524-
525519
let mut capturer = match Capturer::build(source.options.as_ref().clone()) {
526520
Ok(capturer) => capturer,
527521
Err(e) => {
528522
error!("Failed to build capturer: {e}");
529-
ready_signal
530-
.send(Err(MediaError::Any("Failed to build capturer")))
531-
.ok();
523+
let _ = ready_signal.send(Err(MediaError::Any("Failed to build capturer")));
532524
return;
533525
}
534526
};
535527

536528
info!("Capturer built");
537529

538530
let mut capturing = false;
539-
ready_signal.send(Ok(())).ok();
540-
541-
let t = std::time::Instant::now();
531+
let _ = ready_signal.send(Ok(()));
542532

543533
loop {
544534
match control_signal.last() {

0 commit comments

Comments
 (0)