muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.54k stars 1.75k forks source link

How to reduce the size of audio files? #31

Closed CatPrincess closed 9 years ago

CatPrincess commented 9 years ago

When I record audio by Chrome, the file's size if too big, 1 seconds is about 200 KB around. I want to know, is there any config to make the file's size smaller?

by the way, I use this lib to achieve voice chat. I do not need the high quality audio.

Any suggestion would help me, thanks in advance.

philazzi44 commented 9 years ago

While not something part of this repo, I had a similar problem and went down the route of creating a PNaCL component that converts the captured .wav audio into an .ogg using libvorbis. That might be an avenue you can use to bring Chrome into a similar file size as Firefox provides natively via the MediaRecorder API.

muaz-khan commented 9 years ago

@CatPrincess You can use numberOfAudioChannels and bufferSize to reduce WAV size 3-times of the original:

var recrdRTC = RecordRTC(audioStream, {
    numberOfAudioChannels: 1,
    bufferSize: 256
});

Buffer-size lower-values may decrease the audio quality however numberOfAudioChannels will still affect and force generating half of the original WAV.

muaz-khan commented 9 years ago

There is an alternative ffmpeg-based solution as well:

BTW, there is audioconverter.js as well which is having 2MB minified file-size, I guess. There are many alternative solutions as well, e.g. http://stackoverflow.com/a/26245260/552182