【问题标题】:Gstreamer opusenc encoder produces distorted/choppy audioGstreamer opusenc 编码器产生失真/断断续续的音频
【发布时间】:2022-01-01 01:21:45
【问题描述】:

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

我在这里做错了什么?

【问题讨论】:

    标签: gstreamer opus mediasoup


    【解决方案1】:

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

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

    只需要在opusenc前加上下面一行:

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 尝试设置channels=1,没有帮助。由于我也在发送视频,因此无法真正删除 demux 处理。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多