obs-StreamFX icon indicating copy to clipboard operation
obs-StreamFX copied to clipboard

Source Mirror doesn't respect the audio delay

Open erickskrauch opened this issue 3 years ago • 5 comments

Operating System

Windows 10 1903 and higher

OBS Studio Version

28.0.0-beta2

StreamFX Version

0.12.0.77

OBS Studio Log

https://obsproject.com/logs/GLHLvYW5q5cV6yC_

OBS Studio Crash Log

No response

Current and Expected Behavior

If you add a Video Delay (Async) filter, the image on the mirror gets delayed accordingly, while the sound has no delay. On the original media the audio delay is applied correctly.

Steps to Reproduce the Problem

  1. Create Media Source.
  2. Choose any file.
  3. Add a Video Delay (Async) filter to the newly created Media Source. 1500ms should be enough.
  4. Create a Source Mirror of the newly created Media Source with sound enabled.
  5. Start recording.
  6. Listen to the record. You will hear the sound from the mirror without delay while the original media provide sound with correct delay.

Any additional Information we need to know?

As a temporary solution, we set a Sync Offset for mirrors in the Advanced Audio Properties. But this isn't as convenient as it would be if the Source Mirror accounted for the source delay.

erickskrauch avatar Aug 22 '22 01:08 erickskrauch

This appears to be working as intended going by the original plan for audio mirroring. Source Mirror would need to be pointed at the exact filter for audio mirroring to be working as you'd expect, and since detecting filters at the time Source Mirror was released was problematic, it simply targets the selected source.

Potentially this can be resolved much cleaner with the future Spout/Sink system.

Xaymar avatar Aug 22 '22 08:08 Xaymar

As I can see here, OBS doesn't delay audio via filter by default and relies on some internal sync mechanic. However, I compiled OBS so that the #define DELAY_AUDIO was defined and the filter also explicitly delayed the audio. Unfortunately, this didn't help either.

I don't understand C++ code very well, so I don't fully understand how mirroring works, but it seemed to me that if after the filter the audio is clearly delayed in sync with the video frames, then it will be delayed on the mirror as well.

Maybe there is some possibility to pick up sound after filters? Then it will not be necessary to search for the applied filters and make something around them.

erickskrauch avatar Aug 22 '22 13:08 erickskrauch

Audio "cloning" in Source Mirror uses the following code: https://github.com/Xaymar/obs-StreamFX/blob/c45222b820dce3ff8d33b81ad5ba4220c5f6d430/source/obs/obs-signal-handler.hpp#L84

This function registers a hook that is called as soon as libOBS converted it to the global audio format. As it was/is the only way to capture audio at the time of implementation, this is the limitation that users now have to live with. Change things now and existing collections break. Don't change things and people may not expect the behabiour.

So that's why I have a better system envisioned. A system where you can choose the exact point at which audio is "Source"d and sent to "Sink"s. Away from hacky out-of-the-box solutions, and towards proper in-the-box solutions.

Xaymar avatar Aug 22 '22 20:08 Xaymar

So that's why I have a better system envisioned.

That's great! Do you have a plan to do this anytime soon?

erickskrauch avatar Aug 22 '22 20:08 erickskrauch

Do you have a plan to do this anytime soon?

It'll be done when its done. See here: https://github.com/Xaymar/obs-StreamFX/discussions/852

Xaymar avatar Aug 22 '22 21:08 Xaymar