doutao5419 2019-05-30 14:36
浏览 365

如何在Golang中使用字节保存Opus文件?

We are using pion/webrtc library and we have incoming audio track from RTCPeerConnection

We need to save opus audio file from RTCPacket.Raw (list of bytes). We tried to use their OpusWriter but it didn't work, audio is written but not playable.

So the question is how can we save Opus audio file from bytes?

The code:

        for {
          rtpPacket, err := remoteTrack.ReadRTP()
          b := rtpPacket.Raw

          if ivfFile != nil {
            if err := ivfFile.WriteRTP(rtpPacket); err != nil {
              log.Println(err)
            }
          }

          checkError(err)
          videoTrackLock.RLock()
          _, err = videoTrack.Write(b)
          videoTrackLock.RUnlock()

          if err != io.ErrClosedPipe {
            checkError(err)
          }
        }
  • 写回答

1条回答 默认 最新

  • dpdbu24262 2019-05-31 05:40
    关注

    Does the save-to-disk example not work for you? That demonstrates saving VP8/Opus to disk.

    If you do want the audio directly from *RTP.Packet you should use the Payload field not Raw. Raw contains the RTP headers, while Payload will only contain the media.

    Thanks for using Pion! I am happy to help either here or on Slack

    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制