Skip to content

Consider making OpusOggWriteStream accept data that is already encoded as an option #10

@steveellis

Description

@steveellis

This is coming up for me on my journey to try to get faster performance on Android. I've got a p/invoked libopus.so giving me an encoded array but I still need to wrap it in an ogg container.

Right now it looks like OpusOggWriteStream.WriteSamples assumes that you'll always want it to do encoding. But the work you've done creating the ogg wrapper is useful regardless of how the encoding gets done I think--well at least it would be useful to me. :)

I've been hacking on this a bit to try to get it to write the header and (other stuff?) that is required by ogg around the encoded array I get from libopus.

I thought something like this might work:

public void WriteSamples(short[] data, int offset, int count)
{
     _opusFrame = data;
}

But so far no luck. The result can't be played back. Also tried commenting this line out

int packetSize = _encoder.Encode(_opusFrame, 0, _opusFrameSamples, _currentPayload, _payloadIndex, _currentPayload.Length - _payloadIndex);

And then setting the packetSize to be the length of my encoded array.

_payloadIndex += data.Length;

Would love to do a PR to make this class more agnostic about where it gets the encoding if I can get this working.

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