Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
undo some merge conflict problems
Brendan Allan302608476111
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rsindex da239710d..6cac81597 100644--- a/apps/desktop/src-tauri/src/main.rs+++ b/apps/desktop/src-tauri/src/main.rs@@ -35,6 +35,18 @@ use ffmpeg_sidecar::{use winit::monitor::{MonitorHandle, VideoMode};+macro_rules! generate_handler {+ ($($command:ident),*) => {{+ #[cfg(debug_assertions)]+ tauri_specta::ts::export(+ specta::collect_types![$($command),*],+ "../src/utils/commands.ts"+ ).unwrap();++ tauri::generate_handler![$($command),*]+ }}+}+fn main() {let _ = fix_path_env::fix();@@ -73,6 +85,7 @@ fn main() {handle_ffmpeg_installation().expect("Failed to install FFmpeg");#[tauri::command]+ #[specta::specta]async fn start_server(window: Window) -> Result<u16, String> {start(move |url| {let _ = window.emit("redirect_uri", url);@@ -81,6 +94,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn open_screen_capture_preferences() {#[cfg(target_os = "macos")]std::process::Command::new("open")@@ -90,6 +104,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn open_mic_preferences() {#[cfg(target_os = "macos")]std::process::Command::new("open")@@ -99,6 +114,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn open_camera_preferences() {#[cfg(target_os = "macos")]std::process::Command::new("open")@@ -108,6 +124,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn reset_screen_permissions() {#[cfg(target_os = "macos")]std::process::Command::new("tccutil")@@ -119,6 +136,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn reset_microphone_permissions() {#[cfg(target_os = "macos")]std::process::Command::new("tccutil")@@ -130,6 +148,7 @@ fn main() {}#[tauri::command]+ #[specta::specta]fn reset_camera_permissions() {#[cfg(target_os = "macos")]std::process::Command::new("tccutil")@@ -221,7 +240,8 @@ fn main() {media_process: None,recording_options: None,shutdown_flag: Arc::new(AtomicBool::new(false)),- uploading_finished: Arc::new(AtomicBool::new(false)),+ video_uploading_finished: Arc::new(AtomicBool::new(false)),+ audio_uploading_finished: Arc::new(AtomicBool::new(false)),data_dir: Some(data_directory),max_screen_width: max_width as usize,max_screen_height: max_height as usize,@@ -307,7 +327,7 @@ fn main() {Ok(())})- .invoke_handler(tauri::generate_handler![+ .invoke_handler(generate_handler![start_dual_recording,stop_all_recordings,enumerate_audio_devices,@@ -318,7 +338,7 @@ fn main() {has_screen_capture_access,reset_screen_permissions,reset_microphone_permissions,- reset_camera_permissions,+ reset_camera_permissions]).plugin(tauri_plugin_context_menu::init()).system_tray(tray)diff --git a/apps/desktop/src-tauri/src/media.rs b/apps/desktop/src-tauri/src/media.rsindex 669474daf..baa90ae77 100644--- a/apps/desktop/src-tauri/src/media.rs+++ b/apps/desktop/src-tauri/src/media.rs@@ -4,7 +4,7 @@ use cpal::SampleFormat;use image::codecs::jpeg::JpegEncoder;use image::{ImageBuffer, ImageFormat, Rgba};use std::io::{Error, ErrorKind::WouldBlock};-use std::path::Path;+use std::path::{Path, PathBuf};use std::process::Stdio;use std::sync::{atomic::{AtomicBool, Ordering},@@ -37,7 +37,7 @@ pub struct MediaRecorder {video_channel_receiver: Option<mpsc::Receiver<Vec<u8>>>,should_stop: Arc<AtomicBool>,start_time: Option<Instant>,- file_path: Option<String>,+ file_path: Option<PathBuf>,}impl MediaRecorder {@@ -61,8 +61,9 @@ impl MediaRecorder {pub async fn start_media_recording(&mut self,options: RecordingOptions,- chunks_file_path: &str,- screenshot_file_path: &str,+ audio_chunks_dir: &Path,+ video_chunks_dir: &Path,+ screenshot_folder: &Path,custom_device: Option<&str>,max_screen_width: usize,max_screen_height: usize,@@ -305,7 +306,7 @@ impl MediaRecorder {}let video_start_time_clone = Arc::clone(&video_start_time);- let screenshot_file_path_owned = format!("{screenshot_file_path}/screen-capture.jpg");+ let screenshot_file_path = screenshot_folder.join("screen-capture.jpg");let capture_frame_at = Duration::from_secs(3);std::thread::spawn(move || {@@ -354,16 +355,14 @@ impl MediaRecorder {if now - start_time >= capture_frame_at && !screenshot_captured {screenshot_captured = true;- let screenshot_file_path_owned_cloned =- screenshot_file_path_owned.clone();let mut frame_data_clone = frame_data.clone();+ let screenshot_file_path = screenshot_file_path.clone();std::thread::spawn(move || {for chunk in frame_data_clone.chunks_mut(4) {chunk.swap(0, 2);}- let path = Path::new(&screenshot_file_path_owned_cloned);let image: ImageBuffer<Rgba<u8>, Vec<u8>> =ImageBuffer::from_raw(adjusted_width.try_into().unwrap(),@@ -372,29 +371,33 @@ impl MediaRecorder {).expect("Failed to create image buffer");- let mut output_file = std::fs::File::create(&path)- .expect("Failed to create output file");+ let mut output_file =+ std::fs::File::create(&screenshot_file_path)+ .expect("Failed to create output file");let mut encoder =JpegEncoder::new_with_quality(&mut output_file, 20);if let Err(e) = encoder.encode_image(&image) {eprintln!("Failed to save screenshot: {}", e);} else {+ println!(+ "Screenshot captured and saved to {:?}",+ screenshot_file_path+ );+if !is_local_mode {let rt = tokio::runtime::Runtime::new().unwrap();- let screenshot_file_path_owned_cloned_copy =- screenshot_file_path_owned_cloned.clone();- rt.block_on(async {+ rt.block_on(async move {let upload_task = tokio::spawn(upload_file(Some(options_clone),- screenshot_file_path_owned_cloned_copy.clone(),+ screenshot_file_path.clone(),upload::FileType::Screenshot,));match upload_task.await {Ok(result) => match result {Ok(_) => println!("Screenshot captured and saved to {:?}",- path+ screenshot_file_path),Err(e) => eprintln!("Failed to upload file: {}",@@ -407,7 +410,6 @@ impl MediaRecorder {}});}- println!("Screenshot captured and saved to {:?}", path);}});}@@ -456,8 +458,10 @@ impl MediaRecorder {});println!("Starting audio recording and processing...");- let output_chunk_pattern = format!("{chunks_file_path}/recording_%03d.ts");- let segment_list_filename = format!("{chunks_file_path}/segment_list.txt");+ let audio_chunk_pattern = chunks_file_path.join("audio/recording_%03d.aac");+ let video_chunk_pattern = chunks_file_path.join("video/recording_%03d.ts");+ let audio_segment_list_filename = chunks_file_path.join("audio/segment_list.txt");+ let video_segment_list_filename = chunks_file_path.join("video/segment_list.txt");let mut audio_filters = Vec::new();@@ -467,14 +471,14 @@ impl MediaRecorder {audio_filters.push("loudnorm");- std::fs::create_dir_all(format!("{chunks_file_path}/pipes")).map_err(|e| e.to_string())?;+ std::fs::create_dir_all(chunks_file_path.join("pipes")).map_err(|e| e.to_string())?;- let video_pipe_path = format!("{chunks_file_path}/pipes/video.pipe");+ let video_pipe_path = chunks_file_path.join("pipes/video.pipe");std::fs::remove_file(&video_pipe_path).ok();create_named_pipe(&video_pipe_path).map_err(|e| e.to_string())?;- let audio_pipe_path = format!("{chunks_file_path}/pipes/audio.pipe");+ let audio_pipe_path = chunks_file_path.join("pipes/audio.pipe");std::fs::remove_file(&audio_pipe_path).ok();create_named_pipe(&audio_pipe_path).map_err(|e| e.to_string())?;@@ -487,71 +491,57 @@ impl MediaRecorder {};let size = format!("{}x{}", adjusted_width, adjusted_height);- let mut ffmpeg_command = flatten_str_args([- ["-f", "rawvideo"],- ["-pix_fmt", "bgra"],- ["-s", &size],- ["-r", "30"],- ["-thread_queue_size", "4096"],- ["-i", &video_pipe_path],- ]);-- let mut audio_args = flatten_str_args([- // in- ["-f", sample_format],- ["-ar", &sample_rate_str],- ["-ac", &channels_str],- ["-thread_queue_size", "4096"],- ["-i", &audio_pipe_path],- // out- [- "-af",- "aresample=async=1:min_hard_comp=0.100000:first_pts=0",- ],- ["-c:a", "aac"],- ["-b:a", "128k"],- ["-async", "1"],- ]);-- match time_offset {- Some((TimeOffsetTarget::Video, args)) => {- ffmpeg_command.splice(0..0, args.clone()).collect()- }- Some((TimeOffsetTarget::Audio, args)) => {- audio_args.splice(0..0, args.clone()).collect()- }- None => {- vec![]- }- };- if needs_audio {- ffmpeg_command.extend(audio_args);+ let mut ffmpeg_command = Command::new(ffmpeg_binary_path_str);++ if let Some((TimeOffsetTarget::Video, args)) = &time_offset {+ ffmpeg_command.args(args);}- ffmpeg_command.extend(flatten_str_args([- ["-vf", "fps=30,scale=in_range=full:out_range=limited"],- ["-c:v", "libx264"],- ["-preset", "ultrafast"],- ["-pix_fmt", "yuv420p"],- ["-tune", "zerolatency"],- ["-vsync", "1"],- ["-force_key_frames", "expr:gte(t,n_forced*3)"],- ["-f", "segment"],- ["-segment_time", "3"],- ["-segment_time_delta", "0.01"],- ["-segment_list", &segment_list_filename],- ["-segment_format", "ts"],- ["-movflags", "frag_keyframe+empty_moov"],- ["-reset_timestamps", "1"],- ]));-- ffmpeg_command.push(output_chunk_pattern);+ ffmpeg_command+ // video in+ .args(["-f", "rawvideo", "-pix_fmt", "bgra"])+ .args(["-s", &size, "-r", "30"])+ .args(["-thread_queue_size", "4096", "-i"])+ .arg(&video_pipe_path)+ // video out+ .args(["-vf", "fps=30,scale=in_range=full:out_range=limited"])+ .args(["-codec:v", "libx264", "-preset", "ultrafast"])+ .args(["-pix_fmt", "yuv420p", "-tune", "zerolatency"])+ .args(["-vsync", "1", "-force_key_frames", "expr:gte(t,n_forced*3)"])+ .args(["-f", "segment", "-movflags", "frag_keyframe+empty_moov"])+ .args(["-reset_timestamps", "1", "-an"])+ .args(["-segment_time", "3"])+ .args(["-segment_format", "ts"])+ .args(["-segment_time_delta", "0.01", "-segment_list"])+ .args([&video_segment_list_filename, &video_chunk_pattern]);++ if needs_audio {+ if let Some((TimeOffsetTarget::Audio, args)) = &time_offset {+ ffmpeg_command.args(args);+ }++ ffmpeg_command+ // audio in+ .args(["-f", sample_format, "-ar", &sample_rate_str])+ .args(["-ac", &channels_str, "-thread_queue_size", "4096", "-i"])+ .arg(&audio_pipe_path)+ // out+ .args([+ "-af",+ "aresample=async=1:min_hard_comp=0.100000:first_pts=0",+ ])+ .args(["-codec:a", "aac", "-b:a", "128k"])+ .args(["-async", "1", "-f", "segment"])+ .args(["-segment_time", "3", "-segment_time_delta", "0.01"])+ .args(["-reset_timestamps", "1", "-vn", "-segment_list"])+ .args([&audio_segment_list_filename, &audio_chunk_pattern]);+ }println!("Starting FFmpeg process...");let (ffmpeg_child, ffmpeg_stdin) = self- .start_ffmpeg_process(&ffmpeg_binary_path_str, &ffmpeg_command)+ .start_ffmpeg_process(ffmpeg_command).await.map_err(|e| e.to_string())?;println!("Ffmpeg process started");@@ -604,7 +594,7 @@ impl MediaRecorder {});self.start_time = Some(Instant::now());- self.file_path = Some(chunks_file_path.to_string());+ self.file_path = Some(chunks_file_path.to_path_buf());self.ffmpeg_process = Some(ffmpeg_child);self.device_name = Some(device.name().expect("Failed to get device name"));@@ -630,7 +620,7 @@ impl MediaRecorder {let recording_duration = start_time.elapsed();let expected_segments = recording_duration.as_secs() / segment_duration.as_secs();let file_path = self.file_path.as_ref().ok_or("File path not set")?;- let segment_list_filename = format!("{}/segment_list.txt", file_path);+ let segment_list_filename = file_path.join("segment_list.txt");loop {let segments = std::fs::read_to_string(&segment_list_filename).unwrap_or_default();@@ -683,15 +673,14 @@ impl MediaRecorder {async fn start_ffmpeg_process(&self,- ffmpeg_binary_path: &str,- video_ffmpeg_command: &[String],+ cmd: Command,+ // ffmpeg_binary_path: &str,+ // video_ffmpeg_command: &[String],) -> Result<(Child, ChildStdin), Error> {- let mut video_process = start_recording_process(ffmpeg_binary_path, video_ffmpeg_command)- .await- .map_err(|e| {- eprintln!("Failed to start video recording process: {}", e);- std::io::Error::new(std::io::ErrorKind::Other, e.to_string())- })?;+ let mut video_process = start_recording_process(cmd).await.map_err(|e| {+ eprintln!("Failed to start video recording process: {}", e);+ std::io::Error::new(std::io::ErrorKind::Other, e.to_string())+ })?;let video_stdin = video_process.stdin.take().ok_or_else(|| {eprintln!("Failed to take video stdin");@@ -703,6 +692,7 @@ impl MediaRecorder {}#[tauri::command]+#[specta::specta]pub fn enumerate_audio_devices() -> Vec<String> {let host = cpal::default_host();let default_device = host@@ -733,14 +723,11 @@ pub fn enumerate_audio_devices() -> Vec<String> {use tokio::io::{AsyncBufReadExt, BufReader};async fn start_recording_process(- ffmpeg_binary_path_str: &str,- args: &[String],+ mut cmd: Command,+ // ffmpeg_binary_path_str: &str,+ // args: &[String],) -> Result<tokio::process::Child, std::io::Error> {- let mut process = Command::new(ffmpeg_binary_path_str)- .args(args)- .stdin(Stdio::piped())- .stderr(Stdio::piped())- .spawn()?;+ let mut process = cmd.stdin(Stdio::piped()).stderr(Stdio::piped()).spawn()?;if let Some(process_stderr) = process.stderr.take() {tokio::spawn(async move {diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex fe881ed01..f52d02e70 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -21,7 +21,8 @@ pub struct RecordingState {pub media_process: Option<MediaRecorder>,pub recording_options: Option<RecordingOptions>,pub shutdown_flag: Arc<AtomicBool>,- pub uploading_finished: Arc<AtomicBool>,+ pub video_uploading_finished: Arc<AtomicBool>,+ pub audio_uploading_finished: Arc<AtomicBool>,pub data_dir: Option<PathBuf>,pub max_screen_width: usize,pub max_screen_height: usize,@@ -32,7 +33,7 @@ unsafe impl Sync for RecordingState {}unsafe impl Send for MediaRecorder {}unsafe impl Sync for MediaRecorder {}-#[derive(Debug, Serialize, Deserialize, Clone)]+#[derive(Debug, Serialize, Deserialize, Clone, specta::Type)]pub struct RecordingOptions {pub user_id: String,pub video_id: String,@@ -44,6 +45,7 @@ pub struct RecordingOptions {}#[tauri::command]+#[specta::specta]pub async fn start_dual_recording(state: State<'_, Arc<Mutex<RecordingState>>>,options: RecordingOptions,@@ -62,9 +64,11 @@ pub async fn start_dual_recording(println!("data_dir: {:?}", data_dir);let screenshot_dir = data_dir.join("screenshots");- let chunks_dir = data_dir.join("chunks");+ let audio_chunks_dir = data_dir.join("chunks/audio");+ let video_chunks_dir = data_dir.join("chunks/video");- clean_and_create_dir(&chunks_dir)?;+ clean_and_create_dir(&audio_chunks_dir)?;+ clean_and_create_dir(&video_chunks_dir)?;clean_and_create_dir(&screenshot_dir)?;let audio_name = if options.audio_name.is_empty() {@@ -75,7 +79,8 @@ pub async fn start_dual_recording(let media_recording_preparation = prepare_media_recording(&options,- &chunks_dir,+ &audio_chunks_dir,+ &video_chunks_dir,&screenshot_dir,audio_name,state_guard.max_screen_width,@@ -88,7 +93,8 @@ pub async fn start_dual_recording(state_guard.media_process = Some(media_recording_result);state_guard.recording_options = Some(options.clone());state_guard.shutdown_flag = shutdown_flag.clone();- state_guard.uploading_finished = Arc::new(AtomicBool::new(false));+ state_guard.video_uploading_finished = Arc::new(AtomicBool::new(false));+ state_guard.audio_uploading_finished = Arc::new(AtomicBool::new(false));let is_local_mode = match dotenv_codegen::dotenv!("NEXT_PUBLIC_LOCAL_MODE") {"true" => true,@@ -96,6 +102,20 @@ pub async fn start_dual_recording(};if !is_local_mode {+ let screen_upload = start_upload_loop(+ video_chunks_dir.clone(),+ options.clone(),+ "video".to_string(),+ shutdown_flag.clone(),+ state_guard.video_uploading_finished.clone(),+ );+ let audio_upload = start_upload_loop(+ audio_chunks_dir,+ options.clone(),+ "audio".to_string(),+ shutdown_flag.clone(),+ state_guard.audio_uploading_finished.clone(),+ );let upload = start_upload_loop(chunks_dir.clone(),options.clone(),@@ -123,6 +143,7 @@ pub async fn start_dual_recording(}#[tauri::command]+#[specta::specta]pub async fn stop_all_recordings(state: State<'_, Arc<Mutex<RecordingState>>>,) -> Result<(), String> {@@ -182,6 +203,7 @@ fn clean_and_create_dir(dir: &Path) -> Result<(), String> {async fn start_upload_loop(chunks_dir: PathBuf,options: RecordingOptions,+ file_type: upload::FileType,shutdown_flag: Arc<AtomicBool>,uploading_finished: Arc<AtomicBool>,) -> Result<(), String> {@@ -207,11 +229,9 @@ async fn start_upload_loop(let segment_path = chunks_dir.join(segment_filename);if segment_path.is_file() {let options_clone = options.clone();- let segment_path_clone = segment_path.clone();upload_tasks.push(tokio::spawn(async move {- let filepath_str = segment_path_clone.to_str().unwrap_or_default().to_owned();- println!("Uploading video: {}", filepath_str);- upload_file(Some(options_clone), filepath_str, upload::FileType::Segment)+ println!("Uploading video for {file_type}: {segment_path:?}");+ upload_file(Some(options_clone), segment_path, file_type).await.map(|_| ())}));@@ -247,19 +267,19 @@ fn load_segment_list(segment_list_path: &Path) -> io::Result<HashSet<String>> {async fn prepare_media_recording(options: &RecordingOptions,screenshot_dir: &Path,+ audio_chunks_dir: &Path,video_chunks_dir: &Path,audio_name: Option<String>,max_screen_width: usize,max_screen_height: usize,) -> Result<MediaRecorder, String> {let mut media_recorder = MediaRecorder::new();- let video_file_path = video_chunks_dir.to_str().unwrap();- let screenshot_dir_path = screenshot_dir.to_str().unwrap();media_recorder.start_media_recording(options.clone(),- screenshot_dir_path,- video_file_path,+ screenshot_dir,+ audio_chunks_dir,+ video_chunks_dir,audio_name.as_ref().map(String::as_str),max_screen_width,max_screen_height,diff --git a/apps/desktop/src-tauri/src/upload.rs b/apps/desktop/src-tauri/src/upload.rsindex 57089ce81..4909a6b5f 100644--- a/apps/desktop/src-tauri/src/upload.rs+++ b/apps/desktop/src-tauri/src/upload.rs@@ -1,22 +1,25 @@use regex::Regex;use reqwest;use serde_json::Value as JsonValue;-use std::path::Path;+use std::path::{Path, PathBuf};use std::process::{Command, Output};use std::str;use crate::recording::RecordingOptions;use crate::utils::ffmpeg_path_as_str;+#[derive(Clone, Copy)]pub enum FileType {- Segment,+ Video,+ Audio,Screenshot,}impl std::fmt::Display for FileType {fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {match self {- FileType::Segment => write!(f, "segment"),+ FileType::Video => write!(f, "video"),+ FileType::Audio => write!(f, "audio"),FileType::Screenshot => write!(f, "screenshot"),}}@@ -24,7 +27,7 @@ impl std::fmt::Display for FileType {pub async fn upload_file(options: Option<RecordingOptions>,- file_path: String,+ file_path: PathBuf,file_type: FileType,) -> Result<String, String> {if let Some(ref options) = options {@@ -41,18 +44,15 @@ pub async fn upload_file(.to_string();let file_key = format!(- "{}/{}/{}/{}",- options.user_id,- options.video_id,- file_type.to_string(),- file_name+ "{}/{}/{file_type}/{file_name}",+ options.user_id, options.video_id,);let server_url_base: &'static str = dotenv_codegen::dotenv!("NEXT_PUBLIC_URL");let server_url = format!("{}/api/upload/signed", server_url_base);let body = match file_type {- FileType::Segment => {+ FileType::Video => {let (codec_name, width, height, frame_rate, bit_rate) = log_video_info(&file_path).map_err(|e| format!("Failed to log video info: {}", e))?;@@ -68,7 +68,7 @@ pub async fn upload_file("videoCodec": codec_name,})}- FileType::Screenshot => {+ FileType::Audio | FileType::Screenshot => {serde_json::json!({"userId": options.user_id,"fileKey": file_key,@@ -110,11 +110,13 @@ pub async fn upload_file(form = form.text(key.to_string(), value_str.to_owned());}- println!("Uploading file: {}", file_path);+ println!("Uploading file: {file_path:?}");- let mime_type = if file_path.to_lowercase().ends_with(".aac") {+ let mime_type = if file_path.extension().unwrap() == ".aac" {"audio/aac"- } else if file_path.to_lowercase().ends_with(".webm") {+ } else if file_path.extension().unwrap() == ".mp3" {+ "audio/mpeg"+ } else if file_path.extension().unwrap() == ".webm" {"audio/webm"} else {"video/mp2t"@@ -162,7 +164,7 @@ pub async fn upload_file(}}- println!("Removing file after upload: {}", file_path);+ println!("Removing file after upload: {file_path:?}");let remove_result = tokio::fs::remove_file(&file_path).await;match &remove_result {Ok(_) => println!("File removed successfully"),@@ -176,7 +178,7 @@ pub async fn upload_file(}}-pub fn get_video_duration(file_path: &str) -> Result<f64, std::io::Error> {+pub fn get_video_duration(file_path: &Path) -> Result<f64, std::io::Error> {let ffmpeg_binary_path_str = ffmpeg_path_as_str().unwrap().to_owned();let output = Command::new(ffmpeg_binary_path_str)@@ -185,19 +187,19 @@ pub fn get_video_duration(file_path: &str) -> Result<f64, std::io::Error> {.output()?;let output_str = str::from_utf8(&output.stderr).unwrap();- let duration_regex = Regex::new(r"Duration: (\d{2}):(\d{2}):(\d{2})\.\d{2}").unwrap();+ let duration_regex = Regex::new(r"Duration: (\d{2}):(\d{2}):(\d{2})\.(\d{2})").unwrap();let caps = duration_regex.captures(output_str).unwrap();let hours: f64 = caps.get(1).unwrap().as_str().parse().unwrap();let minutes: f64 = caps.get(2).unwrap().as_str().parse().unwrap();- let seconds: f64 = caps.get(3).unwrap().as_str().parse().unwrap();-- let duration = hours * 3600.0 + minutes * 60.0 + seconds;+ let seconds: f64 = caps.get(3).unwrap().as_str().parse::<f64>().unwrap();+ let milliseconds: f64 = caps.get(4).unwrap().as_str().parse::<f64>().unwrap() / 100.0;+ let duration = hours * 3600.0 + minutes * 60.0 + seconds + milliseconds;Ok(duration)}-fn log_video_info(file_path: &str) -> Result<(String, String, String, String, String), String> {+fn log_video_info(file_path: &Path) -> Result<(String, String, String, String, String), String> {let output: Output = Command::new("ffprobe").arg("-v").arg("error")diff --git a/apps/desktop/src-tauri/src/utils.rs b/apps/desktop/src-tauri/src/utils.rsindex 00a770716..4413b6cac 100644--- a/apps/desktop/src-tauri/src/utils.rs+++ b/apps/desktop/src-tauri/src/utils.rs@@ -104,7 +104,7 @@ pub fn ffmpeg_path_as_str() -> Result<String, String> {}}-pub fn create_named_pipe(path: &str) -> Result<(), nix::Error> {+pub fn create_named_pipe(path: &Path) -> Result<(), nix::Error> {use nix::sys::stat;use nix::unistd;unistd::mkfifo(path, stat::Mode::S_IRWXU)?;