Asynchrounous Audio Sample Rate Conversion with gstreamer

Carlos Rafael Giani dv at pseudoterminal.org
Wed May 25 14:46:33 UTC 2016


In most cases, there is only one clock (-> audio clock = pipeline 
clock), but in your case, the pipeline clock is the monotonic system 
clock, so audiobasesink needs to compensate for the drift.
The clicks are most likely coming from the "skew" drift compensation 
method in the audiobasesink. This method looks at the drift, and if a 
threshold is reached, moves the playout pointer (= an offset withing a 
ring buffer), effectively inserting nullsamples or discarding samples, 
depending on the skew direction.

You can hook in your own drift compensation method if you set the 
audiobasesink's "slave-method" property to "custom". We use that in a 
project to finetune the audio clock's speed via a PLL by an integer 
number of ppm. It would be the same with an ASRC.

On 2016-05-25 15:04, Maik Scholz wrote:
> Hi,
> thank you very much for the hints.
> With your help, my pipeline is running quite well with ONE audio source.
>
> My target is, having multiply audio sources with different sample rates and
> different external clock sources.
> That includes small sample rate mismatches (+- 50Hz) and drifts.
>
> *My mixer pipeline prototype:*
> GSTLAUNCH=gst-launch-1.0
> STREAMDECHOST=127.0.0.1
> PORT_SRC1=41001
> PORT_SRC2=42001
> PORT_SINK_DEBUG_1=45002
>
> ${GSTLAUNCH} \
>                  audiomixer name=sink_audiomixer latency=256000000 ! \
>                  tee name=sink_tee \
>                  \
>                  sink_tee. ! \
>                  queue name=outtcp_queue ! \
>                  tcpserversink name=tcpserversink host="0.0.0.0"
> port=${PORT_SINK_DEBUG_1} \
>                  \
>                  sink_tee. ! \
>                  queue name=outdsp_queue ! \
>                  autoaudiosink name=autoaudiosink sync=true
> slave-method=resample \
>                  \
>                  sink_tee. ! \
>                  queue name=file_queue ! \
>                  audioconvert name=fileconvert ! \
>                  filesink name=file_filesink location=/dev/null \
>                  \
>                  udpsrc name=src1_src port=${PORT_SRC1} do-timestamp=true ! \
>                  audio/x-raw,format=S16LE,channels=2,rate=32000 ! \
>                  queue name=src1_queue min-threshold-time=0 ! \
>                  audiorate name=src1_audiorate tolerance=256000000
> skip-to-first=false ! \
>                  audioconvert name=src1_audioconvert ! \
>                  audioresample name=src1_audioresample quality=1 ! \
>                  audio/x-raw,format=S16LE,channels=2,rate=48000 ! \
>                  tee name=src1_tee \
>                  \
>                  src1_tee. ! \
>                  volume name=src1_volume volume=0.5 ! \
>                  sink_audiomixer. \
>                  \
>                  udpsrc name=src2_src port=${PORT_SRC2} do-timestamp=true ! \
>                  audio/x-raw,format=S16LE,channels=2,rate=48000 ! \
>                  queue name=src2_queue min-threshold-time=0 ! \
>                  audiorate name=src2_audiorate tolerance=256000000
> skip-to-first=false ! \
>                  audioconvert name=src2_audioconvert ! \
>                  audioresample name=src2_audioresample quality=4 ! \
>                  audio/x-raw,format=S16LE,channels=2,rate=48000 ! \
>                  tee name=src2_tee \
>                  \
>                  src2_tee. ! \
>                  volume name=src2_volume volume=0.5 ! \
>                  sink_audiomixer.
>                 
>
> *My SRC1 audio transmitter (32000 - 50Hz):*
> gst-launch-1.0 audiotestsrc freq=100 !
> audio/x-raw,format=S16LE,channels=2,rate=31950 ! udpsink host="127.0.0.1"
> port=41001
>
> *My SRC2 audio transmitter (48000 + 50Hz):*
> gst-launch-1.0 audiotestsrc freq=300 !
> audio/x-raw,format=S16LE,channels=2,rate=48050 ! udpsink host="127.0.0.1"
> port=42001
>
> When I run these pipelines with even the latest gst version, then I hear
> "clicks" from time to time.
> I expect, that the audiomixer has some problems with the differ sampling
> frequencies.
>
> My assumption is, I need a asynchronous SRC for each input
> (src1_audioresample+src2_audioresample).
> How can I implement this with available elements. Or if not available, what
> is the best way to implement these?
>
> Why is the audiomixer located in the bad plugins? What means bad?
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Asynchrounous-Audio-Sample-Rate-Conversion-with-gstreamer-tp4677252p4677765.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list