Skip to content

libobs: Fix audio transitions with output scaling - #13812

Open
prgmitchell wants to merge 1 commit into
obsproject:masterfrom
prgmitchell:fixRescaleAudioCrossfade
Open

prgmitchell wants to merge 1 commit into
obsproject:masterfrom
prgmitchell:fixRescaleAudioCrossfade

Conversation

@prgmitchell

@prgmitchell prgmitchell commented Aug 22, 2026

Copy link
Copy Markdown
Member

Description

Encoder output scaling creates an encoder-only video mix which causes the same audio tree to be scanned twice. Previously this wasn't an issue but after commit 50cdabbb5 added duplicate audio source detection this caused these sources to be marked as duplicates and mixed outside the transition audio path. This change ensures we only process each video view once when building the audio render tree. Definitely needs a review, probably from @pkviet who would be the most familiar with this and I have no doubt there could be something I am missing despite how much research I tried to do beforehand.

Motivation and Context

Fixes #12912

How Has This Been Tested?

Created two scenes with separate audio sources both playing audio, set a fade transition with 5000ms and tested with both rescaling enabled and disabled. Without these changes, the audio would hard cut instead of smoothly fade when rescaling was enabled. After these changes, the results are identical whether rescaling is enabled or disabled and the audio fades smoothly.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@pkviet

pkviet commented Aug 22, 2026

Copy link
Copy Markdown
Member

The proposed fix seems correct to me.

Comment thread libobs/obs-audio.c Outdated

@derrod derrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution only works as long as the secondary mixes are all encoder-only, I don't know if that's ever not the case right now (e.g. with NDI or DeckLink outputs) but it might not be in the future.

Perhaps a more robust way of doing this is to deduplicate on the view and ensure each of them is only iterated once.

@prgmitchell
prgmitchell force-pushed the fixRescaleAudioCrossfade branch from 937541c to 2d0e041 Compare August 23, 2026 18:02
@prgmitchell

Copy link
Copy Markdown
Member Author

Thanks everyone for taking the time to review....what @derrod mentions makes sense so I have tried my best to make the changes but once again would appreciate as many eyes as it can get as I am very much doing a "learn as you go" thing with C here. I have added a local for the mix as suggested by @notr1ch and am now looping through the earlier mixes looking for the same view.

Comment thread libobs/obs-audio.c Outdated
Only process each video view once when building the audio render tree
to avoid falsely treating sources as duplicates.
@prgmitchell
prgmitchell force-pushed the fixRescaleAudioCrossfade branch from 2d0e041 to 9e2d666 Compare August 27, 2026 19:15
@WizardCM WizardCM added the kind/bug Categorizes issue or PR as related to a bug. label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-fading audio breaks if "Rescale Output" is used

5 participants