npm

react-native-convert-mov-to-mp4

0.2.2 • Public • Published

react-native-convert-mov-to-mp4

Convert mov file to mp4 for cross-platform playback compatibility. This project is based on https://www.npmjs.com/package/react-native-mov-to-mp4 we created this project for fix import path

Installation

react-native >= 0.40:

npm install react-native-convert-mov-to-mp4 --save

also for iOS:

cd ios && pod install && cd ..

react-native < 0.40:

npm install react-native-convert-mov-to-mp4 --save

link react-native-convert-mov-to-mp4:

react-native link react-native-convert-mov-to-mp4
import MovToMp4 from 'react-native-convert-mov-to-mp4';

const filename = Date.now().toString();
MovToMp4.convertMovToMp4(data.path, filename + ".mp4")
  .then(function (results) {
    //here you can upload the video...
    console.log(results);
  });
          

Parameters:

convertMovToMp4(videoFilePath,newFilenameMp4,callback)

Example

this example use react-native-camera

render() {
    return (
      <View style={styles.container}>
        <Camera
            ref={(cam) => {
            this.camera = cam;
          }}
            captureTarget={Camera.constants.CaptureTarget.disk}
            captureMode={Camera.constants.CaptureMode.video}
            style={styles.preview}
            aspect={Camera.constants.Aspect.fill}>
          <Text style={styles.capture} onPress={this.takeVideo.bind(this)}>[CAPTURE]</Text>
        </Camera>
      </View>
    );
  }
  takeVideo() {
    if(this.isRec){
      this.isRec = false;
      this.camera.stopCapture();
    }else {
      this.isRec = true;
      this.camera.capture()
          .then((data) => {
            const filename = Date.now().toString();
            MovToMp4.convertMovToMp4(data.path, filename + ".mp4")
              .then(function (results) {
              //here you can upload the video...
              console.log(results);
            });
          })
          .catch(err => console.error(err));
    }
  }

License

MIT

Package Sidebar

Install

npm i react-native-convert-mov-to-mp4

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

16.8 kB

Total Files

12

Last publish

Collaborators

  • wdayanand