-
Notifications
You must be signed in to change notification settings - Fork 32
[Question] How do you use this? #9
Comments
Not really sure of what you're trying to do. The following code might be helpful. Note that opus doesn't define a binary encoding for the stream so trying to write it to a file as such is probably not something you want. "use strict";
var lame = require( 'lame' );
var opus = require( 'opus' );
var mp3Decoder = new lame.Decoder();
var opusEncoder = new opus.Encoder( 48000, 2 );
var output = process.stdin.pipe( mp3Decoder ).pipe( opusEncoder );
output.on( 'data', function( packet ) {
console.log( console.log( packet ) );
}); |
Ah, well right now I'm attempting to package opus data into an RTP packet, but I'm just trying to get the data from an mp3 file to the opus encoder first, and oh my god thank you. I think this is exactly what I needed. |
Ah, good. Yes. For that the above code should work. The audio data for each opus frame can be read from the output-data packets. |
I'm sorry, it all seems to be working now, but I get very distorted audio on the server. I'm told I'm supposed to be using 20ms frames and I think that might be the issue because I can't find anywhere that I can define that. I tried typing 20 within the frame_size argument area, but apparently that's meant for something different? Do I handle this on my part or is there something I'm missing? Edit: Nevermind, corrupted packets, bad coding on my part. |
I'm sorry for appearing inexperienced, I have no clue what to do with all these pipes and streams.
Right now, I'm trying to see if I can take data from the 'lame' library and have it encode and output with this 'opus' library. However, I'm running into issue after issue and I'm sure it's just because I don't understand how this works. I've looked at the example provided and it looks like I need to get a buffer from somewhere, I've also looked at the examples folder and none of them really help.
Throws a C++ error:
I assume because the format isn't an array.
Throws this
I guess that means I did that incorrectly.
Throws an undefined error
I have tons of other failed examples, but I figure instead of posting them all, maybe someone who's done this can help me.
The text was updated successfully, but these errors were encountered: