Skip to content

Convert from OGG Data URL #4

@vote539

Description

@vote539

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions