Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert from OGG Data URL #4

Open
vote539 opened this issue Jul 31, 2014 · 2 comments
Open

Convert from OGG Data URL #4

vote539 opened this issue Jul 31, 2014 · 2 comments

Comments

@vote539
Copy link

vote539 commented Jul 31, 2014

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!

@DevJohnC
Copy link
Owner

DevJohnC commented Aug 1, 2014

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.

@MahendraNG
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants