i want to merge an intro.mp4 (located in the assets folder of my project) video with the cameraRecord Output video (let’s say output.mp4)
i tried this (code below) but it gives a bad result (the output video is side by side not sequential ) also it didn’t work with the assets folder i think all the paths should come from the device and not from the project (assets …)
Future<void> mergeRecordWithIntro(String outputPath, String videoPath) async {
emit(MergeVideoLoading());
const String introPath = 'assets/logo.mp4';
const filter =
" [0:v]scale=480:640,setsar=1[l];[1:v]scale=480:640,setsar=1[r];[l][r]hstack;[0][1]amix -vsync 0 ";
await FFmpegKit.execute(
'-y -i $videoPath -i $videoPath -filter_complex $filter $outputPath')
.then((value) async {
final returnCode = await value.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
GallerySaver.saveVideo(outputPath);
emit(MergeVideoSucces());
} else if (ReturnCode.isCancel(returnCode)) {
emit(MergeVideoError());
}
});
this is my updates log screen shot using this command :
-y -i $firstVideoPath -i $secondVideoPath -filter_complex "[0:v]scale=480:640[v0];[1:v]scale=480:640[v1];[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" $outputPath
2
Answers
this command worked for me the only problem is the output video quality is very low so... !! :
First, save the video in the project’s assets folder to a temporary folder and use the path there.
Next, the command to merge videos is
concat
, so fix it. *If you have a different resolution or codec, you may need to fix it.Finally, use the gal package instead of the gallery_saver, which is already two years out of maintenance.