0

Let's say you want to add a looped background audio from bg.mp3 to your mp4 video file.

0

This one would add (possibly replace if there was any in the video) the audio of the mp4 with looped background:

ffmpeg -y -stream_loop -1 -i "bg.mp3" -i "video.mp4" \
-map 0:a:0 -map 1:v:0 -c:v copy -c:a aac -ac 2 -shortest out.mp4

If you would like to merge the background audio with existing audio of the video file you would go for the amerge filter.

  • The loop is infinite but the output duration isn't set, so the output generation will not stop. – Gyan Oct 7 '19 at 5:41
  • Have you tried the command? – ed22 Oct 7 '19 at 8:55
  • I have - output doesn't terminate. – Gyan Oct 7 '19 at 8:56
  • You can add a "-shortest" parameter then, I utilized the "amerge" filter in my original command line which terminates with the shortest input stream and the "-shortest" parameter is not needed. Here, you are right it is required. – ed22 Oct 7 '19 at 8:58
  • Share log of your execution - if it isn't an older version, maybe it's a corner case bug. – Gyan Oct 7 '19 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.