Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow encoding #44

Open
floydback opened this issue Oct 14, 2017 · 4 comments
Open

Slow encoding #44

floydback opened this issue Oct 14, 2017 · 4 comments

Comments

@floydback
Copy link

floydback commented Oct 14, 2017

You write

Fast mp3 encoder written in JavaScript. On my machine it works 20x faster than realtime
but I have a problem with it.

I have demo.mp3 file with total duration 54 sec
On my machine
time sox demo.mp3 -C 256 ~/demo2.mp3
real 0m1.557s
user 0m1.527s
sys 0m0.018s

When I use lamejs encoding spend ~50 sec and it's too much!

Now I try to use another js encoder (https://higuma.github.io/mp3-lame-encoder-js/) and it spent only ~3sec!

What I do wrong? My code:

buffer // <-- decoded with web audio api AudioBuffer
let mp3buf = [];
let mp3encoder = new lamejs.Mp3Encoder(buffer.numberOfChannels, buffer.sampleRate, 192)
mp3buf.push(mp3encoder.encodeBuffer(buffer.getChannelData(0), buffer.getChannelData(1)))
mp3buf.push(mp3encoder.flush())
let blob = new Blob(mp3buf, { type: 'audio/mp3' })
@danibezoff
Copy link

danibezoff commented Oct 10, 2018

@floydback are you using the npm package? I've managed to reduce the encoding time by nearly 6 times with the help of UglifyJs.

Actually, their minified version seems to be even faster, you should use it.

@vasinl124
Copy link

I'm in the same boat right now. I have > 5 min wav file. It took me 7-8mins to convert. Can you show me how you can reduce the encoding time? I'm using React.

@rafael2k
Copy link

In firefox is much faster than in chrome. Strange.

@rafael2k
Copy link

My bad. The minified version works fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants