Gstreamer opusenc 编码器产生失真/断断续续的音频

标签 gstreamer opus mediasoup

我使用以下 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

但这会产生非常断断续续/失真的音频。样本here .

我在这里做错了什么?

最佳答案

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

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

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

! audioresample ! audio/x-raw, rate=24000 

关于Gstreamer opusenc 编码器产生失真/断断续续的音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70065823/

相关文章:

Android Gstreamer SDK教程报错

gstreamer - 如何等待 x264enc 在流末尾对缓冲帧进行编码

javascript - 如何在IE11中使用沿声波图像移动的光标(垂直线)播放作品音频

android - 将cpp类添加到android项目中

WebRTC:我需要 TURN 服务器吗? (这会有帮助吗?)

python - Gstreamer、Python 和 Appsink

c++ - 压缩后的 Opus 帧大小(字节)

javascript - UnsupportedError : cannot produce video at Transport. 产生

android - 无法使用 Android NDK 构建 gstreamer