How to save to disk as audio/PCMA

45 views Asked by At

How can I save audio as PCMA?

  1. I register codec with PCMA
if err := m.RegisterCodec(webrtc.RTPCodecParameters{
        RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypePCMA, ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: nil},
        PayloadType:        8,
    }, webrtc.RTPCodecTypeAudio); err != nil {
        panic(err)
    }
  1. while on track, What kind of file should I use to store it to disk, or should I use the example's OGG file?
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
        codec := track.Codec()
        fmt.Println(codec.MimeType)
        if strings.EqualFold(codec.MimeType, webrtc.MimeTypePCMA) {
            fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")
            saveToDisk(oggFile, track)
        }
    })
  1. But I failed, finally the OGG file don't work !
  2. please help me, Thank!

Can save to disk as audio/PCMA

0

There are 0 answers