<p>I found a workaround for this <a href="https://www.reddit.com/r/ffmpeg/comments/vooezk/stream_loop_creates_gap_in_audio/" rel="nofollow noreferrer">here</a>! Using <code>wav</code> file as input instead of <code>mp3</code> works.</p>
<p>Also in my trials, I found that even <code>aac</code> files suffer from this delay, somehow, <code>wav</code> files do not!</p>

CC BY-SA 4.0
2023-05-02T14:21:50.580Z
2023-05-02T14:21:50.580Z
workwise
<p>I want to loop an audio file infinitely. The <code>-stream_loop -1</code> option adds a small pause  / jerk between the loops, as also mentioned in <a href="https://video.stackexchange.com/questions/21759/why-does-ffmpegs-stream-loop-option-add-a-pause">this question with no solution</a>.
The same question mentions that filter loop works fine without delay. But I am unable to get the filter loop to work. The below code along with rest of the command:</p>
<pre><code> -filter_complex &quot;[1:a]aloop=loop=-1&quot;
</code></pre>
<p>gives a warning:</p>
<pre><code>[Parsed_aloop_0 @ 0x55d83e516b80] Number of samples to loop is not set!
</code></pre>
<p>What is the correct way to loop an audio endlessly using filter loop? I am trying to merge a video and audio, having them both independently loop infinitely. I have got that part to work using <code>-stream_loop -1</code> but it has a minor delay between loops as I mentioned. I am looking for a solution using either <code>filter_complex</code> or any other way if possible. Thanks!</p>
<p>Note, I have also noticed that <code>ffplay -loop 0</code>  plays the loop smoothly without adding this pause.</p>

<ffmpeg><audio>
Using ffmpeg audio filter loop instead of stream_loop as stream_loop adds a delay
workwise
# Using ffmpeg audio filter loop instead of stream_loop as stream_loop adds a delay

(Asked by: username_0 on 2023-05-02)

I want to loop an audio file infinitely. The -stream_loop -1 option adds a small pause  / jerk between the loops, as also mentioned in this question with no solution.
The same question mentions that filter loop works fine without delay. But I am unable to get the filter loop to work. The below code along with rest of the command:
 -filter_complex "[1:a]aloop=loop=-1"

gives a warning:
[Parsed_aloop_0 @ 0x55d83e516b80] Number of samples to loop is not set!

What is the correct way to loop an audio endlessly using filter loop? I am trying to merge a video and audio, having them both independently loop infinitely. I have got that part to work using -stream_loop -1 but it has a minor delay between loops as I mentioned. I am looking for a solution using either filter_complex or any other way if possible. Thanks!
Note, I have also noticed that ffplay -loop 0  plays the loop smoothly without adding this pause.

**Tags:** ffmpeg, audio


---

## 1 answers

### Answer by username_0 on 2023-05-02. Score: 0

I found a workaround for this [here](https://www.reddit.com/r/ffmpeg/comments/vooezk/stream_loop_creates_gap_in_audio/)! Using `wav` file as input instead of `mp3` works.

Also in my trials, I found that even `aac` files suffer from this delay, somehow, `wav` files do not!


---

