Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat(video): add video quality setting (low/balanced/high/max)

Louis Beaumont21bddd0fdc86
diff --git a/Cargo.lock b/Cargo.lock
index f81260352..a2b1d226d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6626,7 +6626,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"anyhow",
"bytemuck",
@@ -6679,7 +6679,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -6730,7 +6730,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"anyhow",
"chrono",
@@ -6754,7 +6754,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"anyhow",
"chrono",
@@ -6772,7 +6772,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"anyhow",
"image",
@@ -6787,7 +6787,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"anyhow",
"async-trait",
@@ -6856,7 +6856,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.82"
+version = "0.3.85"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/Cargo.toml b/Cargo.toml
index faba0c846..4f311fff6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri"]
resolver = "2"
[workspace.package]
-version = "0.3.85"
+version = "0.3.86"
authors = ["louis030195 <[email protected]>"]
description = ""
repository = "https://github.com/screenpipe/screenpipe"
diff --git a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
index 0c4ad1c6c..54e412ee6 100644
--- a/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/recording-settings.tsx
@@ -34,6 +34,7 @@ import {
Loader2,
Globe,
Shield,
+ Film,
} from "lucide-react";
import { cn } from "@/lib/utils";
import {
@@ -829,6 +830,35 @@ export function RecordingSettings() {
</CardContent>
</Card>
+ {/* Video Quality */}
+ <Card className="border-border bg-card">
+ <CardContent className="px-3 py-2.5">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-2.5">
+ <Film className="h-4 w-4 text-muted-foreground shrink-0" />
+ <div>
+ <h3 className="text-sm font-medium text-foreground">Video quality</h3>
+ <p className="text-xs text-muted-foreground">Higher quality = larger files</p>
+ </div>
+ </div>
+ <Select
+ value={settings.videoQuality || "balanced"}
+ onValueChange={(value) => handleSettingsChange({ videoQuality: value }, true)}
+ >
+ <SelectTrigger className="w-[130px] h-7 text-xs">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="low">Low</SelectItem>
+ <SelectItem value="balanced">Balanced</SelectItem>
+ <SelectItem value="high">High</SelectItem>
+ <SelectItem value="max">Max</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ </CardContent>
+ </Card>
+
{/* Audio Chunk Duration */}
<Card className="border-border bg-card">
<CardContent className="px-3 py-2.5">
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 7b86e3d8d..f61049a74 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -229,6 +229,7 @@ let DEFAULT_SETTINGS: Settings = {
enableUiEvents: false,
overlayMode: "fullscreen",
showOverlayInScreenRecording: false,
+ videoQuality: "balanced",
};
export function createDefaultSettingsObject(): Settings {
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index e1b7aec3c..b775da6ab 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -642,7 +642,13 @@ overlayMode?: string;
* Allow screen recording apps to capture the overlay.
* Disabled by default so the overlay doesn't appear in screenpipe's own recordings.
*/
-showOverlayInScreenRecording?: boolean }
+showOverlayInScreenRecording?: boolean;
+/**
+ * Video quality preset controlling storage vs quality tradeoff.
+ * Affects H.265 CRF during recording and JPEG quality during frame extraction.
+ * Values: "low", "balanced", "high", "max". Default: "balanced".
+ */
+videoQuality?: string }
export type ShowRewindWindow = "Main" | { Settings: { page: string | null } } | { Search: { query: string | null } } | "Onboarding" | "Chat" | "PermissionRecovery"
/**
* Sync configuration.
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index cd24257d8..dce46eece 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9007,7 +9007,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.291"
+version = "2.0.292"
dependencies = [
"anyhow",
"async-stream",
@@ -9089,7 +9089,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"anyhow",
"bytemuck",
@@ -9137,7 +9137,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -9188,7 +9188,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"anyhow",
"chrono",
@@ -9212,7 +9212,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"anyhow",
"chrono",
@@ -9228,7 +9228,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"anyhow",
"image 0.25.9",
@@ -9243,7 +9243,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"anyhow",
"async-trait",
@@ -9307,7 +9307,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.85"
+version = "0.3.86"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index da2fdaa6a..51804380c 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.0.291"
+version = "2.0.292"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/embedded_server.rs b/apps/screenpipe-app-tauri/src-tauri/src/embedded_server.rs
index 8decd8f35..fc160503d 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/embedded_server.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/embedded_server.rs
@@ -52,6 +52,7 @@ pub struct EmbeddedServerConfig {
pub use_chinese_mirror: bool,
pub user_id: Option<String>,
pub use_system_default_audio: bool,
+ pub video_quality: String,
}
impl EmbeddedServerConfig {
@@ -100,6 +101,7 @@ impl EmbeddedServerConfig {
None
},
use_system_default_audio: store.use_system_default_audio,
+ video_quality: store.video_quality.clone(),
}
}
}
@@ -357,6 +359,7 @@ pub async fn start_embedded_server(
// Use VisionManager for dynamic monitor detection (handles connect/disconnect)
info!("Using dynamic monitor detection (use_all_monitors=true)");
+ let video_quality = config.video_quality.clone();
let vision_config = VisionManagerConfig {
output_path,
fps,
@@ -370,6 +373,7 @@ pub async fn start_embedded_server(
capture_unfocused_windows: false,
realtime_vision: false,
activity_feed: None,
+ video_quality,
};
let vision_manager = Arc::new(VisionManager::new(
@@ -432,6 +436,7 @@ pub async fn start_embedded_server(
info!("Using static monitor list: {:?}", monitor_ids);
let output_path = Arc::new(output_path);
let shutdown_rx = shutdown_tx_clone.subscribe();
+ let video_quality = config.video_quality.clone();
tokio::spawn(async move {
let mut shutdown_rx = shutdown_rx;
@@ -453,6 +458,7 @@ pub async fn start_embedded_server(
false,
false,
None,
+ video_quality.clone(),
);
tokio::select! {
@@ -526,6 +532,7 @@ pub async fn start_embedded_server(
audio_manager.clone(),
false, // disable pipes
config.use_pii_removal,
+ config.video_quality.clone(),
);
// Start server in background
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
index a8f0eac53..c49328819 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
@@ -218,6 +218,15 @@ pub struct SettingsStore {
/// Disabled by default so the overlay doesn't appear in screenpipe's own recordings.
#[serde(rename = "showOverlayInScreenRecording", default)]
pub show_overlay_in_screen_recording: bool,
+ /// Video quality preset controlling storage vs quality tradeoff.
+ /// Affects H.265 CRF during recording and JPEG quality during frame extraction.
+ /// Values: "low", "balanced", "high", "max". Default: "balanced".
+ #[serde(rename = "videoQuality", default = "default_video_quality")]
+ pub video_quality: String,
+}
+
+fn default_video_quality() -> String {
+ "balanced".to_string()
}
fn generate_device_id() -> String {
@@ -506,6 +515,7 @@ impl Default for SettingsStore {
auto_update: true,
overlay_mode: "fullscreen".to_string(),
show_overlay_in_screen_recording: false,
+ video_quality: "balanced".to_string(),
}
}
}
diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rs
index cfe857a82..2dc6e99fc 100644
--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs
@@ -911,6 +911,7 @@ async fn main() -> anyhow::Result<()> {
capture_unfocused_windows: cli.capture_unfocused_windows,
realtime_vision: cli.enable_realtime_audio_transcription,
activity_feed: activity_feed,
+ video_quality: cli.video_quality.clone(),
};
Some(Arc::new(VisionManager::new(
config,
@@ -921,6 +922,7 @@ async fn main() -> anyhow::Result<()> {
None
};
+ let video_quality_for_server = cli.video_quality.clone();
let handle = if let Some(ref vm) = vision_manager {
// Use VisionManager for dynamic monitor detection
let vm_clone = vm.clone();
@@ -997,6 +999,7 @@ async fn main() -> anyhow::Result<()> {
cli.capture_unfocused_windows,
cli.enable_realtime_audio_transcription,
activity_feed_legacy,
+ cli.video_quality.clone(),
);
let result = tokio::select! {
@@ -1041,6 +1044,7 @@ async fn main() -> anyhow::Result<()> {
audio_manager.clone(),
cli.enable_pipe_manager,
cli.use_pii_removal,
+ video_quality_for_server,
);
// Attach sync handle if sync is enabled
diff --git a/crates/screenpipe-server/src/cli.rs b/crates/screenpipe-server/src/cli.rs
index 5701a8215..b6131e331 100644
--- a/crates/screenpipe-server/src/cli.rs
+++ b/crates/screenpipe-server/src/cli.rs
@@ -311,6 +311,12 @@ pub struct Cli {
#[arg(long, default_value_t = false)]
pub capture_unfocused_windows: bool,
+ /// Video quality preset: low, balanced, high, max.
+ /// Controls H.265 CRF during recording and JPEG quality during frame extraction.
+ /// low=smallest files, balanced=default, high=sharper, max=best quality.
+ #[arg(long, default_value = "balanced")]
+ pub video_quality: String,
+
/// Enable pipe functionality (default: false)
#[arg(long, default_value_t = false)]
pub enable_pipe_manager: bool,
diff --git a/crates/screenpipe-server/src/core.rs b/crates/screenpipe-server/src/core.rs
index 9c8ac6ce9..e67a357aa 100644
--- a/crates/screenpipe-server/src/core.rs
+++ b/crates/screenpipe-server/src/core.rs
@@ -30,6 +30,7 @@ pub async fn start_continuous_recording(
capture_unfocused_windows: bool,
realtime_vision: bool,
activity_feed: screenpipe_vision::ActivityFeedOption,
+ video_quality: String,
) -> Result<()> {
debug!("Starting video recording for monitors {:?}", monitor_ids);
let video_tasks = if !vision_disabled {
@@ -45,6 +46,7 @@ pub async fn start_continuous_recording(
let languages = languages.clone();
let activity_feed = activity_feed;
+ let video_quality = video_quality.clone();
debug!("Starting video recording for monitor {}", monitor_id);
vision_handle.spawn(async move {
@@ -66,6 +68,7 @@ pub async fn start_continuous_recording(
capture_unfocused_windows,
realtime_vision,
activity_feed,
+ video_quality.clone(),
)
.await
{
@@ -132,6 +135,7 @@ pub async fn record_video(
capture_unfocused_windows: bool,
realtime_vision: bool,
activity_feed: screenpipe_vision::ActivityFeedOption,
+ video_quality: String,
) -> Result<()> {
debug!("record_video: Starting for monitor {}", monitor_id);
let device_name = Arc::new(format!("monitor_{}", monitor_id));
@@ -180,6 +184,7 @@ pub async fn record_video(
languages,
capture_unfocused_windows,
activity_feed,
+ video_quality,
);
info!(
diff --git a/crates/screenpipe-server/src/lib.rs b/crates/screenpipe-server/src/lib.rs
index 60031bb8d..6b65015f0 100644
--- a/crates/screenpipe-server/src/lib.rs
+++ b/crates/screenpipe-server/src/lib.rs
@@ -35,7 +35,7 @@ pub use server::PaginatedResponse;
pub use server::SCServer;
pub use server::{api_list_monitors, MonitorInfo};
pub use sleep_monitor::start_sleep_monitor;
-pub use video::{FrameWriteInfo, FrameWriteTracker, VideoCapture};
+pub use video::{FrameWriteInfo, FrameWriteTracker, VideoCapture, video_quality_to_crf, video_quality_to_jpeg_q};
pub mod embedding;
pub use cloud_search::{CloudSearchClient, CloudSearchMetadata, CloudStatus};
pub use ui_recorder::{start_ui_recording, UiRecorderConfig, UiRecorderHandle};
diff --git a/crates/screenpipe-server/src/server.rs b/crates/screenpipe-server/src/server.rs
index 0406d74eb..a16cf4d5d 100644
--- a/crates/screenpipe-server/src/server.rs
+++ b/crates/screenpipe-server/src/server.rs
@@ -1691,7 +1691,7 @@ async fn write_frames_to_video(
video_file_path: &str,
fps: f64,
) -> Result<(), anyhow::Error> {
- let mut ffmpeg_child = start_ffmpeg_process(video_file_path, fps).await?;
+ let mut ffmpeg_child = start_ffmpeg_process(video_file_path, fps, "balanced").await?;
let mut ffmpeg_stdin = ffmpeg_child
.stdin
.take()
diff --git a/crates/screenpipe-server/src/video.rs b/crates/screenpipe-server/src/video.rs
index ae46cf3b9..b2372ed47 100644
--- a/crates/screenpipe-server/src/video.rs
+++ b/crates/screenpipe-server/src/video.rs
@@ -128,6 +128,7 @@ impl VideoCapture {
languages: Vec<Language>,
capture_unfocused_windows: bool,
activity_feed: screenpipe_vision::ActivityFeedOption,
+ video_quality: String,
) -> Self {
let fps = if fps.is_finite() && fps > 0.0 {
fps
@@ -314,6 +315,7 @@ impl VideoCapture {
let frame_write_tracker_clone = frame_write_tracker.clone();
let output_path = output_path.to_string();
+ let video_quality_clone = video_quality;
let video_thread = tokio::spawn(async move {
info!(
"Starting save_frames_as_video task for monitor {}",
@@ -327,6 +329,7 @@ impl VideoCapture {
monitor_id,
video_chunk_duration,
&frame_write_tracker_clone,
+ &video_quality_clone,
)
.await
{
@@ -432,7 +435,29 @@ impl Drop for VideoCapture {
}
}
-pub async fn start_ffmpeg_process(output_file: &str, fps: f64) -> Result<Child, anyhow::Error> {
+/// Map video quality preset to H.265 CRF value.
+/// Lower CRF = higher quality, larger files.
+pub fn video_quality_to_crf(quality: &str) -> &'static str {
+ match quality {
+ "low" => "32",
+ "high" => "18",
+ "max" => "14",
+ _ => "23", // "balanced" or any unknown
+ }
+}
+
+/// Map video quality preset to JPEG quality for frame extraction.
+/// Lower value = higher quality (scale 2-31).
+pub fn video_quality_to_jpeg_q(quality: &str) -> &'static str {
+ match quality {
+ "low" => "18",
+ "high" => "4",
+ "max" => "2",
+ _ => "10", // "balanced" or any unknown
+ }
+}
+
+pub async fn start_ffmpeg_process(output_file: &str, fps: f64, video_quality: &str) -> Result<Child, anyhow::Error> {
// Overriding fps with max fps if over the max and warning user
let fps = if fps > MAX_FPS {
warn!("Overriding FPS from {} to {}", fps, MAX_FPS);
@@ -459,6 +484,7 @@ pub async fn start_ffmpeg_process(output_file: &str, fps: f64) -> Result<Child,
"scale=trunc(iw/2)*2:trunc(ih/2)*2",
];
+ let crf = video_quality_to_crf(video_quality);
args.extend_from_slice(&[
"-vcodec",
"libx265",
@@ -467,7 +493,7 @@ pub async fn start_ffmpeg_process(output_file: &str, fps: f64) -> Result<Child,
"-preset",
"ultrafast",
"-crf",
- "23",
+ crf,
]);
// Use fragmented MP4 to allow reading frames while file is still being written
@@ -523,6 +549,7 @@ async fn save_frames_as_video(
monitor_id: u32,
video_chunk_duration: Duration,
frame_write_tracker: &Arc<FrameWriteTracker>,
+ video_quality: &str,
) -> Result<(), anyhow::Error> {
info!(
"Starting save_frames_as_video function for monitor {}",
@@ -570,7 +597,7 @@ async fn save_frames_as_video(
output_file, monitor_id
);
- match start_ffmpeg_process(&output_file, fps).await {
+ match start_ffmpeg_process(&output_file, fps, video_quality).await {
Ok(mut child) => {
let mut stdin = child.stdin.take().expect("Failed to open stdin");
spawn_ffmpeg_loggers(child.stderr.take(), child.stdout.take());
diff --git a/crates/screenpipe-server/src/video_utils.rs b/crates/screenpipe-server/src/video_utils.rs
index 320f5e23d..47e5452da 100644
--- a/crates/screenpipe-server/src/video_utils.rs
+++ b/crates/screenpipe-server/src/video_utils.rs
@@ -701,7 +701,7 @@ impl VideoMetadataOverride {
}
}
-pub async fn extract_frame_from_video(file_path: &str, offset_index: i64) -> Result<String> {
+pub async fn extract_frame_from_video(file_path: &str, offset_index: i64, jpeg_quality: &str) -> Result<String> {
let ffmpeg_path = find_ffmpeg_path().expect("failed to find ffmpeg path");
// Check if file exists first
@@ -805,7 +805,7 @@ pub async fn extract_frame_from_video(file_path: &str, offset_index: i64) -> Res
"-pix_fmt",
"yuvj420p", // Ensure proper pixel format
"-q:v",
- "10",
+ jpeg_quality,
"-y", // Force overwrite
output_path.to_str().unwrap(),
])
diff --git a/crates/screenpipe-server/src/vision_manager/manager.rs b/crates/screenpipe-server/src/vision_manager/manager.rs
index 5bf1f3e85..e7367d166 100644
--- a/crates/screenpipe-server/src/vision_manager/manager.rs
+++ b/crates/screenpipe-server/src/vision_manager/manager.rs
@@ -30,6 +30,7 @@ pub struct VisionManagerConfig {
pub capture_unfocused_windows: bool,
pub realtime_vision: bool,
pub activity_feed: screenpipe_vision::ActivityFeedOption,
+ pub video_quality: String,
}
/// Status of the VisionManager
@@ -165,6 +166,7 @@ impl VisionManager {
let capture_unfocused_windows = self.config.capture_unfocused_windows;
let realtime_vision = self.config.realtime_vision;
let activity_feed = self.config.activity_feed;
+ let video_quality = self.config.video_quality.clone();
// Spawn the recording task using the existing record_video function
let handle = self.vision_handle.spawn(async move {
@@ -184,6 +186,7 @@ impl VisionManager {
capture_unfocused_windows,
realtime_vision,
activity_feed,
+ video_quality.clone(),
)
.await
{