Convert from OGG Data URL
Hello,
I am trying to use Opus.NET to convert from an OGG with Opus data into a WAV file.
My OGG data originates from the Firefox MediaReader API, which records audio from the computer's microphone. Here is a sample data URL. I transmit this data URL to my server, and I decode it into a byte array as follows.
// `recording` is the data URL string
var base64 = recording.Substring(1 + recording.IndexOf(","));
var bytes = Convert.FromBase64String(base64);
var decoder = OpusDecoder.Create(48000, 1);
int len = this.inputBytes.Length;
this.wavBytes = decoder.Decode(this.inputBytes, len, out len);
The base 64 decoding works fine. However, when the code gets to the decoder.Decode line, it throws the following exception:
Decoding failed - InvalidPacket
I have two questions:
- What is the best way to pass a data URL to the OpusDecoder such that the OpusDecoder will accept it?
- Once the OpusDecoder is formed, how do you save it as a WAV file?
Thanks in advance!
This project is a low level wrapper around the Opus codec. Opus media files that are contained in the OGG format will need a library to read frames from the container format.
@vote539 did you solved this issue, I am also facing the same so please let me know how did you solved?