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: InvalidFilename on windows

wangshifeng6ef5c6f5402e
diff --git a/README.md b/README.md
index 3c6185172..fec5b7cf5 100644
--- a/README.md
+++ b/README.md
@@ -158,7 +158,7 @@ sqlite3 screen-pipe/data/db.sqlite ".mode json" ".once /dev/stdout" "SELECT * FR
Play a sample frame_recording from the database</summary>
```bash
-ffplay "screen-pipe/data/2024-07-12 01:14:14.078958 UTC.mp4"
+ffplay "screen-pipe/data/2024-07-12_01-14-14.mp4"
```
</details>
<details>
diff --git a/data/2024-07-12 01:14:14.078958 UTC.mp4 b/data/2024-07-12 01:14:14.078958 UTC.mp4
deleted file mode 100644
index 2dc807b37..000000000
Binary files a/data/2024-07-12 01:14:14.078958 UTC.mp4 and /dev/null differ
diff --git a/screenpipe-server/src/bin/screenpipe-video.rs b/screenpipe-server/src/bin/screenpipe-video.rs
index 1f27689b6..e402cc5d3 100644
--- a/screenpipe-server/src/bin/screenpipe-video.rs
+++ b/screenpipe-server/src/bin/screenpipe-video.rs
@@ -1,4 +1,4 @@
-use chrono::Utc;
+use chrono::Local;
use env_logger::Env;
use image::GenericImageView;
use log::info;
@@ -21,9 +21,11 @@ fn write_json_frame(writer: &mut BufWriter<File>, frame_data: &Value) -> std::io
fn main() {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
- let time = Utc::now();
+ let time = Local::now();
+ let formatted_time = time.format("%Y-%m-%d_%H-%M-%S").to_string();
let output_path = "data";
- let json_output_path = format!("data/{}.json", time);
+ let json_output_path = format!("data/{}.json", formatted_time);
+
// create dir if not exists
std::fs::create_dir_all("data").unwrap_or_default();
info!("Created data directory {}", output_path);
diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rs
index 18a31a9bc..1b8de6bb0 100644
--- a/screenpipe-server/src/video.rs
+++ b/screenpipe-server/src/video.rs
@@ -1,4 +1,4 @@
-use chrono::Utc;
+use chrono::Local;
use ffmpeg_next as ffmpeg;
use ffmpeg_next::sys::AVSEEK_FLAG_FRAME;
use ffmpeg_next::{format, format::Pixel, media, software::scaling, util::frame::video::Video};
@@ -240,9 +240,11 @@ fn save_frames_as_video(
.write_to(&mut std::io::Cursor::new(&mut buffer), ImageFormat::Png)
.expect("Failed to encode first frame");
- let time = Utc::now();
+ let time = Local::now();
+ let formatted_time = time.format("%Y-%m-%d_%H-%M-%S").to_string();
// Start new FFmpeg process with a new output file
- let output_file = format!("{}/{}.mp4", output_path, time);
+ let output_file = format!("{}/{}.mp4", output_path, formatted_time);
+
// Call the callback with the new video chunk file path
new_chunk_callback(&output_file); // TODO better error handling