Skip to content

chsdwn/react-native-video-to-audio

Repository files navigation

react-native-video-to-audio

Convert videos to audio files. (Only iOS is supported for now)

Installation

  1. Install nitro modules package $ npm i react-native-nitro-modules

  2. Install video to audio package $ npm i react-native-video-to-audio

Demo

Download Video to Audio

Example

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

iOS

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
    }
  }
};

TODO

  • [ ]: Android support
  • [ ]: Tests

Acknowledgments

About

Convert videos to audio(m4a) files. (Only iOS is supported for now)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors