Rantanen / node-opus

Opus bindings for Node.js
MIT License
79 stars 32 forks source link

opus.Encoder._pushEncodedBuffer #101

Closed vinnitu closed 4 years ago

vinnitu commented 4 years ago

Hello!

I have stream of encoded opus packets. I know rate, channels number and frameSize. I need write ogg file. I wrote something like this

var opusEncoderStream = new opus.Encoder(rate, channels, frameSize);
var oggEncoder = new ogg.Encoder();
var fileStream = fs.createWriteStream('file.ogg');

opusEncoderStream.pipe(oggEncoder.stream()).pipe(fileStream);

while (encodedBuffer) { // read encoded opus data
   opusEncodeStream._pushEncodedBuffer(encodedBuffer);
}

But I get nothing in file.ogg Tell me what else I need to do?

Thanks.

vinnitu commented 4 years ago

It works, but seems audio has not time stampes inside. vlc player for example plays it wrong. ffplay plays normal. browser plays normal but doest show full time info.

var fileStream = fs.createWriteStream('file.ogg');
var oggEncoder = new ogg.Encoder();
oggEncoder.pipe(fileStream);

var opusEncoderStream = new opus.Encoder(rate, channels, frameSize);
opusEncoderStream.pipe(oggEncoder.stream())

while (encodedBuffer) { // read encoded opus data
   opusEncodeStream._pushEncodedBuffer(encodedBuffer);
}

How to fix time problem?

Thanks.

Rantanen commented 4 years ago

I'm archiving the repository for lack of interest in maintaining it. Sorry I never got to deal with this issue. Please see @discordjs/opus for an alternative implementation that is based this project but uses more stable Node.js module technology that should break less between Node.js versions.