Applying audio to video background using ffmpeg_kit_flutter package not working in flutter

65 views Asked by At

I am trying to merge video and audio and downloading the video in a flutter app using ffmpeg_kit_flutter package, it works fine with the videos that recorded by screen recorder app which records the screen of my phone, but it does not works with the videos that recorded by my phone camera or any video else and I do not know where the problem is. Here's my code:

Future<void> mergeRecordWithIntro({required String videoPath, required String audiPath, }) 
async 
  {
 final random = Random();
 final directory = await getTemporaryDirectory();

 String outputVideoPath = '${directory.path}/${random.nextInt(10000)}_merged_video.mp4';
 String ffmpegCommand = '-i $videoPath -i $audiPath -c:v copy -c:a aac $outputVideoPath';

 await FFmpegKit.execute(ffmpegCommand)
    .then((value) async {
  await Gal.putVideo(outputVideoPath);
  emit(MergeVideoAudioSuccessState());
  }).catchError((error){
  emit(MergeVideoAudioFailureState());
  });
}
0

There are 0 answers