Replies: 2 comments
-
I tried it with this example code, but not sure what I'm missing (https://github.com/bluenviron/gortsplib/blob/main/examples/client-read-format-g711/main.go). I believe the library
|
Beta Was this translation helpful? Give feedback.
-
Hello, in my opinion you can dynamically update the sample count in the WAV file header by overriding the header by using wavOut.Write(op)
// place pointer at the beginning of the file in order to override the header
f2.Seek(0, 0)
blockAlign := numChannels * bitsPerSample / 8
byteRate := sampleRate * uint32(blockAlign)
format := &WavFormat{AudioFormatPCM, numChannels, sampleRate, byteRate, blockAlign, bitsPerSample}
dataSize := numSamples * uint32(format.BlockAlign)
riffSize := 4 + 8 + 16 + 8 + dataSize
riffWriter := riff.NewWriter(f2, []byte("WAVE"), riffSize)
writer = &Writer{riffWriter, format}
riffWriter.WriteChunk([]byte("fmt "), 16, func(w io.Writer) {
binary.Write(w, binary.LittleEndian, format)
})
// place pointer at the end of the file in order to continue writing
f2.Seek(0, io.SeekEnd)
...
// repeat I took the header code from the library: |
Beta Was this translation helpful? Give feedback.
-
Hello all, I'm currently experimenting with some audio codecs (and still learning). While using
gortsplib
I'm able to read the PCM stream of an IP camera, using the codec I understand there is thesampleRate
,Clock
, and more.I'm now trying to understand how I can write this PCM (RTP packets) to a valid
wav
file. So instead of just recording audio and video, I would like to retrieve only the audio.Beta Was this translation helpful? Give feedback.
All reactions