obsproject / obsproject/obs-studio

Calling obs_source_set_sync_offset() from a C module or Python Script has no real effect on the source

Open
#7,912 0 comments 0 reactions 0 assignees View on GitHub

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.

  1. Start OBS 28.1.2
  2. Create a blank scene (delete all sources like Desktop Audio etc.)
  3. Add a new Media Source. IMPORTANT: leave the name as is (The script will not work otherwise)
  4. Assign rhythm_mono.mp3 to that source
  5. Open Advanced Audio Properties and choose "Monitor and Output" as Audio Monitoring setting
  6. Open Tools->Scripts and load the obs-offset.py Python script
  7. Set the offset slider in the script properties to -300 ms
  8. Disable "Enable Workaround"
  9. Start playback of the Media Source
  10. Start recording
  11. Wait a few beats and press "Set"
  12. Stop recording and playback after another few beats
  13. Manually reset the Sync Offset to 0 ms in the Advanced Audio Properties
  14. Restart OBS
  15. Stop playback
  16. Open Tools->Scripts
  17. Enable "Enable Workaround" in the script properties
  18. 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

OBS_sync_offset

obs_sync_offset_files.zip

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.