Repository navigation
fix(linux-v4l2): frame-sync the Virtual Camera with its microphone (OBS Audio), drop stale FIFO audio (#4087) - #4093
Conversation
…one audio (#4087) video_waits_for_its_audio, held_video_is_bounded and stale_audio_is_dropped fail against the stubs; ci/vcam_av_sync.py measures the A/V offset of a running OBS over obs-websocket (baseline: audio 732 ms behind video).
…p stale FIFO audio, name it OBS Audio (#4087) Frames wait (at most 64) until the audio with the same timestamp has gone to the microphone; audio waiting unread in the FIFO beyond one packet is thrown away, so an app that links later hears the newest audio. The microphone's description becomes "OBS Audio"; the source name obs_virtual_microphone and the camera's "OBS Virtual Camera" label stay, since existing setups select them by name.
…'s 8192-frame buffer (#4087) On the device, after frame sync audio still trailed by 162-176 ms: the tunnel keeps target_buffer = 8192 frames (170.7 ms) and no argument changes it. pipewire_tunnel_lead_is_8192_frames and video_waits_for_the_tunnel fail against the stub.
…nel's buffer too (#4087) Under pipewire-pulse (a source's driver column reads PipeWire), frames wait an extra 8192 frames of audio, the tunnel's fixed target_buffer, so they leave with the sound that comes out of the tunnel. The hold ring grows to 128 frames for 60 fps with deep audio buffering.
|
Device measurement with
The mic is listed as "OBS Audio". The remaining ~170 ms comes from PipeWire's pipe tunnel, which keeps a fixed RED cb1a6d9 / GREEN 0bd1dc9 also hold frames for those 8192 frames when the server is pipewire-pulse. A device run on 0bd1dc9 will follow. |
|
Device result on dca7330 (AppImage from verify run 42543994284, plugin swapped into the running desktop OBS). The libpulse source list now carries the driver column, so the PipeWire tunnel hold applies.
Before this PR the audio was 732 ms late. The residual is under two frames, audio slightly early, which is inside the usual lip-sync tolerance. |
Fixes #4087
Problem
On Linux the virtual mic trailed the Virtual Camera picture by 732 ms: video arrived 143 ms after the clip started, audio 875 ms after. There were two causes:
raw_videoframes to the output as they render, but passesraw_audioonly after its audio buffering (490 ms in the user's session). The writer did not line the two up.Change (
plugins/linux-v4l2/v4l2-output.c.h)vmic_drop_stale).obs_virtual_microphoneand the camera label "OBS Virtual Camera" stay the same. The OBS wiki, Debian and Snap docs, and users' modprobe configs select the camera by that label, so renaming it would break existing setups.ci/vcam_av_sync.pydrives OBS over obs-websocket. It plays a clip where a white flash and a 1 kHz beep start on the same frame, records/dev/video9and the mic in one ffmpeg process with wall-clock timestamps, and printsav_offset_ms.Tests
video_waits_for_its_audio,held_video_is_boundedandstale_audio_is_droppedfail against the stubs.video_is_not_held_without_microphonepasses against both.test_v4l2_vmic_servernow expects the "OBS Audio" description.test_v4l2_vcam_audiopass count goes from 14 to 18.