i merged video with auto with this command
final command = "-i file.mp4 -i audio.mp3 -c:v copy -c:a aac -b:a 128k -shortest video.mp4 "
final return0 = await FFmpegKit.execute(command);
(https://pub.dev/packages/ffmpeg_kit_flutter)
but the video after merging lost the sound of the video only the music
how can i (Merge an Audio file with a Video file in Flutter without losing the original audio of the video)
Merge an Audio file with a Video file in Flutter without losing the original audio of the video
>Solution :
Haven’t been able to test this snippet but this might help:
final command = "-i file.mp4 -i audio.mp3 -filter_complex \"[0:a][1:a]amix=inputs=2:duration=shortest[outa]\" -map 0:v -map \"[outa]\" -c:v copy -c:a aac -b:a 128k -shortest video.mp4";
final return0 = await FFmpegKit.execute(command);
- filter_complex "[0:a][1:a]amix=inputs=2:duration=shortest[outa]": This part combines the audio streams from the video file (identified by [0:a]) and the audio file (identified by [1:a]) into a single output stream [outa] using the amix filter.
- map 0:v: This makes sure that the video stream from the original file is selected
- map "[outa]": This maps the combined audio stream to the output