Better Audio Clock Skew Correction
Currently, GStreamer has support for skew
and resample
methods (and bring-your-own) of correcting clock skew.
However, these are not good enough for professional use, as - for instance - GStreamer struggles on its own to reliably play out a live audio stream (even locally generated) without re-syncing in a very noticable way (#317, gst-plugins-base#80, https://narkive.com/oUoa2zeg).
This can be observed by running these really simple pipelines on the same machine (and waiting for 5 - 30 minutes - depending on how accurate the clock in your sound card is - to observe a glitch or drop-out):
# Terminal 1
gst-launch-1.0 audiotestsrc wave=sine freq=1000 volume=0.1 is-live=1 do-timestamp=1 \
! audio/x-raw,sample-rate=48000,channels=2,format=S16LE \
! queue \
! srtsink uri="srt://127.0.0.1:9001?mode=caller" sync=true wait-for-connection=0
# Terminal 2
gst-launch-1.0 srtsrc uri="srt://127.0.0.1:9001?mode=listener" do-timestamp=1 keep-listening=1 \
! rawaudioparse pcm-format=s16le \
! queue \
! alsasink
The resample method produces very audible artefacts and only works when sync=false on the sink, and the skew
method drops buffers (skips) or introduces noticable underruns when the drift reaches a certain threshold.
I note the PipeWire project implements a Delay-Locked Loop and good adaptive resampling that could be re-purposed for use inside GStreamer. This can be done inside a project by using a custom slave-method
on a sink (and indeed an easier but limited workaround on Linux is to play out to pipewiresink and let that handle synchronisation). But this is something I'd really want to see GStreamer do natively/better in the GstAudioBaseSink.
I'd love to have a go at this but admittedly I'm not a strong C developer.