Convert videos to audio files. (Only iOS is supported for now)
-
Install nitro modules package
$ npm i react-native-nitro-modules -
Install video to audio package
$ npm i react-native-video-to-audio
For usage details, please refer to the src folder of the example app. https://github.com/chsdwn/react-native-video-to-audio/tree/main/example/src
import VideoToAudio, { ERROR_MESSAGES } from 'react-native-video-to-audio';
const convert = async () = {
try {
const videoUri = ""; // local video uri
const audioUri = await VideoToAudio.convertToAudio(videoUri);
} catch (error) {
if (error?.message === ERROR_MESSAGES.iOS.INVALID_URI) {
// it must be a local video uri
// e.g: file:///X/Y/video.mp4 or /X/Y/video.mp4
}
if (error?.message === ERROR_MESSAGES.iOS.COMPATIBILITY_CHECK_FAILED) {
// selected video cannot be converted to a .m4a audio file
}
if (error?.message === ERROR_MESSAGES.iOS.EXPORT_FAILED) {
// audio file is created but cannot be saved to the device
}
}
};- [ ]: Android support
- [ ]: Tests
