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: make screenpipe index copy files by default

Louis Beaumontb0685c8fd6d7
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 754a1ff9b..da14c4201 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -286,6 +286,7 @@ async fn main() -> anyhow::Result<()> {
pattern,
ocr_engine,
metadata_override,
+ copy_videos,
} => {
let local_data_dir = get_base_dir(&data_dir)?;
let db = Arc::new(
@@ -299,8 +300,17 @@ async fn main() -> anyhow::Result<()> {
e
})?,
);
- handle_index_command(path, pattern, db, output, ocr_engine, metadata_override)
- .await?;
+ handle_index_command(
+ local_data_dir,
+ path,
+ pattern,
+ db,
+ output,
+ ocr_engine,
+ metadata_override,
+ copy_videos,
+ )
+ .await?;
return Ok(());
}
}
diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rs
index 23e270b7b..bda62922c 100644
--- a/screenpipe-server/src/cli.rs
+++ b/screenpipe-server/src/cli.rs
@@ -298,7 +298,7 @@ pub enum Command {
#[command(subcommand)]
subcommand: PipeCommand,
},
- /// Index video files for search
+ /// Index video files for search - DOES NOT SUPPORT AUDIO
Index {
/// Path to folder containing video files
path: String,
@@ -317,6 +317,9 @@ pub enum Command {
/// Path to JSON file containing metadata overrides
#[arg(long)]
metadata_override: Option<PathBuf>,
+ /// Copy videos to screenpipe data directory
+ #[arg(long, default_value_t = true)]
+ copy_videos: bool,
},
/// Setup screenpipe environment
Setup {
diff --git a/screenpipe-server/src/index.rs b/screenpipe-server/src/index.rs
index dbc80543a..74a6f2be0 100644
--- a/screenpipe-server/src/index.rs
+++ b/screenpipe-server/src/index.rs
@@ -1,6 +1,7 @@
use anyhow::Result;
use image::DynamicImage;
use regex::Regex;
+use screenpipe_vision::perform_ocr_tesseract;
use screenpipe_vision::utils::{compare_with_previous_image, OcrEngine};
#[cfg(target_os = "macos")]
@@ -13,10 +14,13 @@ use screenpipe_vision::perform_ocr_windows;
use screenpipe_vision::perform_ocr_tesseract;
use serde_json::json;
+use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
+use tokio::fs;
use tokio::sync::mpsc;
use tracing::{debug, error, info};
+use uuid::Uuid;
use walkdir::WalkDir;
use crate::{
@@ -26,12 +30,14 @@ use crate::{
};
pub async fn handle_index_command(
+ screenpipe_dir: PathBuf,
path: String,
pattern: Option<String>,
db: Arc<DatabaseManager>,
output_format: crate::cli::OutputFormat,
ocr_engine: Option<CliOcrEngine>,
metadata_override: Option<PathBuf>,
+ copy_videos: bool,
) -> Result<()> {
// Load metadata override if provided
let metadata_overrides = if let Some(path) = metadata_override {
@@ -78,7 +84,24 @@ pub async fn handle_index_command(
for video_path in video_files {
info!("processing video: {}", video_path.display());
- let video_path = &video_path;
+ let video_path_for_processing = if copy_videos {
+ // Generate unique filename using UUID
+ let ext = video_path.extension().unwrap_or_default();
+ let new_filename = format!("{}.{}", Uuid::new_v4(), ext.to_string_lossy());
+
+ // Construct path in screenpipe data directory
+ let target_path = Path::new(&screenpipe_dir).join("data").join(new_filename);
+
+ // Copy the file
+ info!("copying video to: {}", target_path.display());
+ fs::copy(&video_path, &target_path).await?;
+
+ target_path
+ } else {
+ video_path.clone()
+ };
+
+ let video_path = &video_path_for_processing;
let mut metadata = get_video_metadata(video_path.to_str().unwrap()).await?;
// Apply metadata override if provided and matches the file