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

update cli table + video chunk duration configurable thru cli

Louis Beaumontd98ae85b6342
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 382120f98..437d3acf6 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -288,6 +288,8 @@ async fn main() -> anyhow::Result<()> {
let shutdown_tx_clone = shutdown_tx.clone();
let friend_wearable_uid_clone: Option<String> = friend_wearable_uid.clone(); // Clone here
let monitor_ids_clone = monitor_ids.clone();
+ let ignored_windows_clone = cli.ignored_windows.clone();
+ let included_windows_clone = cli.included_windows.clone();
let fps = if cli.fps.is_finite() && cli.fps > 0.0 {
cli.fps
@@ -316,6 +318,7 @@ async fn main() -> anyhow::Result<()> {
output_path_clone.clone(),
fps,
Duration::from_secs(cli.audio_chunk_duration),
+ Duration::from_secs(cli.video_chunk_duration),
vision_control_clone.clone(),
audio_devices_control.clone(),
cli.disable_audio,
@@ -398,6 +401,10 @@ async fn main() -> anyhow::Result<()> {
"│ Audio Chunk Duration│ {:<34} │",
format!("{} seconds", cli.audio_chunk_duration)
);
+ println!(
+ "│ Video Chunk Duration│ {:<34} │",
+ format!("{} seconds", cli.video_chunk_duration)
+ );
println!("│ Port │ {:<34} │", cli.port);
println!("│ Audio Disabled │ {:<34} │", cli.disable_audio);
println!("│ Vision Disabled │ {:<34} │", cli.disable_vision);
@@ -432,6 +439,19 @@ async fn main() -> anyhow::Result<()> {
"Disabled".to_string()
}
);
+ println!("│ Use PII Removal │ {:<34} │", cli.use_pii_removal);
+ println!(
+ "│ Ignored Windows │ {:<34} │",
+ format_cell(&format!("{:?}", &ignored_windows_clone), VALUE_WIDTH)
+ );
+ println!(
+ "│ Included Windows │ {:<34} │",
+ format_cell(&format!("{:?}", &included_windows_clone), VALUE_WIDTH)
+ );
+ println!(
+ "│ Friend Wearable UID │ {:<34} │",
+ cli.friend_wearable_uid.as_deref().unwrap_or("Not set")
+ );
const VALUE_WIDTH: usize = 34;
// Function to truncate and pad strings
diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rs
index 3def3e896..b2b489fe7 100644
--- a/screenpipe-server/src/cli.rs
+++ b/screenpipe-server/src/cli.rs
@@ -184,6 +184,10 @@ pub struct Cli {
#[arg(long)]
pub included_windows: Vec<String>,
+ /// Video chunk duration in seconds
+ #[arg(long, default_value_t = 30)]
+ pub video_chunk_duration: u64,
+
#[command(subcommand)]
pub command: Option<Command>,
}
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index e16f7332e..df4953a45 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -27,6 +27,7 @@ pub async fn start_continuous_recording(
output_path: Arc<String>,
fps: f64,
audio_chunk_duration: Duration,
+ video_chunk_duration: Duration,
vision_control: Arc<AtomicBool>,
audio_devices_control: Arc<SegQueue<(AudioDevice, DeviceControl)>>,
audio_disabled: bool,
@@ -97,6 +98,7 @@ pub async fn start_continuous_recording(
use_pii_removal,
&ignored_windows_video,
&include_windows_video,
+ video_chunk_duration,
)
.await
})
@@ -167,6 +169,7 @@ async fn record_video(
use_pii_removal: bool,
ignored_windows: &[String],
include_windows: &[String],
+ video_chunk_duration: Duration,
) -> Result<()> {
debug!("record_video: Starting");
let db_chunk_callback = Arc::clone(&db);
@@ -185,6 +188,7 @@ async fn record_video(
let video_capture = VideoCapture::new(
&output_path,
fps,
+ video_chunk_duration,
new_chunk_callback,
save_text_files,
Arc::clone(&ocr_engine),
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index ec439fb56..f1d89ac23 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -28,6 +28,7 @@ impl VideoCapture {
pub fn new(
output_path: &str,
fps: f64,
+ video_chunk_duration: Duration,
new_chunk_callback: impl Fn(&str) + Send + Sync + 'static,
save_text_files: bool,
ocr_engine: Arc<OcrEngine>,
@@ -128,6 +129,7 @@ impl VideoCapture {
fps,
new_chunk_callback_clone,
monitor_id,
+ video_chunk_duration,
)
.await;
});
@@ -144,9 +146,10 @@ async fn save_frames_as_video(
fps: f64,
new_chunk_callback: Arc<dyn Fn(&str) + Send + Sync>,
monitor_id: u32,
+ video_chunk_duration: Duration,
) {
debug!("Starting save_frames_as_video function");
- let frames_per_video = (fps * 30.0).round() as usize; // 30 seconds of video
+ let frames_per_video = (fps * video_chunk_duration.as_secs_f64()).round() as usize;
let mut frame_count = 0;
let (sender, mut receiver): (Sender<Vec<u8>>, Receiver<Vec<u8>>) = channel(512);
let sender = Arc::new(sender);