0

windows 7 64 bit running latest ffmpeg command-line.

ffmpeg -i "song.mp4" -i "2.mp3" -filter_complex "[1:a]adelay=3000|60000[1a];[0:a][1a]amix" -vcodec copy -y "output1.mp4"

I want to loop the 2.mp3 all the way till the video ends.

The 2.mp3 finishes after xxx time in 2.mp3 so I wish to loop it instead of how do I add a loop to this.

1
  • 1
    Welcome! It is a bit unclear what you are asking. Are you saying that 2.mp3 is shorter than song.mp4 and you want to loop the mp3? Or is it the other way around? Jun 5 '20 at 20:18
0

You want to take a look at the aloop-filter.

ffmpeg -i "song.mp4" -i "2.mp3" -filter_complex "[1:a]aloop=loop=-1[al];[al]adelay=3000|60000[1a];[0:a][1a]amix" -vcodec copy -y "output1.mp4"

https://ffmpeg.org/ffmpeg-filters.html#aloop

And then you will probably want to limit the song.mp4, so we are using the duration option of amix, to tell it to limit by the first input given. https://ffmpeg.org/ffmpeg-filters.html#amix

ffmpeg -i "song.mp4" -i "2.mp3" -filter_complex "[1:a]aloop=loop=-1[al];[al]adelay=3000|60000[1a];[0:a][1a]amix=duration=first" -vcodec copy -y "output1.mp4"

Since I am not sure which of the two files you want to loop and don't know if you want to loop before or after the delay you might need to adjust the order of filters.

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.