Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T08:15:29.317Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T08:30:14.273Z
Answers.Text: Do you intend to 'live-stream' the looped output?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T08:59:54.490Z
Answers.Text: 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..
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T09:09:24.937Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T09:13:48.603Z
Answers.Text: Strange. Can you upload your sample?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T09:21:32.550Z
Answers.Text: https://drive.google.com/open?id=0B0YATlG4DeOdd0RURUNJUG9mVFE
  Note visually this is not a loop, this is just something to test audio sync.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T10:26:12.697Z
Answers.Text: 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
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T10:33:31.137Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T10:56:29.207Z
Answers.Text: Ok, but when you play it, is the timing of the beep like I see it?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T11:05:13.663Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T11:14:38.983Z
Answers.Text: 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.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T11:28:53.220Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-25T13:54:10.630Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-25T15:49:32.653Z
Answers.Text: Images will work as there is a dedicated loop option (and code): `-loop 1`
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-25T15:50:04.413Z
Answers.Text: I'll look into your sample sometime during the next few days.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-25T17:38:04.953Z
Answers.Text: 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.
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-23T23:02:06.167Z
Answers.Text: Any updates? I have pause about 15-20seconds between loops. That's disgusting
Answers.UserDisplayName: Ngoral
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-24T11:26:34.173Z
Answers.Text: Are you using current version of ffmpeg? The ticket is marked as fixed in Nov '17.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-25T09:46:43.400Z
Answers.Text: Working for me in latest version of FFMPEG. Doesn't work with the version packaged with Ubuntu 18.04 currently (3.4.4)
Answers.UserDisplayName: Baa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-22T15:46:39.837Z
Answers.LastActivityDate: 2017-06-22T15:46:39.837Z
Answers.UserDisplayName: Gyan
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-10T19:56:07.533Z
Answers.LastActivityDate: 2021-01-10T19:56:07.533Z
Answers.UserDisplayName: Marc A
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-02T13:36:32.947Z
Comments.Text: Did you manage to solve this? I am facing this for audio loops
Comments.UserDisplayName: workwise
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-03T14:17:41.463Z
Comments.Text: See comments below, it's been fixed.
Comments.UserDisplayName: Mike Versteeg
Tags: <ffmpeg>
Title: Why does FFmpeg's stream_loop option add a pause?
UserDisplayName: Mike Versteeg
ThreadText: # 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.
  
  
  ---
  
  