Thomas
Thomas

Reputation: 1706

compress blob containing audio PCM data in javascript

I have made a program that generates a blob (containing PCM data) from a recording using the new HTML5 getusermedia api however; these recordings can get pretty big and I hoped that the files could be compressed before sending them to the server. I know that mp3/ogg compression is way out of what a browser can handle (i think) so I looked elsewhere.

Some people talk about http compression (that would also use Gzip) but isn't that a browser-server decision when setting up communication?

I found https://github.com/olle/lz77-kit; it has a javascript implementation for the client and php for the server but would this even make sensor for audio?

Does anybody have any experience with compressing audio on the client side (without using flash)

Upvotes: 2

Views: 5282

Answers (3)

mido
mido

Reputation: 25064

I know I am answering quite late, here is my attempt at client side audio compression without using flash : https://github.com/Mido22/recordOpus,

I am sending the encoded opus packets to server(nodejs) using opus packets through socket, where I convert it to whatever format requested by user and provide him the link...

Upvotes: 1

jeremy
jeremy

Reputation: 4314

Raw (or compressed) audio is very hard to compress and I would highly suggest either writing a browser plugin that compresses the audio or doing it server side. A general compression algorithm, zip, gz, etc. will not be able to give you any worthwhile amount of bandwidth savings.

Upvotes: 1

Carsten
Carsten

Reputation: 18446

Since you are using getUserMedia, I suppose that you want to record speech from a user's microphone.

Audio-specific compression algorithms should be much more efficient than general data compression algorithms. The downside of audio codes, such as MP3, are, that they are lossy.

Now, Speex might be a good codec for you. And as it happens, there is a full JavaScript Speex encoder/decoder, complete with example: speex.js.

Upvotes: 4

Related Questions