Low latency audio capture with gstreamer

∥☆過路亽.° 提交于 2019-12-10 18:15:30

问题


I need (almost) real-time audio capturing on Linux with gstreamer. My problem is that I cannot reduce the latency below ~210ms. I tried a simple loopback from mic to headphone:

gst-launch-1.0 pulsesrc ! alsasink
gst-launch-1.0 alsasrc ! alsasink

Both produced the same delay. The latency-time property of alsasrc did not help (it did add the given latency). I could produce the effect I need with

pactl load-module module-loopback latency_msec=1

But I could not figure out whether it is possible to set the device latency for the pulsesrc plug-in of gstreamer. I guess, if it is possible, I should add something to the stream-properties, but could not figure out what (I searched for it here) and how.

Is it possible to set this device latency for any gstreamer sources, and if yes, how?


回答1:


Using pulsesink instead of alsasink may solve the problem. Try this:

gst-launch-1.0 -v alsasrc buffer-time=35000 !  pulsesink



回答2:


About as close as you can get to zero latency over network is about 20ms. This example produces the same RTP stream as you would get from a VoIP call with max ptime of 20 in the Session Description protocol. The first pipeline is the speaker and the second pipeline is the listener. I haven't tested this with lower latencies or to a local sink pad for that matter, but the setting does exist for your purpose.

speaker

gst-launch alsasrc name=mic provide-clock=true actual-buffer-time=20000 do-timestamp=true buffer-time=20000 \
mic. \
! alawenc \
! rtppcmapay max-ptime=20000000 \
! udpsink host=192.168.1.2 port=5000

listener

gst-launch udpsrc port=5000 caps="application/x-rtp, media=(string)audio, clock-rate=(int)8000, encoding-name=(string)PCMA" \
! rtppcmadepay \
! audio/x-alaw, rate=8000, channels=1 \
! alawdec \
! alsasink buffer-time=80000


来源:https://stackoverflow.com/questions/42023770/low-latency-audio-capture-with-gstreamer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!