-1

i'm looking for a methode to merge audio with video file recorded by the camera , i found that the best way is using FFmpeg with react native but there's not any explained documentation on this object, if you any one did something like this before ,

this what i already tried :

react-native-video react-native-video-processing react-native-video-editor : with this i can only merge two video files

1 Answers1

0

Adding an audio to a video using ffmpeg has already been solved on StackOverflow and you can find the link to the thread right here. But to integrate the command into react-native you will first need to build the command in a string and then use it in react using the ffmpeg package. Here is how you’ll do it:

import RNFFmpeg from 'react-native-ffmpeg';

const videoPath = path.mp4';
const audioPath = path.mp3';
const outputPath = path.mp4';

// FFmpeg command to add audio to video
const command = `-i ${videoPath} -i ${audioPath} -c:v copy -c:a aac -strict experimental ${outputPath}`;

RNFFmpeg.execute(command).then(result => {
  console.log(`FFmpeg process exited with rc=${result.rc}`);
}).catch(error => {
  console.log('FFmpeg process failed:', error);
});

One suggestion that I would make, based on my assumption that you are using React-Native and will be hosting your app for different devices, is that it would be beneficial that you settle for a hosting platform like Akamai or Cloudinary for all your assets. This way, you can add transformations to your assets in real-time. Give these a read to learn more in Cloudinary and in Akamai.