Aligning/synchronizing live audio with pad.set_offset
Michiel Konstapel
michiel at aanmelder.nl
Fri Apr 22 14:08:53 UTC 2022
On 21-04-2022 23:24, Michiel Konstapel wrote:
> I am trying to synchronize multiple (microphone) audio tracks picking
> up the same sound, but currently testing using files as input; one
> original and one copy delayed by a few dozen milliseconds. I am using
> cross correlation based on https://github.com/rpuntaie/syncstart to
> calculate the required time shift to bring them into alignment. This
> works, I get the exact amount to delay the "early" signal by.
>
> However, now I need to actually *apply* the delay to one of the
> streams, before they go into an audiomixer. I am trying to do so using
> pad.set_offset() either on the source pad of a queue that feeds into
> the mixer (because I recall a comment that set_offset() must be called
> on a source pad), or on the sinkpad of the audiomixer.
>
> If I do so before starting the pipeline, it works. But I want to do
> this on the fly (live input) - but if I call set_offset() on a pad
> while it is running, either nothing happens, or I very briefly get a
> fragment of perfectly synced audio, and then (it sounds like) it just
> goes back to the old timing.
>
> What should I do to apply a delay to an audiomixer input in a running
> pipeline?
>
> Kind regards,
> Michiel
Looks like I have it working! I had a silly bug: I had a time in seconds
and forgot to convert it to nanoseconds... while in another code path I
did do the conversion, so *that* worked. Also, it works when setting the
offset on the peer of the mixer sinkpad - so indeed on a source pad.
More information about the gstreamer-devel
mailing list