Open immocalcul opened 1 year ago
@immocalcul , you can use ffmpeg-kit-react-native
to convert the audio file to wav format.
import {FFmpegKit, ReturnCode} from 'ffmpeg-kit-react-native';
const recordedAudioPath = await audioRecorderPlayer.stopRecorder();
const wavFilePath = `${
RNFS.CachesDirectoryPath
}/${Date.now()}recordedAudio.wav`;
const command = `-i ${recordedAudioPath} -vn -acodec pcm_s16le -ar 16000 -ac 1 -b:a 256k ${wavFilePath}`;
const session = await FFmpegKit.execute(command);
// Return code for completed sessions.
// Will be undefined if session is still running or FFmpegKit fails to run it
const returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
const exists = await RNFS.exists(wavFilePath);
console.log('exists ', exists);
if (exists) {
// do your stuff with the wav audio file
}
}
A bit late here, but in case someone is looking, I was able to get IOS to save as a wav with this configuration:
const path = Platform.select({
ios: `file://${recordingDirectory}/${fileName}.wav`,
android: `data/user/0/com.flow_app/cache/${fileName}.mp4`,
});
const audioSet = {
AudioSamplingRateAndroid: 44100,
AVEncoderAudioQualityKeyIOS: 'low',
AVFormatIDKeyIOS: 'wav',
AVNumberOfChannelsKeyIOS: 2
};
"Hello, I have been unsuccessfully trying to save my record in WAV format on iOS. Is this something that's possible, or do we absolutely have to use the M4A format?