I've been trying to merge videos using a flutter ffmpeg package, but for some reason it doesn't work. Here is my current approach.
Future<String> mergeVideos(List<String> paths) async {
final appDir = await getApplicationDocumentsDirectory();
String rawDocumentPath = appDir.path;
final outputPath = '$rawDocumentPath/output.mp4';
String videos = '';
for (int i = 0; i < paths.length; i++) {
videos = videos + ' -i ${videoFragmentsPaths[i]}';
}
String commandToExecute =
'-y $videos -filter_complex \'[0:0][1:0]concat=n=2:v=1:a=0[out]\' -map \'[out]\' $outputPath';
final ffmpegSession = await FFmpegKit.execute(commandToExecute);
final returnCode = await ffmpegSession.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
// SUCCESS
print('success');
} else if (ReturnCode.isCancel(returnCode)) {
// CANCEL
print('cancel');
} else {
// ERROR
print('error');
}
print(File(outputPath).lengthSync());
return outputPath;
}