Giter Club home page Giter Club logo

Comments (13)

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Opus doesn't support 44100 internally. I'm guessing that the rate 44100 you
see is the decoded data sample rate for playback. If you attach a sample
file I can take a look at it.

On Sun, 6 Nov 2016 at 14:34 Rotem [email protected] wrote:

Hi,
I'm streaming from recorderjs to node-opus.
On the server when I read the header file it seems like it is still
44100.I also tried to run opusinfo, and still it is 44100.
Do I miss anything?

this is how I use it on the client:

var rec = new Recorderjs.Recorder({
encoderPath:'libs/recorderjs/encoderWorker.min.js',
streamPages:true,
encoderSampleRate:48000
});

On the server, using node-opus I do:

var oggDecoder = new ogg.Decoder();
var opusDecoder=null;
var wavWriter = null;
var fsOpus = fs.createWriteStream(opusFile);
oggDecoder.on('stream',function (oggStream) {
opusDecoder = new opus.Decoder();
opusDecoder.on('format', function (format) {
console.log(format);
wavWriter = new wav.FileWriter(pcmFile, {
channels: format.channels,
sampleRate: format.sampleRate,
bitDepth: format.bitDepth
});
opusDecoder.pipe(wavWriter);
});
oggStream.pipe(opusDecoder);

        })
        stream.pipe(oggDecoder);
        stream.pipe(fsOpus);


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#60, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAe7gw4MeoEuznIPtcfCn55ZBmcziSPfks5q7ivTgaJpZM4KqpxP
.

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

Sure,
Thank you!
See attached.
in.opus.txt

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

This is the opusinfo output for your file. What part about this doesn't look right to you?

New logical stream (#1, serial: f07d0bd4): type opus Encoded with Recorder WARNING: EOS not set on stream 1 (normal for live streams) Opus stream 1: Pre-skip: 3840 Playback gain: 0 dB Channels: 1 Original sample rate: 44100Hz Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min) Page duration: 3700.0ms (max), 3700.0ms (avg), 3700.0ms (min) Total data length: 23777 bytes (overhead: 1.31%) Playback length: 0m:03.620s Average bitrate: 52.55 kb/s, w/o overhead: 51.86 kb/s

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Original sample rate: 44100Hz means that the original audio had a bandwidth of 44100Hz. Judging from your code snippets, it was then up-sampled to 48000Hz for encoding with opus. This all looks as expected.

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

I'm getting an error from node-opus (Maybe it related to node-opus)
Error: Could not create decoder. Check the decoder parameters
When looking into node-opus code, it seems like it sends the header sampleRate to the opus decoder, and opus decoder does not support it.
Any idea what's going on? If for example I modify the code and hard code 48000, it works.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Yeah, seems that node-opus is using the header defined sample rate to try and decode. I opened an issue here: Rantanen/node-opus#20

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

Ok. Thanks,
Still, if I try to play the file after the decoding.. it different (like slower..)

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Likely because you are decoding at 48000 Hz and then playing it back at 44100Hz without resampling?

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

Ok, so I need to downsample it then... Thank you for the help. Do you know if there is a library that downsample?

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Lots of them. Easiest would probably be to pipe your output to SOX.
Never tried this, but it might do the trick: https://www.npmjs.com/package/sox

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

Ok,
Thank you!
I think we should close this issue as it is not related to recorderjs.

from opus-recorder.

rotem925 avatar rotem925 commented on June 29, 2024

See my pull request on node-opus:
Rantanen/node-opus#21

Hope that should solve it.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Cool. 👍

from opus-recorder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.