Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(recording): anchor Instant audio at the recording start on every platform
Richie McIlroy0345804ef4a7
diff --git a/crates/recording/src/instant_recording.rs b/crates/recording/src/instant_recording.rsindex 759025f1f..6868d62f6 100644--- a/crates/recording/src/instant_recording.rs+++ b/crates/recording/src/instant_recording.rs@@ -788,11 +788,11 @@ async fn create_pipeline(let audio_dir = content_dir.join("audio");let mut builder = output_pipeline::OutputPipeline::builder(audio_dir.clone()).with_timestamps(start_time)- .with_start_gate(start_gate.clone());- #[cfg(target_os = "linux")]- {- builder = builder.with_audio_anchor(output_pipeline::AudioAnchor::PipelineEpoch);- }+ .with_start_gate(start_gate.clone())+ // Zero is the recording start, not the first audio sample: a mic+ // that becomes ready late, or loopback system audio that delivers+ // only while sound plays, would otherwise move all audio early.+ .with_audio_anchor(output_pipeline::AudioAnchor::PipelineEpoch);if let Some(sys_audio) = system_audio_source {builder = builderdiff --git a/crates/verify/expectations.toml b/crates/verify/expectations.tomlindex 09db7f249..8cb78fdfe 100644--- a/crates/verify/expectations.toml+++ b/crates/verify/expectations.toml@@ -254,30 +254,6 @@ link = "https://github.com/CapSoftware/Cap/pull/2636"# finalize_instant_output). Each audio source is its own class, so a known# loss or offset of one source cannot hide the other's.-[[xfail]]-case = "export/instant-ungated-mic-late/output/mp4/native"-class = "sync-mic"-platforms = ["macos", "windows"]-bound = { count = 1, offset-ms = [-210, -190] }-reason = "NEW: the Instant audio track is anchored at its first sample (AudioAnchor::FirstFrame) and nothing aligns it to the screen afterwards: a mic that becomes ready 0.2 s after the screen plays 200 ms early in output.mp4 (-198.7 to -201.1 ms measured). Bound: early by the mic's start delay"-link = ""--[[xfail]]-case = "export/instant-ungated-system-loopback/output/mp4/native"-class = "sync-system"-platforms = ["macos", "windows"]-bound = { count = 1, offset-ms = [-270, -250] }-reason = "NEW: same anchor, loopback-style system audio (WASAPI delivers packets only while sound plays): the first sound becomes audio zero, so all audio is early by the time to first sound (260 ms here; -253.7 to -260.2 ms measured)"-link = ""--[[xfail]]-case = "export/instant-gated-system-only/output/mp4/native"-class = "sync-system"-platforms = ["macos", "windows"]-bound = { count = 1, offset-ms = [-240, -215] }-reason = "NEW: same first-sample anchor behind the start gate, loopback-only system audio: the first sound after the gate becomes audio zero, so the system audio is early by the time from the gate to the first sound (-226.7 ms in every run on macOS and Windows; Linux, which anchors Instant audio at the recording epoch, is only up to one frame late, see the gated sync-system entry)"-link = ""-[[xfail]]case = "export/instant-gated-*mic*/output/mp4/native"class = "sync-mic"@@ -289,7 +265,7 @@ link = ""case = "export/instant-gated-system-*/output/mp4/native"class = "sync-system"bound = { count = 1, offset-ms = [5, 34] }-reason = "NEW: the gate's per-pipeline zero, as the gated sync-mic entry: system audio late by up to one video frame (13.3 to 15.1 ms measured; on macOS and Windows the loopback-only variant is the first-sample anchor entry instead)"+reason = "NEW: the gate's per-pipeline zero, as the gated sync-mic entry: system audio late by up to one video frame (12.2 to 15.1 ms measured)"link = ""[[xfail]]diff --git a/crates/verify/src/pipeline.rs b/crates/verify/src/pipeline.rsindex b1fa13003..b30fa11bf 100644--- a/crates/verify/src/pipeline.rs+++ b/crates/verify/src/pipeline.rs@@ -669,11 +669,9 @@ pub async fn record_instant(spec: &InstantSpec, dir: &Path) -> anyhow::Result<()if let Some(gate) = &gate {builder = builder.with_start_gate(Some(gate.clone()));}- // Mirrors the product's Instant audio pipeline, which anchors at the- // recording epoch on Linux only.- if cfg!(target_os = "linux") {- builder = builder.with_audio_anchor(cap_recording::AudioAnchor::PipelineEpoch);- }+ // Mirrors the product's Instant audio pipeline, anchored at the recording+ // epoch.+ builder = builder.with_audio_anchor(cap_recording::AudioAnchor::PipelineEpoch);let has_audio = spec.mic_delay.is_some() || spec.system_audio;if spec.system_audio {let track = marker_track(AudioSource::System, spec.duration);