0

我正在使用以下 gstreamer 管道来获取 RTMP src 并使用 opusenc 编码器对其进行转码,并将其作为 rtp 数据包发送到 Mediasoup(一个 webrtc 库)。

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

但这会产生非常不连贯/失真的音频。这里有一个样本。

我在这里做错了什么?

4

2 回答 2

0

听起来像是立体声音频隔行扫描问题,每个其他样本都被跳过。您提供的输出样本是立体声 MP3,但两个通道是相同的。

尝试使用channels=1或使用或删除demux处理。

于 2021-11-22T20:15:10.493 回答
0

找到了解决问题的解决方案。所以回答我自己的问题。

我认为它与使用 OPUS 的 mediasoup(我正在使用的 WebRTC 框架)更相关,channels=2 & rate=48000但 gstreamer 中的 opusenc 可以使用通道 1 或 8。将采样率设置为 24000 可以解决问题。

只需在 opusenc 之前添加以下行:

! audioresample ! audio/x-raw, rate=24000 
于 2022-02-01T09:30:38.800 回答