I have a trouble in my app.
I want to record a sound and store it in iOS using Cordova. I have already a base64/wav file, but it's very heavy so I want to convert it into a base64/mp3.
Which is the algorithm that allows me to do that?
Example:
b64Wavtob64mp3("base64/...");
// Return a mp3 base64
Thanks in advance!
I forgot completely base64
because I was looking for a audio compressed
Solved!
I did it with a wav2m4a
plugin.
But I wanted to go further so I modified CDVSound.m
at iOS.
I just followed these instructions:
Add to the startRecordingAudio
method on CDVSound.m
this:
NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:16000.0], AVSampleRateKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, nil];
Replace:
audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:nil error:&error]; // Default PCM recording
With:
audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:recordSettings error:&error];
I changed it to:
#define RECORDING_WAV @"m4a"
or
#define RECORDING_M4A @"m4a"
and change in the file instances that contains the RECORDING_WAV
variable.