obsproject / obsproject/obs-studio
libobs: Last audio appears when restart audio playback
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
Other
Other OS
Fedora 35
OBS Studio Version
Git
OBS Studio Version (Other)
28.0.0-beta2-19-g7eb46d50b
OBS Studio Log URL
https://obsproject.com/logs/yOia20gn6s7Oyz57
OBS Studio Crash Log URL
No response
Expected Behavior
When starting to play an audio file, the audio from the beginning of the audio file appears.
Current Behavior
When starting to play an audio file, the last several frames of the audio file is first played back, then the desired audio is played back.
Steps to Reproduce
- Setup OBS profile and ensure audio sampling frequency is 48 kHz. Also set transition to
Cut. - Create three scenes named
Scene,Chirp 44k1,Chirp 48k. - In the scene
Chirp 44k1, add a media source and set a audio file whose sampling frequency is 44.1 kHz and which has a chirp starting from low frequency to high frequency. - In the scene
Chirp 48k, add a media source and set a audio file whose sampling frequency is 48 kHz and which has a chirp starting from low frequency to high frequency. - Switch to the scene
Scene. - Restart OBS
- Start recording
- Switch scene to
Chirp 48kand wait until playback ended. - Switch scene to
Chirp 44k1and wait until playback ended. - Switch scene to
Chirp 48kand wait until playback ended. - Switch scene to
Chirp 44k1and wait until playback ended. - Stop recording.
- Check recording
A waveform below is the beginning of the step 11. The very high frequency wave comes from the end of the audio file. The very low frequency wave comes from the beginning of the audio file.

Anything else we should know?
Suspecting last samples are remaining in libswscale (the sample rate converter).
I believe this bug has existed for many versions. I found this bug while editing libobs/media-io/audio-resampler-ffmpeg.c for another purpose.
Maybe we need to add an API on libobs for a source to notify there is no more audio and libobs has to flush remaining audio in the resampler.
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 with libobs/media-io/audio-resampler-ffmpeg.c, the file named in the report, and reproduce the scene-switching test with 44.1 kHz and 48 kHz audio at a 48 kHz OBS setting. Check the recorded waveform around each restart for samples from the end of the previous playback. Done means playback begins at the start of the selected file without trailing audio from the prior file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100