<p>This is a known bug with stream_loop. See <a href="https://trac.ffmpeg.org/ticket/5719" rel="nofollow noreferrer">https://trac.ffmpeg.org/ticket/5719</a></p>

<p>Wrapping to MKV or TS and then looping <em>may</em> work. Re-encoding your video as intraframe is the safest option.</p>

CC BY-SA 3.0
2017-06-23T08:15:29.317Z
Wow, reported 11 months ago already and it's still there.. Re-encoding is not an option for me unfortunately, clients have pre-made loops.
Mike Versteeg
CC BY-SA 3.0
2017-06-23T08:30:14.273Z
Do you intend to 'live-stream' the looped output?
Gyan
CC BY-SA 3.0
2017-06-23T08:59:54.490Z
It is processed live, so I guess that is a 'yes'. So it's not possible to cut out pauses, if that's where you're heading..
Mike Versteeg
CC BY-SA 3.0
2017-06-23T09:09:24.937Z
BTW: wrapping in ts (no difference) or mkv (shorter pause) is no fix either. Neither is re-encoding to intraframe. The very visible pause remains present.
Mike Versteeg
CC BY-SA 3.0
2017-06-23T09:13:48.603Z
Strange. Can you upload your sample?
Gyan
CC BY-SA 3.0
2017-06-23T09:21:32.550Z
https://drive.google.com/open?id=0B0YATlG4DeOdd0RURUNJUG9mVFE
Note visually this is not a loop, this is just something to test audio sync.
Mike Versteeg
CC BY-SA 3.0
2017-06-23T10:26:12.697Z
Before I check this further, let me confirm that in the original file, the flash of the black box happens when the OSD says 1:52:12 and the beep happens at 1:52:16
Gyan
CC BY-SA 3.0
2017-06-23T10:33:31.137Z
I have no idea, someone else made this file. It's just a loop someone whipped up for me a long time ago to check for obvious issues. Served me well to find this issue and of all videos I have this is  nice and small.
Mike Versteeg
CC BY-SA 3.0
2017-06-23T10:56:29.207Z
Ok, but when you play it, is the timing of the beep like I see it?
Gyan
CC BY-SA 3.0
2017-06-23T11:05:13.663Z
I don't see why this is relevant to the issue at hand, but I checked in VirtualDub and audio is 3 frames late. So the first beep is at 1:52:15.
Mike Versteeg
CC BY-SA 3.0
2017-06-23T11:14:38.983Z
I'm checking if the timestamps or stream frame order is wonky. In a video editor, I get the beep at 1:52:13. What the stream_loop bugs relates to, is generating continuous timestamps, but stream quirks can affect this.
Gyan
CC BY-SA 3.0
2017-06-23T11:28:53.220Z
Just so you know I can reproduce the bug with lots of videos, all from different sources.
Interesting about your editor. I have always used VirtualDub as a reference, this is the first time I have any reason to doubt.
Mike Versteeg
CC BY-SA 3.0
2017-06-25T13:54:10.630Z
I wonder if converting it to uncompressed A+V or even separate images and sound track would overcome the bug? Have you tried anything with the sample I uploaded for you? I don't think they will ever fix this btw.
Mike Versteeg
CC BY-SA 3.0
2017-06-25T15:49:32.653Z
Images will work as there is a dedicated loop option (and code): `-loop 1`
Gyan
CC BY-SA 3.0
2017-06-25T15:50:04.413Z
I'll look into your sample sometime during the next few days.
Gyan
CC BY-SA 3.0
2017-06-25T17:38:04.953Z
Yeah, but the documentation is lacking and I get the idea it is just for images, not audio. Remember the loop filter already works fine for just video, it's when audio needs to be included that issues start to happen.
Oh, I just get a warning that we're apparently not supposed to use comments for discussions and we need to move this to chat.
Mike Versteeg
CC BY-SA 3.0
2018-01-23T23:02:06.167Z
Any updates? I have pause about 15-20seconds between loops. That's disgusting
Ngoral
CC BY-SA 3.0
2018-01-24T11:26:34.173Z
Are you using current version of ffmpeg? The ticket is marked as fixed in Nov '17.
Gyan
CC BY-SA 4.0
2019-04-25T09:46:43.400Z
Working for me in latest version of FFMPEG. Doesn't work with the version packaged with Ubuntu 18.04 currently (3.4.4)
Baa
CC BY-SA 3.0
2017-06-22T15:46:39.837Z
2017-06-22T15:46:39.837Z
Gyan
<p>I am streaming a looping video and was struggling with pauses in-between loops too. What I discovered was that I was streaming at 24 FPS, but my input video was 23.97. Re-encoding the video at 24 FPS with the FPS filter <code>fps=fps=24</code> resolved the issue.</p>
<p>See <a href="https://trac.ffmpeg.org/wiki/ChangingFrameRate" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/ChangingFrameRate</a> for more information on changing the frame rate with FFmpeg.</p>

CC BY-SA 4.0
2021-01-10T19:56:07.533Z
2021-01-10T19:56:07.533Z
Marc A
<p>I have tested several files with the added option</p>

<pre><code>-fflags +genpts -stream_loop -1
</code></pre>

<p>to make them loop, but all have a slight pause just before they loop (250 ms or so). The loop filter does not have this issue, but it has other issues.</p>

CC BY-SA 4.0
2023-05-02T13:36:32.947Z
Did you manage to solve this? I am facing this for audio loops
workwise
CC BY-SA 4.0
2023-05-03T14:17:41.463Z
See comments below, it's been fixed.
Mike Versteeg
<ffmpeg>
Why does FFmpeg's stream_loop option add a pause?
Mike Versteeg
# Why does FFmpeg's stream_loop option add a pause?

(Asked by: username_0 on 2017-06-22)

I have tested several files with the added option
-fflags +genpts -stream_loop -1

to make them loop, but all have a slight pause just before they loop (250 ms or so). The loop filter does not have this issue, but it has other issues.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Did you manage to solve this? I am facing this for audio loops  
> **username_0**: See comments below, it's been fixed.  

---

## 2 answers

### Answer by username_2 on 2017-06-22. Score: 1 | Accepted answer

This is a known bug with stream\_loop. See <https://trac.ffmpeg.org/ticket/5719>

Wrapping to MKV or TS and then looping *may* work. Re-encoding your video as intraframe is the safest option.

> **Comments:**
> **username_0**: Wow, reported 11 months ago already and it's still there.. Re-encoding is not an option for me unfortunately, clients have pre-made loops.  
> **username_2**: Do you intend to 'live-stream' the looped output?  
> **username_0**: It is processed live, so I guess that is a 'yes'. So it's not possible to cut out pauses, if that's where you're heading..  
> **username_0**: BTW: wrapping in ts (no difference) or mkv (shorter pause) is no fix either. Neither is re-encoding to intraframe. The very visible pause remains present.  
> **username_2**: Strange. Can you upload your sample?  
> **username_0**: https://drive.google.com/open?id=0B0YATlG4DeOdd0RURUNJUG9mVFE Note visually this is not a loop, this is just something to test audio sync.  
> **username_2**: Before I check this further, let me confirm that in the original file, the flash of the black box happens when the OSD says 1:52:12 and the beep happens at 1:52:16  
> **username_0**: I have no idea, someone else made this file. It's just a loop someone whipped up for me a long time ago to check for obvious issues. Served me well to find this issue and of all videos I have this is  nice and small.  
> **username_2**: Ok, but when you play it, is the timing of the beep like I see it?  
> **username_0**: I don't see why this is relevant to the issue at hand, but I checked in VirtualDub and audio is 3 frames late. So the first beep is at 1:52:15.  
> **username_2**: I'm checking if the timestamps or stream frame order is wonky. In a video editor, I get the beep at 1:52:13. What the stream_loop bugs relates to, is generating continuous timestamps, but stream quirks can affect this.  
> **username_0**: Just so you know I can reproduce the bug with lots of videos, all from different sources. Interesting about your editor. I have always used VirtualDub as a reference, this is the first time I have any reason to doubt.  
> **username_0**: I wonder if converting it to uncompressed A+V or even separate images and sound track would overcome the bug? Have you tried anything with the sample I uploaded for you? I don't think they will ever fix this btw.  
> **username_2**: Images will work as there is a dedicated loop option (and code): `-loop 1`  
> **username_2**: I'll look into your sample sometime during the next few days.  
> **username_0**: Yeah, but the documentation is lacking and I get the idea it is just for images, not audio. Remember the loop filter already works fine for just video, it's when audio needs to be included that issues start to happen. Oh, I just get a warning that we're apparently not supposed to use comments for discussions and we need to move this to chat.  
> **username_3**: Any updates? I have pause about 15-20seconds between loops. That's disgusting  
> **username_2**: Are you using current version of ffmpeg? The ticket is marked as fixed in Nov '17.  
> **username_4**: Working for me in latest version of FFMPEG. Doesn't work with the version packaged with Ubuntu 18.04 currently (3.4.4)  

---

### Answer by username_5 on 2021-01-10. Score: 0

I am streaming a looping video and was struggling with pauses in-between loops too. What I discovered was that I was streaming at 24 FPS, but my input video was 23.97. Re-encoding the video at 24 FPS with the FPS filter `fps=fps=24` resolved the issue.

See <https://trac.ffmpeg.org/wiki/ChangingFrameRate> for more information on changing the frame rate with FFmpeg.


---

