obsproject / obsproject/obs-studio

libobs: Last audio appears when restart audio playback

Open
#7,063 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

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
  1. Setup OBS profile and ensure audio sampling frequency is 48 kHz. Also set transition to Cut.
  2. Create three scenes named Scene, Chirp 44k1, Chirp 48k.
  3. 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.
  4. 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.
  5. Switch to the scene Scene.
  6. Restart OBS
  7. Start recording
  8. Switch scene to Chirp 48k and wait until playback ended.
  9. Switch scene to Chirp 44k1 and wait until playback ended.
  10. Switch scene to Chirp 48k and wait until playback ended.
  11. Switch scene to Chirp 44k1 and wait until playback ended.
  12. Stop recording.
  13. 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.
Screenshot_2022-08-14_19-46-13

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.