Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix windows border via scap + do recording fps check in init (#439)

Brendan Allan7a91ee0e302a
diff --git a/Cargo.lock b/Cargo.lock
index 173f12fc1..f592a7f09 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6341,7 +6341,7 @@ dependencies = [
[[package]]
name = "scap"
version = "0.0.8"
-source = "git+https://github.com/CapSoftware/scap?rev=98a1b3c6d650#98a1b3c6d65096625493161c23387c6d0d0bf3b9"
+source = "git+https://github.com/CapSoftware/scap?rev=4164b9a3e7c7#4164b9a3e7c7afade350c88267577855a4e3af9f"
dependencies = [
"cocoa 0.25.0",
"core-foundation 0.10.0",
diff --git a/Cargo.toml b/Cargo.toml
index 6da6abae7..7be4cba31 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,7 +25,7 @@ specta = { version = "=2.0.0-rc.20", features = [
"uuid",
] }
-scap = { git = "https://github.com/CapSoftware/scap", rev = "98a1b3c6d650" }
+scap = { git = "https://github.com/CapSoftware/scap", rev = "4164b9a3e7c7" }
nokhwa = { git = "https://github.com/CapSoftware/nokhwa", rev = "b9c8079e82e2", features = [
"input-native",
"serialize",
diff --git a/crates/media/src/pipeline/builder.rs b/crates/media/src/pipeline/builder.rs
index dbcb7332c..70dbd7c8b 100644
--- a/crates/media/src/pipeline/builder.rs
+++ b/crates/media/src/pipeline/builder.rs
@@ -138,7 +138,7 @@ impl<T: PipelineClock> PipelineBuilder<T> {
tokio::time::timeout(Duration::from_secs(5), task.ready_signal.recv_async())
.await
.map_err(|_| MediaError::TaskLaunch(format!("task timed out: '{name}'")))?
- .map_err(|e| MediaError::TaskLaunch(format!("{name} stop / {e}")))??;
+ .map_err(|e| MediaError::TaskLaunch(format!("{name} build / {e}")))??;
task_handles.insert(name, task.join_handle);
stop_rx.push(task.done_rx);
diff --git a/crates/media/src/sources/screen_capture.rs b/crates/media/src/sources/screen_capture.rs
index 1884b9562..214159db3 100644
--- a/crates/media/src/sources/screen_capture.rs
+++ b/crates/media/src/sources/screen_capture.rs
@@ -1,12 +1,9 @@
-use cap_flags::FLAGS;
use cpal::traits::{DeviceTrait, HostTrait};
-use ffmpeg::{format::Sample, frame::Audio, ChannelLayout};
-use ffmpeg_sys_next::{AV_TIMECODE_STR_SIZE, AV_TIME_BASE_Q};
+use ffmpeg::{format::Sample, ChannelLayout};
+use ffmpeg_sys_next::AV_TIME_BASE_Q;
use flume::Sender;
use scap::{
- capturer::{
- get_output_frame_size, Area, Capturer, Options, Point, Resolution as ScapResolution, Size,
- },
+ capturer::{Area, Capturer, Options, Point, Resolution as ScapResolution, Size},
frame::{Frame, FrameType, VideoFrame},
Target,
};
@@ -219,6 +216,10 @@ impl<TCaptureFormat: ScreenCaptureFormat> ScreenCaptureSource<TCaptureFormat> {
get_target_fps(&scap_target).ok_or_else(|| "Failed to get target fps".to_string())?;
let fps = fps.min(max_fps);
+ if fps > 0 {
+ return Err("FPS must be greater than 0".to_string());
+ }
+
let captures_audio = audio_tx.is_some();
let mut this = Self {
@@ -418,11 +419,6 @@ impl PipelineSourceTask for ScreenCaptureSource<AVFrameCapture> {
let audio_tx = self.audio_tx.clone();
let start_time = self.start_time;
- // let start_time_nanos = self
- // .start_time
- // .duration_since(SystemTime::UNIX_EPOCH)
- // .unwrap()
- // .as_nanos() as u64;
inner(
self,
@@ -520,15 +516,11 @@ fn inner<T: ScreenCaptureFormat>(
_ => None,
};
- assert!(source.options.fps > 0);
-
let mut capturer = match Capturer::build(source.options.as_ref().clone()) {
Ok(capturer) => capturer,
Err(e) => {
error!("Failed to build capturer: {e}");
- ready_signal
- .send(Err(MediaError::Any("Failed to build capturer")))
- .ok();
+ let _ = ready_signal.send(Err(MediaError::Any("Failed to build capturer")));
return;
}
};
@@ -536,9 +528,7 @@ fn inner<T: ScreenCaptureFormat>(
info!("Capturer built");
let mut capturing = false;
- ready_signal.send(Ok(())).ok();
-
- let t = std::time::Instant::now();
+ let _ = ready_signal.send(Ok(()));
loop {
match control_signal.last() {