opusfile icon indicating copy to clipboard operation
opusfile copied to clipboard

read contents of .opus files (no decoding)

Open dragos-oancea opened this issue 3 years ago • 2 comments

I always wondered why there is no support in the lib for getting individual opus packets from the ".opus" file itself. It would be very helpful for VOIP/webrtc - eg: reading an opus file and send it contents packet by packet on the wire (without decoding the file and then re-encoding to put the packet on the wire).

dragos-oancea avatar Feb 25 '21 13:02 dragos-oancea

Do you need seeking support? If not it's fairly straightforward to use the underlying libogg api to extract the packets. See this code from opus-tools package for an example.

If you do need seeking support that's a better use-case for opusfile, although RTP can't be made sample-accurate. The API would be complicated by RTP's narrower specification: an opus file can switch between mono/stereo and mutli-channel within the same stream, but RTP doesn't allow this, so there would need to be some way to signal the caller when parameters changed at a particular link boundary.

rillian avatar Feb 25 '21 18:02 rillian

Thank you for your answer and for pointing out the code. No seeking support needed for the scenarios I have in mind: playing opus files for IVRs (when the caller has opus negotiated in SDP) and doing RTP->websocket streaming (for ASR for example). Switching middle-call between mono/stereo is fairly uncommon in VOIP.

dragos-oancea avatar Feb 26 '21 07:02 dragos-oancea