Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

add cli to recording crate

Brendan Allan8fb5f11dcde1
diff --git a/Cargo.lock b/Cargo.lock
index 1cf1cdb69..66c21d958 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -336,7 +336,7 @@ dependencies = [
"futures-lite",
"parking",
"polling",
- "rustix",
+ "rustix 0.38.39",
"slab",
"tracing",
"windows-sys 0.59.0",
@@ -368,7 +368,7 @@ dependencies = [
"cfg-if 1.0.0",
"event-listener",
"futures-lite",
- "rustix",
+ "rustix 0.38.39",
"tracing",
"windows-sys 0.59.0",
]
@@ -396,7 +396,7 @@ dependencies = [
"cfg-if 1.0.0",
"futures-core",
"futures-io",
- "rustix",
+ "rustix 0.38.39",
"signal-hook-registry",
"slab",
"windows-sys 0.59.0",
@@ -982,7 +982,7 @@ dependencies = [
[[package]]
name = "cap-desktop"
-version = "0.3.57"
+version = "0.3.58"
dependencies = [
"anyhow",
"axum",
@@ -1221,6 +1221,7 @@ dependencies = [
"serde",
"serde_json",
"specta",
+ "tempfile",
"thiserror 1.0.69",
"tokio",
"tracing",
@@ -2626,12 +2627,12 @@ dependencies = [
[[package]]
name = "errno"
-version = "0.3.9"
+version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [
"libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.59.0",
]
[[package]]
@@ -3179,7 +3180,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc3655aa6818d65bc620d6911f05aa7b6aeb596291e1e9f79e52df85583d1e30"
dependencies = [
- "rustix",
+ "rustix 0.38.39",
"windows-targets 0.52.6",
]
@@ -3207,6 +3208,18 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "getrandom"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
+dependencies = [
+ "cfg-if 1.0.0",
+ "libc",
+ "r-efi",
+ "wasi 0.14.2+wasi-0.2.4",
+]
+
[[package]]
name = "gif"
version = "0.13.1"
@@ -4355,6 +4368,12 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+[[package]]
+name = "linux-raw-sys"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
+
[[package]]
name = "litrs"
version = "0.4.1"
@@ -5856,7 +5875,7 @@ dependencies = [
"concurrent-queue",
"hermit-abi 0.4.0",
"pin-project-lite",
- "rustix",
+ "rustix 0.38.39",
"tracing",
"windows-sys 0.59.0",
]
@@ -6115,6 +6134,12 @@ dependencies = [
"proc-macro2",
]
+[[package]]
+name = "r-efi"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
+
[[package]]
name = "rand"
version = "0.7.3"
@@ -6582,10 +6607,23 @@ dependencies = [
"bitflags 2.9.0",
"errno",
"libc",
- "linux-raw-sys",
+ "linux-raw-sys 0.4.14",
"windows-sys 0.52.0",
]
+[[package]]
+name = "rustix"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
+dependencies = [
+ "bitflags 2.9.0",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.9.4",
+ "windows-sys 0.59.0",
+]
+
[[package]]
name = "rustls"
version = "0.23.13"
@@ -8275,14 +8313,14 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.13.0"
+version = "3.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
+checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
dependencies = [
- "cfg-if 1.0.0",
"fastrand",
+ "getrandom 0.3.3",
"once_cell",
- "rustix",
+ "rustix 1.0.7",
"windows-sys 0.59.0",
]
@@ -9091,6 +9129,15 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+[[package]]
+name = "wasi"
+version = "0.14.2+wasi-0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
+dependencies = [
+ "wit-bindgen-rt",
+]
+
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
@@ -9183,7 +9230,7 @@ checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6"
dependencies = [
"cc",
"downcast-rs",
- "rustix",
+ "rustix 0.38.39",
"scoped-tls",
"smallvec",
"wayland-sys",
@@ -9196,7 +9243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280"
dependencies = [
"bitflags 2.9.0",
- "rustix",
+ "rustix 0.38.39",
"wayland-backend",
"wayland-scanner",
]
@@ -9464,7 +9511,7 @@ dependencies = [
"either",
"home",
"once_cell",
- "rustix",
+ "rustix 0.38.39",
]
[[package]]
@@ -10297,6 +10344,15 @@ dependencies = [
"windows-sys 0.48.0",
]
+[[package]]
+name = "wit-bindgen-rt"
+version = "0.39.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
+dependencies = [
+ "bitflags 2.9.0",
+]
+
[[package]]
name = "wry"
version = "0.51.2"
@@ -10369,7 +10425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12"
dependencies = [
"gethostname 0.4.3",
- "rustix",
+ "rustix 0.38.39",
"x11rb-protocol",
]
@@ -10386,8 +10442,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f"
dependencies = [
"libc",
- "linux-raw-sys",
- "rustix",
+ "linux-raw-sys 0.4.14",
+ "rustix 0.38.39",
]
[[package]]
diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml
index a84d8a542..b6ec1383c 100644
--- a/apps/desktop/src-tauri/Cargo.toml
+++ b/apps/desktop/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cap-desktop"
-version = "0.3.57"
+version = "0.3.58"
description = "Beautiful screen recordings, owned by you."
authors = ["you"]
edition = "2021"
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 87fa91ed8..0a169ba2e 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1221,7 +1221,6 @@ async fn take_screenshot(app: AppHandle, _state: MutableState<'_, App>) -> Resul
use cap_project::*;
RecordingMeta {
platform: Some(Platform::default()),
-
project_path: recording_dir.clone(),
sharing: None,
pretty_name: screenshot_name,
diff --git a/crates/recording/Cargo.toml b/crates/recording/Cargo.toml
index d94afcd1f..400395cbf 100644
--- a/crates/recording/Cargo.toml
+++ b/crates/recording/Cargo.toml
@@ -43,3 +43,6 @@ windows = { workspace = true, features = [
"Win32_Graphics_Gdi",
"Win32_UI_WindowsAndMessaging",
] }
+
+[dev-dependencies]
+tempfile = "3.20.0"
diff --git a/crates/recording/examples/recording-cli.rs b/crates/recording/examples/recording-cli.rs
new file mode 100644
index 000000000..a1576004a
--- /dev/null
+++ b/crates/recording/examples/recording-cli.rs
@@ -0,0 +1,34 @@
+use std::time::Duration;
+
+use cap_media::sources::ScreenCaptureTarget;
+use cap_recording::RecordingBaseInputs;
+
+#[tokio::main]
+pub async fn main() {
+ let _ = std::fs::remove_dir_all("/tmp/bruh");
+ let _ = std::fs::create_dir("/tmp/bruh");
+
+ let dir = tempfile::tempdir().unwrap();
+
+ println!("Recording to directory '{}'", dir.path().display());
+
+ let (handle, ready_rx) = cap_recording::spawn_studio_recording_actor(
+ "test".to_string(),
+ dir.path().into(),
+ RecordingBaseInputs {
+ capture_target: ScreenCaptureTarget::primary_display(),
+ capture_system_audio: false,
+ mic_feed: &None,
+ },
+ None,
+ false,
+ )
+ .await
+ .unwrap();
+
+ tokio::time::sleep(Duration::from_secs(5)).await;
+
+ let _ = handle.stop().await;
+
+ std::mem::forget(dir);
+}