mattdiamond / Recorderjs

A plugin for recording/exporting the output of Web Audio API nodes
4.17k stars 1.46k forks source link

Changing the bitrate and recording the mono wav files #40

Open savantmohan opened 10 years ago

savantmohan commented 10 years ago

Hi,

I am using the recorder.js for recording the audio. This gives me output as 44.1khz, 2-channel wav file.But my requirement is 16khz sinlgle channel WAV file . Could you please guide me on how to achieve this with the help of recorder.js.

Thanks in advance.

Regards, Mohan Savant

cwilso commented 10 years ago

This is "hard". You need to do downsampling in order to make this work properly - which requires band-limiting the audio stream (i.e. you can't just skip every other sample to get a 22.05kHz buffer; that can have nasty aliasing effects).

At a quick guess - I'd generate the AudioBuffer using recordJS, then create an OfflineAudioContext at your preferred rate, load the buffer in that context and play it back to record the buffer.

rodneytamblyn commented 10 years ago

Being able to set the bitrate and stereo/mono size would be a great addition to recorder.js At a minimum, being able to specify mono out of the box would cut recording sizes in half.

This topic is discussed here http://stackoverflow.com/questions/16296645/decrease-bitrate-on-wav-file-created-with-recorderjs but would be good to incorporate I found this example which may be useful: http://searchcode.com/codesearch/view/25648192 for anyone researching this.

cwilso commented 10 years ago

If I'm reading that code right, that's a bit dangerous. You can't just skip samples to reduce bitrate - you need to downsample, including brick-wall filtering at the new sample rate to eliminate aliasing noise.

On Mon, Feb 10, 2014 at 6:17 PM, Rodney Tamblyn notifications@github.comwrote:

Being able to set the bitrate and stereo/mono size would be a great addition to recorder.js At a minimum, being able to specify mono out of the box would cut recording sizes in half.

This topic is discussed here http://stackoverflow.com/questions/16296645/decrease-bitrate-on-wav-file-created-with-recorderjsbut would be good to incorporate I found this example which may be useful: http://searchcode.com/codesearch/view/25648192 for anyone researching this.

Reply to this email directly or view it on GitHubhttps://github.com/mattdiamond/Recorderjs/issues/40#issuecomment-34720576 .

cherouvim commented 10 years ago

Any plans on this one? Recording at lower bitrate seems like a common use case for javascript apps.

dciccale commented 10 years ago

+1

maxbrodie commented 9 years ago

+1

TheRealCDay commented 9 years ago

+1

astillman commented 9 years ago

+1

chris-rudmin commented 9 years ago

Check out my fork. https://github.com/chris-rudmin/Recorderjs

rosssclafani-zz commented 9 years ago

@chris get that baby PR'd so it comes by way of NPM

ladaphnego commented 9 years ago

From an article, I found a solution at: http://www.faasoft.com/articles/mp3-bitrate-converter-mac-and-windows.html

With Faasoft MP3 Bitrate Converter, the following tasks will be readily completed:

1. Adjust bitrate of almost all kinds of video files such as MP4,  MOV, AVI, WMV, MKV, FLV, ASF, MXF, WebM, OGV, 3GP, Xvid, DivX, AVCHD,  MTS/M2TS, MOD, SWF, 720p and 1080p and so on;
2. Adjust bitrate of various kinds of audio files like AAC, AC3,  M4A, WAV, MP3, FLAC, AIFF, CAF, VOC, OGG, WMA, M4B, OPUS, APE, AMR, etc;
3. Change video bitrate and keep the source video format or as well as convert to other popular video formats for playback;
4. Change audio bitrate without re-encoding or convert the source audio to other audio formats as your desire;
5. Adjust bitrate of audio files to 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 and more;
6. Adjudt bitrate of video clips to 512, 640, 768, 894, 1000, 1200, 1500, 2000, 3000, 4000, and more;
7. Apart from change video or audio bitrate, this MP3 Bitrate  Converter allows you to do many other advanced editing like adjust  sample rate of audio, frame rate of video, change audio channels, adjust  video and audio size, increase or decrease audio volume, remove audio  from video, etc;
8. This amazing MP3 Bitrate Converter also has the following  basic features for explore: trim, compress, rotate, crop, add effect,  remove subtitle, add watermark/music background, etc;
9. Works on Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, and Windows 2000;
10. Is compatible with Mac OS X 10.10, 10.9, 10.8, 10.7, 10.6, 10.5.
Zerquix18 commented 8 years ago

+1 :smile:

endoplasmic commented 8 years ago

@chris-rudmin it looks like you axed the WAV stuff out of this. Sadly I would love to use a compressed format, but the voice engine requires 16kHz, 16bit, mono WAV files :(

Happen to have a way to do WAVs, or should I roll my own?

chris-rudmin commented 8 years ago

@endoplasmic you can always check out the lib from an older commit. It's all there.

Zerquix18 commented 8 years ago

I found this library, which uses this library and also allows to record directly in MP3 and OGG instead of WAV and you can decrease the bitrate. It's very useful.

alejandroparra commented 7 years ago

+1

David-Almeida commented 7 years ago

+1

complanboy2 commented 7 years ago

@endoplasmic , Did you find solution to this ? Can you please share if so. Thank you.

yanshengjia commented 6 years ago

+1

endoplasmic commented 6 years ago

@complanboy2 --- I'm sorry for not seeing this until now. Since this was 3 years ago, I honestly don't remember what I ended up doing.

https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer is the current way to do it all in browser with native API.

complanboy2 commented 6 years ago

@endoplasmic Thank you for replying bro.

I've found the solution. And for others, if you are facing this same problem, have a look at my repository: https://github.com/complanboy2/VoiceConversion/tree/master/js

And thanks for the link, I will go through.