Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Merge an Audio file with a Video file in Flutter without losing the original audio of the video

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading