How to merge one image and one audio file to make one video file in Flutter
I attached my code but not working
final Directory tempDir = await getTemporaryDirectory();
final String outputPath =
path.join(tempDir.path, '${DateTime.now().second}output.mp4');
print("Check Image Path ==> ${imagePathSelected}");
print("Check Image Path ==> ${audioPathSelected}");
// Paths to your image and audio files
String imagePath = imagePathSelected!; // Update with actual path
String audioPath = audioPathSelected!; // Update with actual path
await mergeImageAndAudio(imagePath, audioPath, outputPath);
Future<void> mergeImageAndAudio(
String imagePath, String audioPath, String outputPath) async {
// Define the FFmpeg command
String command =
"-y -i $imagePath -i $audioPath -map 0:v -map 1:a -c:v copy "
"-shortest $outputPath";
// Execute the command
int rc = await _flutterFFmpeg.execute(command);
if (rc == 0) {
print("FFmpeg process completed successfully.");
} else {
print("FFmpeg process failed with return code $rc.");
}
}