obsproject / obsproject/obs-studio
Calling obs_source_set_sync_offset() from a C module or Python Script has no real effect on the source
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 76.4k
- Forks
- 10.2k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 12
Description
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
28.1.2
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/_EnDaZ2SGEkugejr
OBS Studio Crash Log URL
No response
Expected Behavior
When using the C API call obs_source_set_sync_offset(mysource, time) inside an OBS plugin the call should actually add a delay to the source mysource with time delay.
Current Behavior
The API call has no effect to the audio source. Although the Sync Offset is updated in the Advanced Audio Properties and obs_source_get_sync_offset(mysource) returns the correct value, but the offset can not be seen in a recorded file.
However, if you call the function twice with slightly different values and a small amount of time between the calls it works!
Steps to Reproduce
Just out of curiosity I tried if the same happens when I call obs_source_set_sync_offset() from inside a Python script. And yes, it behaves the same. Using Python makes it easy to create minimal demonstration for this issue.
You can find all required files for reproducing the issue in the attached zip file.
- Start OBS 28.1.2
- Create a blank scene (delete all sources like Desktop Audio etc.)
- Add a new Media Source. IMPORTANT: leave the name as is (The script will not work otherwise)
- Assign rhythm_mono.mp3 to that source
- Open Advanced Audio Properties and choose "Monitor and Output" as Audio Monitoring setting
- Open Tools->Scripts and load the obs-offset.py Python script
- Set the offset slider in the script properties to -300 ms
- Disable "Enable Workaround"
- Start playback of the Media Source
- Start recording
- Wait a few beats and press "Set"
- Stop recording and playback after another few beats
- Manually reset the Sync Offset to 0 ms in the Advanced Audio Properties
- Restart OBS
- Stop playback
- Open Tools->Scripts
- Enable "Enable Workaround" in the script properties
- Repeat step 9. to 12.
Now if you open both files in Audacity (see OBS_sync_offset.png) you realize that the first recording
has the same rythm as the original file. There is no offset visible or hearable.
-> Calling obs_source_set_sync_offset() failed
In the second recording you can find one interval between two beats that is half the interval (300ms)
of the other beats (600ms)
-> Calling obs_source_set_sync_offset() succeeded
Anything else we should know?
I tracked this bug down to source_output_audio_data() in obs-source.c and was able to
see that the sync_offset gets added to in.timestamp but I was unable to find out why the offset is not forwarded to the recording.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in obs-source.c at source_output_audio_data(), where the issue reports that sync_offset is added to in.timestamp. Use the attached Python script and reproduction steps to compare recordings with and without the workaround. Done means a single obs_source_set_sync_offset() call produces the requested offset in the recording, not only in the displayed property or getter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100