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

fix(windows): add CREATE_NO_WINDOW flag to all subprocess spawns

louis0301956946c03eba69
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index 05b3d9bb2..bc7b7878b 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -8612,7 +8612,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "2.0.227"
+version = "2.0.225"
dependencies = [
"anyhow",
"async-stream",
@@ -8692,7 +8692,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"anyhow",
"bytemuck",
@@ -8740,7 +8740,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -8791,7 +8791,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"anyhow",
"chrono",
@@ -8815,7 +8815,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"anyhow",
"chrono",
@@ -8831,7 +8831,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"anyhow",
"image 0.25.5",
@@ -8846,7 +8846,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"anyhow",
"async-trait",
@@ -8910,7 +8910,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.21"
+version = "0.3.19"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/screenpipe-audio/src/utils/ffmpeg.rs b/screenpipe-audio/src/utils/ffmpeg.rs
index 1b581e040..e3a4b98aa 100644
--- a/screenpipe-audio/src/utils/ffmpeg.rs
+++ b/screenpipe-audio/src/utils/ffmpeg.rs
@@ -45,6 +45,13 @@ fn encode_single_audio(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ command.creation_flags(CREATE_NO_WINDOW);
+ }
+
debug!("FFmpeg command: {:?}", command);
#[allow(clippy::zombie_processes)]
diff --git a/screenpipe-server/src/auto_destruct.rs b/screenpipe-server/src/auto_destruct.rs
index 174bd95c2..56bdffab2 100644
--- a/screenpipe-server/src/auto_destruct.rs
+++ b/screenpipe-server/src/auto_destruct.rs
@@ -48,21 +48,25 @@ pub async fn watch_pid(pid: u32) -> bool {
}
// Fallback to Command approach
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+
let pid_output = Command::new("tasklist")
.args(&["/FI", &format!("PID eq {}", pid), "/NH", "/FO", "CSV"])
+ .creation_flags(CREATE_NO_WINDOW)
.output()
.expect("failed to check pid");
- let app_output = Command::new("tasklist")
- .args(&[
- "/FI",
- "IMAGENAME eq screenpipe-app.exe",
- "/NH",
- "/FO",
- "CSV",
- ])
- .output()
- .expect("failed to check app name");
+ let mut app_cmd = Command::new("tasklist");
+ app_cmd.args(&[
+ "/FI",
+ "IMAGENAME eq screenpipe-app.exe",
+ "/NH",
+ "/FO",
+ "CSV",
+ ]);
+ app_cmd.creation_flags(CREATE_NO_WINDOW);
+ let app_output = app_cmd.output().expect("failed to check app name");
let pid_alive = String::from_utf8_lossy(&pid_output.stdout).contains(&pid.to_string());
let app_alive = !String::from_utf8_lossy(&app_output.stdout).is_empty();
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 998d63f90..1a7e9abbe 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -471,6 +471,13 @@ pub async fn start_ffmpeg_process(output_file: &str, fps: f64) -> Result<Child,
.stdout(Stdio::piped())
.stderr(Stdio::piped());
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ command.creation_flags(CREATE_NO_WINDOW);
+ }
+
debug!("FFmpeg command: {:?}", command);
let child = command.spawn()?;
diff --git a/screenpipe-server/src/video_cache.rs b/screenpipe-server/src/video_cache.rs
index b03258c8e..05ef51689 100644
--- a/screenpipe-server/src/video_cache.rs
+++ b/screenpipe-server/src/video_cache.rs
@@ -741,6 +741,13 @@ async fn extract_frame(
output_pattern.to_str().unwrap(),
]);
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
debug!("running ffmpeg command: {:?}", cmd);
let output = cmd.output().await?;
@@ -849,11 +856,17 @@ async fn is_video_file_complete(ffmpeg_path: &PathBuf, file_path: &str) -> Resul
}
}
- match Command::new(ffmpeg_path)
- .args(["-v", "error", "-i", file_path, "-f", "null", "-"])
- .output()
- .await
+ let mut cmd = Command::new(ffmpeg_path);
+ cmd.args(["-v", "error", "-i", file_path, "-f", "null", "-"]);
+
+ #[cfg(windows)]
{
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ match cmd.output().await {
Ok(output) => {
let is_complete = output.status.success();
if !is_complete {
@@ -1010,10 +1023,17 @@ impl OrderedFrameStreamer {
}
async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {
- let output = Command::new(ffmpeg_path)
- .args(["-i", video_path])
- .output()
- .await?;
+ let mut cmd = Command::new(ffmpeg_path);
+ cmd.args(["-i", video_path]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let output = cmd.output().await?;
// ffmpeg outputs metadata to stderr by design
let metadata = String::from_utf8_lossy(&output.stderr);
diff --git a/screenpipe-server/src/video_utils.rs b/screenpipe-server/src/video_utils.rs
index 61ef60886..9fffe2384 100644
--- a/screenpipe-server/src/video_utils.rs
+++ b/screenpipe-server/src/video_utils.rs
@@ -97,6 +97,13 @@ pub async fn extract_frame(file_path: &str, offset_index: i64) -> Result<String>
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped());
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ command.creation_flags(CREATE_NO_WINDOW);
+ }
+
debug!("ffmpeg command: {:?}", command);
let mut child = command.spawn()?;
@@ -144,10 +151,17 @@ pub async fn validate_media(file_path: &str) -> Result<()> {
}
let ffmpeg_path = find_ffmpeg_path().expect("failed to find ffmpeg path");
- let status = Command::new(ffmpeg_path)
- .args(["-v", "error", "-i", file_path, "-f", "null", "-"])
- .output()
- .await?;
+ let mut cmd = Command::new(ffmpeg_path);
+ cmd.args(["-v", "error", "-i", file_path, "-f", "null", "-"]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let status = cmd.output().await?;
if status.status.success() {
Ok(())
@@ -192,21 +206,28 @@ pub async fn merge_videos(
}
let ffmpeg_path = find_ffmpeg_path().expect("failed to find ffmpeg path");
- let status = Command::new(ffmpeg_path)
- .args([
- "-f",
- "concat",
- "-safe",
- "0",
- "-i",
- temp_file.to_str().unwrap(),
- "-c",
- "copy",
- "-y",
- output_path.to_str().unwrap(),
- ])
- .output()
- .await?;
+ let mut cmd = Command::new(ffmpeg_path);
+ cmd.args([
+ "-f",
+ "concat",
+ "-safe",
+ "0",
+ "-i",
+ temp_file.to_str().unwrap(),
+ "-c",
+ "copy",
+ "-y",
+ output_path.to_str().unwrap(),
+ ]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let status = cmd.output().await?;
// clean up the temporary file
tokio::fs::remove_file(temp_file).await?;
@@ -277,31 +298,38 @@ pub async fn extract_frames_from_video(
let fps_filter = format!("fps={}", target_fps);
// Extract frames using ffmpeg
- let status = Command::new(&ffmpeg_path)
- .args([
- "-i",
- video_path.to_str().unwrap(),
- "-vf",
- &fps_filter,
- "-strict",
- "unofficial",
- "-c:v",
- "mjpeg",
- "-q:v",
- "2",
- "-qmin",
- "2",
- "-qmax",
- "4",
- "-vsync",
- "0",
- "-threads",
- "2",
- "-y",
- output_pattern.to_str().unwrap(),
- ])
- .output()
- .await?;
+ let mut cmd = Command::new(&ffmpeg_path);
+ cmd.args([
+ "-i",
+ video_path.to_str().unwrap(),
+ "-vf",
+ &fps_filter,
+ "-strict",
+ "unofficial",
+ "-c:v",
+ "mjpeg",
+ "-q:v",
+ "2",
+ "-qmin",
+ "2",
+ "-qmax",
+ "4",
+ "-vsync",
+ "0",
+ "-threads",
+ "2",
+ "-y",
+ output_pattern.to_str().unwrap(),
+ ]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let status = cmd.output().await?;
if !status.status.success() {
let stderr = String::from_utf8_lossy(&status.stderr);
@@ -343,21 +371,28 @@ async fn get_video_fps(ffmpeg_path: &PathBuf, video_path: &str) -> Result<f64> {
async fn get_video_fps_and_duration(ffmpeg_path: &PathBuf, video_path: &str) -> Result<(f64, f64)> {
let ffprobe_path = get_ffprobe_path(ffmpeg_path);
- let output = Command::new(&ffprobe_path)
- .args([
- "-v",
- "quiet",
- "-print_format",
- "json",
- "-select_streams",
- "v:0", // Select first video stream
- "-show_entries",
- "stream=r_frame_rate:format=duration", // Request frame rate and duration
- "-show_format",
- video_path,
- ])
- .output()
- .await?;
+ let mut cmd = Command::new(&ffprobe_path);
+ cmd.args([
+ "-v",
+ "quiet",
+ "-print_format",
+ "json",
+ "-select_streams",
+ "v:0", // Select first video stream
+ "-show_entries",
+ "stream=r_frame_rate:format=duration", // Request frame rate and duration
+ "-show_format",
+ video_path,
+ ]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let output = cmd.output().await?;
if !output.status.success() {
let error = String::from_utf8_lossy(&output.stderr);
@@ -423,21 +458,27 @@ pub async fn get_video_metadata(video_path: &str) -> Result<VideoMetadata> {
let ffprobe_path = get_ffprobe_path(&ffmpeg_path);
// Try ffprobe first
- let creation_time = match Command::new(&ffprobe_path)
- .args([
- "-v",
- "quiet",
- "-print_format",
- "json",
- "-show_format",
- "-show_streams",
- "-show_entries",
- "format_tags=creation_time",
- video_path,
- ])
- .output()
- .await
+ let mut cmd = Command::new(&ffprobe_path);
+ cmd.args([
+ "-v",
+ "quiet",
+ "-print_format",
+ "json",
+ "-show_format",
+ "-show_streams",
+ "-show_entries",
+ "format_tags=creation_time",
+ video_path,
+ ]);
+
+ #[cfg(windows)]
{
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let creation_time = match cmd.output().await {
Ok(output) if output.status.success() => {
let stdout = String::from_utf8_lossy(&output.stdout);
let metadata: FFprobeOutput = serde_json::from_str(&stdout)?;
@@ -492,18 +533,25 @@ pub async fn get_video_metadata(video_path: &str) -> Result<VideoMetadata> {
// Helper function to get fps and duration
async fn get_video_technical_metadata(ffprobe_path: &Path, video_path: &str) -> Result<(f64, f64)> {
- let output = Command::new(ffprobe_path)
- .args([
- "-v",
- "quiet",
- "-print_format",
- "json",
- "-show_format",
- "-show_streams",
- video_path,
- ])
- .output()
- .await?;
+ let mut cmd = Command::new(ffprobe_path);
+ cmd.args([
+ "-v",
+ "quiet",
+ "-print_format",
+ "json",
+ "-show_format",
+ "-show_streams",
+ video_path,
+ ]);
+
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+
+ let output = cmd.output().await?;
let stdout = String::from_utf8_lossy(&output.stdout);
let metadata: FFprobeOutput = serde_json::from_str(&stdout)?;
@@ -674,6 +722,13 @@ pub async fn extract_frame_from_video(file_path: &str, offset_index: i64) -> Res
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped());
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ command.creation_flags(CREATE_NO_WINDOW);
+ }
+
debug!("ffmpeg command: {:?}", command);
let output = command.output().await?;
@@ -768,6 +823,13 @@ pub async fn extract_high_quality_frame(
output_path.to_str().unwrap(),
]);
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x08000000;
+ command.creation_flags(CREATE_NO_WINDOW);
+ }
+
let output = command.output().await?;
if !output.status.success() {
let error_msg = String::from_utf8_lossy(&output.stderr);