Repository navigation
libobs: Fix monitoring for media with cover art - #2531
Merged
zackees merged 2 commits intoOct 26, 2026
Merged
Conversation
zackees
reviewed
Oct 26, 2026
zackees
left a comment
Member
There was a problem hiding this comment.
Reviewed:
- The RED commit moves the tracking out without changing it.
- GREEN adds the upstream line that saves the new timestamp.
- Behaviour change:
util_mul_div64is now computed on every packet, where before it ran only when the timestamp stood still. It has no side effects and costs very little. - The header has no OS code. The new tests cover first play, restarts and moving video, plus a real
ffmpeg_sourcerun with a cover-art file. - No existing test was changed, and the ledger line is present.
Queuing; it goes in when CI is green.
Member
|
The Windows Rust Tier 2 failure here (LNK2005 on |
Move the WASAPI monitor's video timestamp tracking into the shared header monitor-video-sync.h, unchanged, so it runs on every platform, and test it: test_monitor_video_sync feeds it a still cover, a restart with a new cover timestamp and moving video; test_media_cover_art_monitor feeds it the real ffmpeg_source's last_frame_ts from an audio capture callback, for an MP3 and a FLAC with cover art, before and after the scene is shown again. After the restart the timestamp has moved, the monitor resets its count but keeps the old timestamp, so the still cover never counts as still and the Windows monitor holds the audio back for good. Refs obs-rust#2530
The WASAPI monitor stops syncing a source's audio to its video once the video timestamp has stood still for 100 ms, as for an audio file with embedded cover art. On a new timestamp it reset the count but did not store the timestamp, so after the source restarted (the scene was shown again, or the file looped) and the cover got a new timestamp, every packet saw it as new and the count stayed at 0. The audio, ever further ahead of the still cover, was held back for good and monitoring went silent until it was switched off and on. Store the new timestamp. Port of upstream obs-studio PR 14091. Fixes obs-rust#2530 Co-Authored-By: prgmitchell <[email protected]>
zackees
force-pushed
the
fix/upstream-cover-art-monitoring
branch
from
October 26, 2026 22:11
b977e42 to
eb794a3
Compare
6 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2530
What and why
On Windows, audio monitoring of a Media Source playing a song with embedded cover art goes silent after the source restarts: the scene is shown again, visibility is toggled, or the file loops. The stream and recordings still get the audio, and switching monitoring off and on brings it back until the next restart (upstream obs-studio issues 9428 and 11739). This is a port of the one-line upstream fix, obs-studio PR 14091, which is open there with no reviews yet.
The WASAPI monitor holds a source's audio back while it runs ahead of the source's video, and stops syncing once the video timestamp has stood still for 100 ms. Cover art is one picture, so its timestamp stands still. When the timestamp changed, the monitor reset its count but kept the old timestamp. After a restart the cover gets a new timestamp, so every later packet saw it as new, the count stayed at 0, and the audio, ever further ahead of the still cover, was held back for good.
process_audio_delay()inlibobs/audio-monitoring/win32/wasapi-output.c.hinto a shared header,libobs/audio-monitoring/monitor-video-sync.h(onestatic inlinefunction, no OS code, included throughlibobs-windows.pch.h). The 100 ms limit becomesAUDIO_MONITOR_VIDEO_STALL_NS. This lets the decision run on every platform.docs/features.mdline under Fixed upstream bugs, Audio.Linux and macOS are not affected: the PulseAudio and CoreAudio monitors have no such check. The program audio is not affected on any OS.
Tests (both new; no existing test changed):
test_monitor_video_sync(test graph, every platform, no libobs): a still cover, a restart with a new cover timestamp, repeated restarts, and a guard with moving video (a new frame every 33 ms never counts as still).test_media_cover_art_monitor(tests.d, Linux, under Xvfb, skips without a display): real libobs and the realffmpeg_sourceplay a generated MP3 (when an MP3 encoder is available) and FLAC, each with a JPEG cover as an attached picture. The files are written at run time, not committed. The test runs the monitor's decision in the source's audio capture callback, where the WASAPI monitor runs it, with the source's reallast_frame_ts, for 1 s of first play and 1 s after the program went to another scene and back (restart on activate).The WASAPI output itself can't run on Linux, so the Windows device path is covered by the Windows build in PR CI, not by a run. The Windows unity group (
libobs.windows+.h.c) passes a MinGW syntax check locally.RED → GREEN
test_monitor_video_sync:cover_art_restart_stalls_againandcover_art_every_restart_stallsfail ("video stood still but only 0 ms counted (stall after 100 ms)"); the first-play and moving-video guards pass.test_media_cover_art_monitor: both cases fail in 5 of 5 runs on hybrid libobs and on libobs-c-reference: after the restart the cover is at a new timestamp, the monitor still holds the first one, and the still cover counts 0 ms (first play: 768 to 888 ms). In one run on libobs-c-reference, the FLAC case already counted 0 ms on first play, the same trap when the video timestamp moves once after the first packet.test_media_cover_art_monitor6 of 6 runs each; after the restart the monitor holds the new timestamp and counts 768 to 888 ms). The media, monitoring and cover-art ctests (-R 'media|monitor|cover') pass on both lanes: 39 of 39 on libobs-c-reference, 41 of 41 on hybrid libobs.uv run ci/local_gate.py --lane lint,--test-diff origin/master(4531 passed) and--lane crosspass.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC