<p>You want to take a look at the <code>aloop</code>-filter.</p>

<pre><code>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"
</code></pre>

<p><a href="https://ffmpeg.org/ffmpeg-filters.html#aloop" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#aloop</a></p>

<p>And then you will probably want to limit the song.mp4, so we are using the <code>duration</code> option of <code>amix</code>, to tell it to limit by the first input given. <a href="https://ffmpeg.org/ffmpeg-filters.html#amix" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#amix</a></p>

<pre><code>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"
</code></pre>

<p>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.</p>

CC BY-SA 4.0
2020-06-06T11:36:28.127Z
2020-06-06T11:51:37.893Z
2020-06-06T11:51:37.893Z
Pingger Shikkoken
<p>windows 7 64 bit running latest ffmpeg command-line.</p>

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

<p>I want to loop the 2.mp3 all the way till the video ends.</p>

<p>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.</p>

CC BY-SA 4.0
2020-06-05T20:18:48.823Z
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?
Michael Liebman
<ffmpeg><audio>
ffmpeg add loop to this line of code i have
jenna
# ffmpeg add loop to this line of code i have

(Asked by: username_0 on 2020-06-04)

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.

**Tags:** ffmpeg, audio

> **Comments:**
> **username_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?  

---

## 1 answers

### Answer by username_2 on 2020-06-06. Score: 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.


---

