Repository navigation
Description
Upstream OBS bug, reported by Daniel-Noethen in obsproject/obs-studio#7912. The same thing is reported in obsproject/obs-studio#11656 (jetpackpaul, with davidtriggs), obsproject/obs-studio#11873 (ndfan77) and obsproject/obs-studio#5356 (MasterZap). The code has not changed in this fork.
Location
libobs/obs-source.csource_output_audio_data(): when a packet continues the previous one seamlessly, it is appended to the source's buffer. The sync offset is only added to a packet's own timestamp, and an appended packet's timestamp is ignored. When the offset changes, the next packet should be placed by its timestamp instead. But the checkif (source->last_sync_offset) push_back = false;(from 2016) skips that when the previous offset was 0, so a change from 0 is never applied. A change from one non-zero value to another works, which is why setting the offset twice "fixes" it.libobs/obs.cobs_load_source(): the source is created first and the saved offset is set afterwards. A live capture (Pulse/PipeWire, macOS Audio Capture, NDI) starts producing audio as soon as it is created, so on load its saved offset is a change from 0 and is ignored.
Class
Audio/video sync: the audio sync offset (Advanced Audio Properties) has no effect, so recordings and streams stay out of sync.
How it is reached
- Advanced Audio Properties, a script (
obs_source_set_sync_offset), a plugin or obs-websocket changes the offset of a source that is producing audio, starting from 0 ms. The value shows up in the UI, but the audio is not delayed. - Restart OBS with a non-zero offset saved on a live audio capture. The offset is not applied until it is changed by hand.
Reproduced headlessly with libobs and a source that behaves like a live capture: 10 ms packets stamped with the system clock, with a click every 1.5 s. The source is put on the program, and the delay is measured from each click's timestamp in the mixed program audio. On master, after 0 -> 300 ms the audio is delayed by 0 ms (21 ms for the first source of the process). After 300 -> 600 ms it is delayed by 599 ms, and after 600 -> 0 ms by 0 ms.
Not the same as #286
#286 (PR #287) fixed a Media Source losing its offset when its audio buffer is reset on restart or after a timestamp jump. That fix changed where the buffer starts after a reset (reset_audio_data_at_sys_time()). This issue is about the offset itself changing while audio flows, which is a different branch of source_output_audio_data(). #287's test still passes and is not affected by the change below.
Proposed fix and failing test
Fix: drop the if (source->last_sync_offset) condition, so the next packet is placed by its timestamp after any change of the offset. The first packet is placed by its timestamp anyway (the source has no audio_ts yet), so the condition only ever skipped real changes.
RED test (cmocka, test_audio_sync_offset_change) with five cases:
- 0 -> 300 ms on a running source that is on the program;
obs_load_source()of a capturing source with a saved 300 ms offset;- 300 ms set after the source is shown;
- guard: offset set before the source produces any audio;
- guard: 300 -> 600 -> 0 ms.
The first three fail today and both guards pass.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 12, 2026
Claiming: this issue.
test_audio_sync_offset_change(3 of 5 failing): a live-capture-like source with clicks on program; the click's lag in the mixed audio must match the offset after 0 -> 300 ms, after loading a saved offset while capturing, and after setting it once the source is shown.PR today.
libobs: Apply a sync offset changed from 0 to a running source
test/cmocka: Add failing test for a sync offset changed from 0
rdoupe commentedon Oct 12, 2026
@Daniel-Noethen you reported this in obsproject/obs-studio#7912, so a heads-up: it's fixed here in obs-rust by #334, merged today with a regression test.
Cause: when a source's sync offset changes, libobs is meant to place its next audio packet by timestamp, which is where the offset is applied. A check from 2016 skipped that whenever the previous offset was 0, which is every source's default. So
obs_source_set_sync_offset()from a plugin or script on a running source updated the value but not the audio, exactly as you described. A non-zero to non-zero change worked, which is why it looked inconsistent. The same check made live captures ignore their saved offset when a scene collection loads, as jetpackpaul, davidtriggs, ndfan77 and MasterZap reported in the later issues. Now any change of the offset is applied to the next packet. The test drives a live-capture-like source with clicks through the real audio mixer: before, a 0 -> 300 ms change measured 21 ms of delay (and 0 ms for the load and set-after-show cases); now it measures 299 ms in all of them.Not covered: real devices and the Advanced Audio Properties dialog weren't tested; one report says just opening that dialog undid an offset, which this change doesn't explain.
Workaround on stock OBS: set the offset to a non-zero value first (for example 1 ms), then to the value you want.
obs-rust is an AI-assisted fork of OBS; on Arch it's
obs-studio-rust-gitin the AUR.If you try it, a short reply here on whether your plugin's offset now takes effect would really help.
libobs: Move the source audio timestamp placement into obs-source-aud…
test: Characterize the source audio timestamp placement
obs-source: Port the source audio timestamp placement
obs-source: Check the source audio timestamp placement port against t…
obs-source: Port the source audio timestamp placement (obs-rust#1936)