I am using the following gstreamer pipeline to grab RTMP src and transcode it with opusenc encoder and sending it as rtp packet to Mediasoup (a webrtc library).
gst-launch-1.0 \
-v \
rtpbin name=rtpbin rtp-profile=avpf do-retransmission=true \
rtmpsrc location=rtmp://3.126.121.45:1935/live/qonda-injecttest-orig \
! flvdemux name=demux \
demux.audio \
! queue \
! decodebin \
! "audio/x-raw,channels=2,rate=48000" \
! audioconvert \
! opusenc \
! rtpopuspay pt=101 ssrc=11111111 \
! rtpbin.send_rtp_sink_1 \
rtpbin.send_rtp_src_1 ! udpsink host="3.69.236.199" port="41269" sync=true \
rtpbin.send_rtcp_src_1 ! udpsink host="3.69.236.199" port="48143" sync=false async=false
But this produces very choppy/distorted audio. A sample here.
What am I doing wrong here?
Found a solution that solves the problem. So Answering my own question.
I think it's more related to mediasoup (WebRTC framework that I am using) which uses OPUS which is set to channels=2 & rate=48000
but opusenc in gstreamer can use channels 1 or 8. Setting a sample rate of 24000 solves the problem.
Just need to add the following line before opusenc:
! audioresample ! audio/x-raw, rate=24000