feat: honor separate audio tracks via the FFmpeg backend, fix stream-specifier args
This commit is contained in:
1 parent
dd91910f98
commit
78fc2951a8
3 files changed
+125
-7
No files matched your search
@@ -57,7 +57,7 @@
|
||||
## Not Fully Working Yet
|
||||
|
||||
- Native Windows Graphics Capture and FFmpeg capture finalization have not yet been manually QA-tested on real NVIDIA/AMD/Intel gaming systems.
|
||||
- Native WASAPI audio is mixed into a single AAC track for MVP clips; separate audio tracks and per-process audio capture are still future work (the separate-audio-tracks setting is stored but not yet honored by the encoder).
|
||||
- Native WASAPI audio is mixed into a single AAC track for MVP clips; separate audio tracks are now honored by the FFmpeg recording backend (routing around the single-track native WGC encoder), while per-process audio capture remains future work.
|
||||
- Valve GSI receiver is a lightweight MVP receiver; config templates can be generated from the Auto Clip screen. CS2 event mapping is now enriched with round, bomb, and match-start metadata, but full per-game mapping for Dota 2 and other Source titles is still needed.
|
||||
- Auto start/stop is conservative but live: when auto-record is enabled, supported detected games can start recording and stop when the game disappears.
|
||||
- Recorder service still runs inside the Tauri process instead of a separate background service process.
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
## Next Engineering Steps
|
||||
|
||||
1. Honor the separate-audio-tracks setting by encoding system and mic audio to distinct tracks, and consider per-process loopback capture.
|
||||
1. Add per-process loopback capture so individual application audio can be captured independently of the system mix.
|
||||
2. Add full per-game Valve GSI event mapping for Dota 2 and other Source titles beyond the current CS2 enrichment.
|
||||
3. Add installer/onboarding screens for privacy, capture source, storage, and hotkeys.
|
||||
4. Exercise the GitHub Actions release workflow with a real tag push and verify the published assets appear in a GitHub Release.
|
||||
|
||||
+26
-3
@@ -1684,9 +1684,32 @@ fn start_best_capture_backend(
|
||||
native_mic_available: bool,
|
||||
ffmpeg_system_audio_available: bool,
|
||||
) -> Result<ActiveCaptureBackend, String> {
|
||||
if (!config.system_audio_enabled || native_system_audio_available)
|
||||
&& (!config.mic_enabled || native_mic_available)
|
||||
{
|
||||
let separate_tracks =
|
||||
config.system_audio_enabled && config.mic_enabled && config.separate_audio_tracks;
|
||||
|
||||
// windows-capture exposes a single mixed audio channel, so distinct system/mic tracks
|
||||
// can only be encoded through the FFmpeg backend. Prefer it when the user enabled
|
||||
// separate tracks; fall back to native WGC if FFmpeg cannot start (recording must not
|
||||
// be blocked by a backend choice).
|
||||
if separate_tracks {
|
||||
let mut ffmpeg_backend =
|
||||
FfmpegReplayCaptureBackend::new(ffmpeg, segment_pattern, segment_duration);
|
||||
let mut ffmpeg_config = config.clone();
|
||||
if ffmpeg_config.system_audio_enabled && !ffmpeg_system_audio_available {
|
||||
ffmpeg_config.system_audio_enabled = false;
|
||||
}
|
||||
if ffmpeg_backend.start(ffmpeg_config).is_ok() {
|
||||
return Ok(ActiveCaptureBackend::Ffmpeg(ffmpeg_backend));
|
||||
}
|
||||
}
|
||||
|
||||
if clipforge::capture::native_capture_can_honor_audio(
|
||||
config.system_audio_enabled,
|
||||
config.mic_enabled,
|
||||
config.separate_audio_tracks,
|
||||
native_system_audio_available,
|
||||
native_mic_available,
|
||||
) {
|
||||
let mut native = NativeWgcReplayCaptureBackend::new(segment_pattern, segment_duration);
|
||||
if native.start(config.clone()).is_ok() {
|
||||
return Ok(ActiveCaptureBackend::NativeWgc(native));
|
||||
|
||||
+97
-2
@@ -160,6 +160,23 @@ pub fn ffmpeg_supports_filter(executable: &std::path::Path, filter: &str) -> boo
|
||||
.any(|line| line.split_whitespace().any(|part| part == filter))
|
||||
}
|
||||
|
||||
/// Returns true when the single-track native WGC encoder can satisfy the requested audio
|
||||
/// configuration. windows-capture exposes one mixed audio channel, so distinct system/mic
|
||||
/// tracks are only achievable through the FFmpeg backend and route there instead.
|
||||
pub fn native_capture_can_honor_audio(
|
||||
system_audio_enabled: bool,
|
||||
mic_enabled: bool,
|
||||
separate_audio_tracks: bool,
|
||||
native_system_audio_available: bool,
|
||||
native_mic_available: bool,
|
||||
) -> bool {
|
||||
if system_audio_enabled && mic_enabled && separate_audio_tracks {
|
||||
return false;
|
||||
}
|
||||
(!system_audio_enabled || native_system_audio_available)
|
||||
&& (!mic_enabled || native_mic_available)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FfmpegRecordingPlan {
|
||||
pub executable: PathBuf,
|
||||
@@ -298,9 +315,9 @@ fn base_desktop_input_args(config: &CaptureConfig) -> Vec<String> {
|
||||
args.extend([
|
||||
"-map".to_string(),
|
||||
format!("{}:a?", input_idx),
|
||||
"-c:a:{}".to_string(), idx.to_string(),
|
||||
format!("-c:a:{idx}"),
|
||||
"aac".to_string(),
|
||||
"-b:a:{}".to_string(), idx.to_string(),
|
||||
format!("-b:a:{idx}"),
|
||||
"160k".to_string(),
|
||||
]);
|
||||
}
|
||||
@@ -572,4 +589,82 @@ mod tests {
|
||||
"wasapi"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn separate_tracks_map_distinct_audio_inputs() {
|
||||
let config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::DesktopDuplication,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: true,
|
||||
mic_enabled: true,
|
||||
system_audio_device: None,
|
||||
mic_device: Some("Microphone".to_string()),
|
||||
separate_audio_tracks: true,
|
||||
};
|
||||
|
||||
let plan = FfmpegRecordingPlan::for_windows_desktop_segments(
|
||||
"ffmpeg",
|
||||
"segment-%05d.mp4",
|
||||
&config,
|
||||
Duration::from_secs(5),
|
||||
);
|
||||
|
||||
assert!(plan.args.iter().any(|arg| arg == "-map"));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "1:a?"]));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "2:a?"]));
|
||||
assert!(plan.args.iter().any(|arg| arg == "-c:a:0"));
|
||||
assert!(plan.args.iter().any(|arg| arg == "-c:a:1"));
|
||||
assert!(plan.args.iter().any(|arg| arg == "wasapi"));
|
||||
assert!(plan.args.iter().any(|arg| arg.contains("Microphone")));
|
||||
assert!(!plan.args.windows(3).any(|triple| triple == ["-c:a", "aac", "-b:a"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_mixed_audio_keeps_single_track_encoding_when_separate_tracks_off() {
|
||||
let config = CaptureConfig {
|
||||
source: CaptureSource::Desktop,
|
||||
method: CaptureMethod::GdiGrab,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fps: 30,
|
||||
bitrate_kbps: 6000,
|
||||
encoder: EncoderPreference::HardwareH264,
|
||||
system_audio_enabled: true,
|
||||
mic_enabled: true,
|
||||
system_audio_device: None,
|
||||
mic_device: Some("Microphone".to_string()),
|
||||
separate_audio_tracks: false,
|
||||
};
|
||||
|
||||
let plan = FfmpegRecordingPlan::for_windows_desktop("ffmpeg", "out.mp4", &config);
|
||||
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "1:a?"]));
|
||||
assert!(plan.args.windows(2).any(|pair| pair == ["-map", "2:a?"]));
|
||||
assert!(plan.args.windows(3).any(|triple| triple == ["-c:a", "aac", "-b:a"]));
|
||||
assert!(!plan.args.iter().any(|arg| arg == "-c:a:0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_cannot_honor_separate_tracks() {
|
||||
assert!(!native_capture_can_honor_audio(true, true, true, true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_honors_single_source_combinations() {
|
||||
assert!(native_capture_can_honor_audio(true, false, true, true, false));
|
||||
assert!(native_capture_can_honor_audio(false, true, true, false, true));
|
||||
assert!(native_capture_can_honor_audio(true, true, false, true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_capture_requires_available_native_sources() {
|
||||
assert!(!native_capture_can_honor_audio(true, false, false, false, true));
|
||||
assert!(!native_capture_can_honor_audio(false, true, false, true, false));
|
||||
assert!(native_capture_can_honor_audio(false, false, true, false, false));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user