<p>Use</p>

<pre><code>ffmpeg -re -stream_loop -1 -i file.flv -c copy -f flv rtmp://x.y.z
</code></pre>

<p>This option is buggy when the input it is applied to is filtered with another input, like in an overlay. For a single input - output chain, it works fine.</p>

CC BY-SA 3.0
2016-05-09T14:35:34.333Z
Unrecognized option 'stream_loop'.
spacer GIF
CC BY-SA 3.0
2016-05-09T14:41:05.913Z
You'll need a ffmpeg build from Oct 2015 or later.
Gyan
CC BY-SA 3.0
2016-05-09T14:45:57.037Z
Oh. How do I get a more recent version? I have Ubuntu 15.04 but it has certainly had updates since October!
spacer GIF
CC BY-SA 3.0
2016-05-09T14:49:51.873Z
Get them from here: http://johnvansickle.com/ffmpeg/
Gyan
CC BY-SA 3.0
2016-05-09T15:03:14.457Z
Thanks! I'll download it later today, wonder what on earth a .xz file is then pray this works. Will do it on a server though since that way there's no real chance of upsetting things on my computer such as Openshot. Do you advise uninstalling the repositories version first?
spacer GIF
CC BY-SA 3.0
2016-05-09T15:17:18.270Z
This is a static build. It won't affect anything else. Just don't put in one of the path locations to avoid it being called by other programs.
Gyan
CC BY-SA 3.0
2016-05-09T15:35:17.223Z
Oh, okay. I've got it.  :P

Trying it soon.
spacer GIF
CC BY-SA 3.0
2016-05-09T15:49:20.637Z
Just tried it and it outputs the video once, adds a minute to the timestamp for some reason then gets stuck.  :/
spacer GIF
CC BY-SA 3.0
2016-05-09T15:50:18.180Z
Add `-fflags +genpts` before `-i`
Gyan
CC BY-SA 3.0
2016-05-09T15:52:03.230Z
Same thing is happening. `./ffmpeg -re -stream_loop -1 -fflags +genpts -i ../file.flv -c copy -f flv test2.flv`
spacer GIF
CC BY-SA 3.0
2016-05-09T16:14:02.100Z
I tested it here. It loops, but the timecode is buggy and jumps 30 seconds after each loop on a 10 second input. Which is to say, it's buggy.
Gyan
CC BY-SA 3.0
2016-05-09T04:31:53.547Z
2016-05-09T14:50:44.563Z
2016-05-09T14:50:44.563Z
Gyan
<p>Is there a way to infinitely loop a video in ffmpeg for a livestream? I've been looking around and can see it was possible to use "loop 1" but it appears that is no longer working.</p>

<p>This is what I'm currently using, but as you can see, it is not infinitely looping and entering a ridiculously high number is not an option for me due to 32-bit integer limitations:</p>

<pre><code>ffmpeg -re -f concat -i &lt;(for i in {1..10000}; do printf "file '%s'\n" /root/file.flv; done) -codec copy -f flv rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx
</code></pre>

CC BY-SA 3.0
2016-05-10T16:36:32.277Z
_Update:_ In my testing, I got `WriteN, RTMP send error 104 (52 bytes)` after a few hours so will probably just call it quits and say Ffmpeg just isn't up to livestreaming. Thanks anyway, folks!
spacer GIF
<video><ffmpeg><rtmp>
Infinite Video Loop in Ffmpeg?
spacer GIF
# Infinite Video Loop in Ffmpeg?

(Asked by: username_0 on 2016-05-08)

Is there a way to infinitely loop a video in ffmpeg for a livestream? I've been looking around and can see it was possible to use "loop 1" but it appears that is no longer working.
This is what I'm currently using, but as you can see, it is not infinitely looping and entering a ridiculously high number is not an option for me due to 32-bit integer limitations:
ffmpeg -re -f concat -i <(for i in {1..10000}; do printf "file '%s'\n" /root/file.flv; done) -codec copy -f flv rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx

**Tags:** video, ffmpeg, rtmp

> **Comments:**
> **username_0**: _Update:_ In my testing, I got `WriteN, RTMP send error 104 (52 bytes)` after a few hours so will probably just call it quits and say Ffmpeg just isn't up to livestreaming. Thanks anyway, folks!  

---

## 1 answers

### Answer by username_1 on 2016-05-09. Score: 5

Use
ffmpeg -re -stream_loop -1 -i file.flv -c copy -f flv rtmp://x.y.z

This option is buggy when the input it is applied to is filtered with another input, like in an overlay. For a single input - output chain, it works fine.

> **Comments:**
> **username_0**: Unrecognized option 'stream_loop'.  
> **username_1**: You'll need a ffmpeg build from Oct 2015 or later.  
> **username_0**: Oh. How do I get a more recent version? I have Ubuntu 15.04 but it has certainly had updates since October!  
> **username_1**: Get them from here: http://johnvansickle.com/ffmpeg/  
> **username_0**: Thanks! I'll download it later today, wonder what on earth a .xz file is then pray this works. Will do it on a server though since that way there's no real chance of upsetting things on my computer such as Openshot. Do you advise uninstalling the repositories version first?  
> **username_1**: This is a static build. It won't affect anything else. Just don't put in one of the path locations to avoid it being called by other programs.  
> **username_0**: Oh, okay. I've got it.  :P  Trying it soon.  
> **username_0**: Just tried it and it outputs the video once, adds a minute to the timestamp for some reason then gets stuck.  :/  
> **username_1**: Add `-fflags +genpts` before `-i`  
> **username_0**: Same thing is happening. `./ffmpeg -re -stream_loop -1 -fflags +genpts -i ../file.flv -c copy -f flv test2.flv`  
> **username_1**: I tested it here. It loops, but the timecode is buggy and jumps 30 seconds after each loop on a 10 second input. Which is to say, it's buggy.  

---

