cordova-plugin-media icon indicating copy to clipboard operation
cordova-plugin-media copied to clipboard

Add option to change Sampling- and Bitrate

Open d3xtr0 opened this issue 7 years ago • 5 comments

The default sound quality is really bad (8kHz sampling rate).

Please add an option to let us change the EncodingBitRate and SamplingRate.

Android Example:

this.recorder.setAudioEncodingBitRate(192000);
this.recorder.setAudioSamplingRate(44100);

d3xtr0 avatar Sep 19 '18 18:09 d3xtr0

I really need this too, on android it is horrific! Ios is pretty good, no quality loss..

koraysels avatar Jun 04 '19 09:06 koraysels

https://github.com/remoorejr/cordova-plugin-media-with-compression

Prenden avatar Jul 07 '19 21:07 Prenden

PR's welcome. Also a crossref to #255

timbru31 avatar Apr 02 '20 17:04 timbru31

On which place in the Code i have to put it in?

"this.recorder.setAudioEncodingBitRate(192000); this.recorder.setAudioSamplingRate(44100);"

simonreger avatar Feb 13 '22 10:02 simonreger

Hardcoded(!)

In the source code: /src/android/AudioPlayer.java:169 or compiled: /platforms/android/app/src/main/java/org/apache/cordova/media/AudioPlayer.java:156

add these lines:

this.recorder.setAudioEncodingBitRate(128000); //128 kbit/s  
this.recorder.setAudioSamplingRate(44100); //44.1 kHz

/src/ios/CDVSound.m:694 or compiled: \platforms\ios\xxx\Plugins\cordova-plugin-media\CDVSound.m:690

change these lines:

NSMutableDictionary *audioSettings = [NSMutableDictionary dictionaryWithDictionary:
@{AVSampleRateKey: @(44100),
 AVEncoderBitRateKey : @128000,
 AVNumberOfChannelsKey: @(1),
 }];

d3xtr0 avatar Feb 13 '22 11:02 d3xtr0