mergeVideos method

Future<void> mergeVideos({
  1. required String listFileTextPath,
  2. required String outputPath,
  3. bool isOverride = true,
  4. void onStdout(
    1. String data
    )?,
})

multiple videos join

Example

listFileTextPath -> list_file.txt

#wirte down

file '/path/video1.mp4'
file '/path/video2.mp4'
file '/path/video3.mp4'

Implementation

Future<void> mergeVideos({
  required String listFileTextPath, // concat input list file path
  required String outputPath,
  bool isOverride = true,
  void Function(String data)? onStdout,
}) async {
  final outFile = File(outputPath);
  if (outFile.existsSync() && isOverride) {
    await outFile.delete();
  }
  final args = <String>[
    '-f',
    'concat',
    '-safe',
    '0',
    '-i',
    listFileTextPath,
    '-c',
    'copy',
    outputPath,
  ];

  await ffmpegStart(arguments: args, onStdErrorOut: onStdout);
}