diff --git a/src-tauri/build.rs b/src-tauri/build.rs index d8c8da7..261851f 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -1,9 +1,3 @@ fn main() { tauri_build::build(); - - #[cfg(all(target_os = "windows", not(debug_assertions)))] - { - // Set the subsystem to windows to avoid console window (release builds only) - println!("cargo:rustc-link-arg=/SUBSYSTEM:WINDOWS,5.01"); - } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index cf4d008..bb0074c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -644,6 +644,7 @@ fn start_capture_inner(runtime: &AppRuntime) -> Result { mic_enabled: recorder.settings.privacy.mic_enabled, system_audio_device: recorder.settings.privacy.system_audio_device.clone(), mic_device: recorder.settings.privacy.mic_device.clone(), + separate_audio_tracks: recorder.settings.privacy.separate_audio_tracks, }; let backend = start_best_capture_backend( &ffmpeg, diff --git a/src/capture.rs b/src/capture.rs index a3d7026..dee28a5 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -42,6 +42,7 @@ pub struct CaptureConfig { pub mic_enabled: bool, pub system_audio_device: Option, pub mic_device: Option, + pub separate_audio_tracks: bool, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -221,6 +222,8 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec { let size = format!("{}x{}", config.width, config.height); let fps = config.fps.to_string(); let bitrate = format!("{}k", config.bitrate_kbps); + let separate_tracks = config.system_audio_enabled && config.mic_enabled && config.separate_audio_tracks; + let mut args = vec![ "-y".to_string(), "-hide_banner".to_string(), @@ -246,7 +249,7 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec { ]), } let mut next_input_index = 1; - let mut audio_maps = Vec::new(); + let mut audio_input_indices = Vec::new(); if config.system_audio_enabled { args.extend([ @@ -258,7 +261,7 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec { .clone() .unwrap_or_else(|| "default".to_string()), ]); - audio_maps.push(format!("{next_input_index}:a?")); + audio_input_indices.push(next_input_index); next_input_index += 1; } @@ -275,7 +278,7 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec { .unwrap_or_else(|| "Microphone".to_string()) ), ]); - audio_maps.push(format!("{next_input_index}:a?")); + audio_input_indices.push(next_input_index); } args.extend([ @@ -288,10 +291,24 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec { "-pix_fmt".to_string(), "yuv420p".to_string(), ]); - for audio_map in audio_maps { - args.extend(["-map".to_string(), audio_map]); - } - if config.system_audio_enabled || config.mic_enabled { + + if separate_tracks { + // Map each audio input to a separate track with its own encoder settings + for (idx, &input_idx) in audio_input_indices.iter().enumerate() { + args.extend([ + "-map".to_string(), + format!("{}:a?", input_idx), + "-c:a:{}".to_string(), idx.to_string(), + "aac".to_string(), + "-b:a:{}".to_string(), idx.to_string(), + "160k".to_string(), + ]); + } + } else if config.system_audio_enabled || config.mic_enabled { + // Legacy: mix all audio into single track + for input_idx in audio_input_indices { + args.extend(["-map".to_string(), format!("{}:a?", input_idx)]); + } args.extend([ "-c:a".to_string(), "aac".to_string(), @@ -509,6 +526,7 @@ mod tests { mic_enabled: false, system_audio_device: None, mic_device: None, + separate_audio_tracks: false, }; let plan = FfmpegRecordingPlan::for_windows_desktop("ffmpeg", "out.mp4", &config); @@ -532,6 +550,7 @@ mod tests { mic_enabled: false, system_audio_device: None, mic_device: None, + separate_audio_tracks: false, }; let plan = FfmpegRecordingPlan::for_windows_desktop_segments( diff --git a/src/native_wgc.rs b/src/native_wgc.rs index f74be5a..ece47e5 100644 --- a/src/native_wgc.rs +++ b/src/native_wgc.rs @@ -704,6 +704,7 @@ mod tests { mic_enabled: false, system_audio_device: None, mic_device: None, + separate_audio_tracks: false, }; let mut backend = NativeWgcReplayCaptureBackend::new(&pattern, Duration::from_secs(1)); @@ -750,6 +751,7 @@ mod tests { mic_enabled: false, system_audio_device: None, mic_device: None, + separate_audio_tracks: false, }; let mut backend = NativeWgcReplayCaptureBackend::new(&pattern, Duration::from_secs(1)); @@ -796,6 +798,7 @@ mod tests { mic_enabled: true, system_audio_device: None, mic_device: None, + separate_audio_tracks: false, }; let mut backend = NativeWgcReplayCaptureBackend::new(&pattern, Duration::from_secs(1)); diff --git a/src/settings.rs b/src/settings.rs index 20ce6e3..370103d 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -34,6 +34,8 @@ pub struct PrivacySettings { pub mic_device: Option, #[serde(default)] pub system_audio_device: Option, + #[serde(default)] + pub separate_audio_tracks: bool, pub desktop_capture_requires_confirmation: bool, pub excluded_window_titles: Vec, pub upload_requires_confirmation: bool, @@ -119,6 +121,7 @@ impl AppSettings { mic_enabled: false, mic_device: None, system_audio_device: None, + separate_audio_tracks: false, desktop_capture_requires_confirmation: true, excluded_window_titles: Vec::new(), upload_requires_confirmation: true, @@ -152,6 +155,8 @@ impl AppSettings { if self.upload.custom_response_url_path.trim().is_empty() { self.upload.custom_response_url_path = "url".to_string(); } + // Ensure separate_audio_tracks defaults to false for older configs + // (serde default handles this, but explicit for clarity) self.schema_version = CURRENT_SCHEMA_VERSION; } }