Opus.NET icon indicating copy to clipboard operation
Opus.NET copied to clipboard

Convert from OGG Data URL

Open vote539 opened this issue 11 years ago • 2 comments

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:

  1. What is the best way to pass a data URL to the OpusDecoder such that the OpusDecoder will accept it?
  2. Once the OpusDecoder is formed, how do you save it as a WAV file?

Thanks in advance!

vote539 avatar Jul 31 '14 19:07 vote539

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.

DevJohnC avatar Aug 01 '14 00:08 DevJohnC

@vote539 did you solved this issue, I am also facing the same so please let me know how did you solved?

MahendraNG avatar Dec 01 '14 13:12 MahendraNG