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
  • 1
    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 May 10 '16 at 16:36


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.

  • Unrecognized option 'stream_loop'. – spacer GIF May 9 '16 at 14:35
  • You'll need a ffmpeg build from Oct 2015 or later. – Gyan May 9 '16 at 14:41
  • Oh. How do I get a more recent version? I have Ubuntu 15.04 but it has certainly had updates since October! – spacer GIF May 9 '16 at 14:45
  • 1
    Get them from here: johnvansickle.com/ffmpeg – Gyan May 9 '16 at 14:49
  • 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 May 9 '16 at 15:03

Use -vf loop=parameters filter, see fine documentation. Note that this currently will put all video frames in memory.

  • The OP will have to re-encode to get the unending output stream. Why does stream_loop not work reliably here? – Gyan May 9 '16 at 20:21
  • There is bug in pts generation form stream_loop I guess. – user12174 May 10 '16 at 10:54
  • In this question, the user would like help on getting an animated zoom for a video input. – Gyan May 28 '16 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.