If an FFmpeg stream goes offline when a playlist finishes, first check whether the input is a finite local file or concat-demuxer list. For either kind of local input that should repeat, put -stream_loop -1 immediately before its matching -i; it requests that FFmpeg read that input again after it reaches EOF.
That setting is not a general keep-alive switch. It does not make every kind of playlist repeat, repair a network failure, or guarantee that YouTube stays live, so confirm which input is ending before changing the command.
Why a playlist reaching EOF can end the broadcast
A local video file has a definite end. FFmpeg reads its packets, processes them and, unless told otherwise, reaches end of file (EOF). If it has no more input to encode or send, the process may finish and close its output connection. YouTube can then show the stream as ended or offline. The exact status you see depends on the command’s exit and YouTube’s stream or event state, so EOF and the platform display are related clues rather than interchangeable diagnoses.
A playlist can mean different things. It might be one local file, a text file consumed by FFmpeg’s concat demuxer, or a network playlist whose contents are fetched or refreshed over a connection. A looping option intended for a finite local input should not be assumed to handle the latter cases. Start by identifying what follows -i in the command and what format that input actually has.
The FFmpeg project’s command-line documentation describes -stream_loop as an input option and defines -1 as infinite looping, with 0 meaning no loop. That describes the requested input behaviour; it is not an uptime guarantee for the encoder, network path or YouTube ingest. If your production is built around a playlist and you need to replace or rearrange items, our guide to changing a video playlist without interrupting a YouTube live stream covers the separate question of changing content while broadcasting.
Confirm which input is actually ending
Read the complete FFmpeg command from left to right. Each -i introduces an input; options placed before an input generally apply to the next file or source. If a command includes a background clip, an audio bed and an overlay, it may contain several inputs. A loop option placed before the wrong -i will not loop the file that reaches EOF.
For example, this command has two inputs:
ffmpeg -stream_loop -1 -re -i background.mp4 -i narration.wav [mapping and output options] [YouTube ingest destination]
Here the loop option is associated with background.mp4, not narration.wav. If the narration ends first and the output needs it to continue, looping the video does not solve that mismatch. Conversely, adding the loop option before the narration input would not make the background repeat. Check input order and any -map options together so you know which audio and video streams reach the output.
Look at FFmpeg’s final log lines as well as the command. They can show that an input reached EOF, but the process might instead have stopped because of a malformed playlist, an unavailable file, an encoder error, a broken connection or another failure. If FFmpeg remains running while YouTube reports an issue, that is evidence to investigate the output path or stream state rather than assuming a local file reached its end. Do not infer the cause from the platform’s offline label alone.
If the playlist lives on a separate machine or volume, confirm the exact path and that the process can read it. A playlist that names files using paths valid only on your desktop will not necessarily work on a VPS. Our notes on transferring playlist videos to a VPS for an FFmpeg YouTube stream explain why the media files and the paths in a list have to be available where FFmpeg runs.
Put the loop option before the matching -i
The important placement is:
ffmpeg -stream_loop -1 -i input.mp4 [output options] output
-stream_loop belongs on the input side, before the -i that opens the file or list to repeat. It does not belong after that input’s -i, nor does putting it beside the final YouTube destination make the destination repeat. FFmpeg command-line options are order-sensitive in this respect: ordinary options apply to the next specified input or output. If you have several inputs, position the option directly before the intended one and review the rest of the command for clarity.
Use -1 when the intention is for this input to repeat without a planned final pass. The documented value 0 means no looping; it is not the value to use for an infinite repeat. These are option values, not performance figures. For finite repetition rather than an open-ended loop, consult the documentation for the supported option syntax in the FFmpeg build you actually run.
A useful check is to make a copy of the command and mark every -i with the option that precedes it. Then identify which input supplies the stream that runs out. If that is the local file you want repeated, the loop flag should occur before its -i. If the source is a network URL or a live capture input, pause before applying this recipe: the documented behaviour does not establish that it will solve the failure you are seeing.
Example: one local file sent to YouTube
For a single local MP4, a command pattern is:
ffmpeg -stream_loop -1 -re -i input.mp4 [encoding and output options] [YouTube ingest destination]
Replace the bracketed parts with the encoding settings and ingest destination required by your setup. The example shows option order, not a complete command for every channel. The loop option repeats the local input; -re is separate and controls reading pace. FFmpeg defines -re as reading at the input’s native frame rate, equivalent to -readrate 1, which can be useful when reading a file for live output. It does not cause a repeat.
If you omit -re, the loop request does not change into a pacing instruction. A file reader may process media faster than real time unless the rest of the command or input type imposes a pace. For a live-style output from a file, check whether your command should use -re, and confirm that it is placed before the same input whose reading rate you intend to control.
Test the command while watching both the FFmpeg log and YouTube’s live status. Near the point where the file would ordinarily finish, FFmpeg should proceed into another pass of the input rather than simply finishing because the file ended. A visible cut, repeated opening frame or audio discontinuity may indicate a content or stream-boundary issue even if the process continues. A test of one file cannot establish that a longer run will avoid unrelated failures.
For a channel built from recorded material, also consider the publishing workflow: repeating a single file is different from rotating several videos. The distinction matters for devotional, study or ambience channels where a long sequence may be preferable to a single repeated segment. Our overview of continuous YouTube livestreams using a browser-based service addresses a different way to keep a pre-recorded channel running when maintaining a local FFmpeg process is the pain point.
Looping a concat-demuxer playlist
For a local concat-demuxer list, put the loop option before the -i that reads the list. A command pattern is:
ffmpeg -stream_loop -1 -re -f concat -i playlist.txt [encoding and output options] [YouTube ingest destination]
The order shown makes the loop apply to the concat input. The -f concat option identifies the input format and belongs with the input declaration; the playlist file then follows -i. Check the concat-demuxer syntax and playlist format against the FFmpeg version installed on the machine running the job. A list intended for one environment may contain relative paths or formatting that behaves differently elsewhere.
Looping the list does not make incompatible media compatible. FFmpeg’s concat demuxer expects the component files to have matching streams, codecs and time base. If one item has different stream structure or timing characteristics, a transition may fail or behave unexpectedly. The FFmpeg-user mailing-list discussion on concat-demuxer compatibility notes the practical problem of files that differ in format; examine the documentation for the demuxer and the actual media rather than expecting the loop setting to normalise them.
Before relying on a long-running list, check each entry, path and media file. Confirm that the list reaches all intended items once, then test that it begins again after the final entry. If the last item is followed by an error, inspect whether the list syntax is accepted and whether the input streams satisfy the concat constraints. If you need to rotate episodes or other items, our guide to using a text playlist to rotate podcast episodes in a 24/7 YouTube stream deals with the playlist design as a separate concern from EOF looping.
Check timing, audio and output behaviour
A repeated input can have an abrupt boundary. A file may end on a quiet frame, a spoken sentence or a musical phrase that does not join smoothly to its beginning. Looping repeats the media as encoded; it does not add a fade, crossfade, gapless audio edit or scene transition. Listen and watch across the file boundary, not just at the start of a test.
Audio and video may also end at different moments. A separate audio bed can be shorter than the video, or an overlay can have its own duration. Confirm which streams are mapped into the output, whether each input is intended to repeat, and what FFmpeg does when one stream ends before another. A loop setting on the video input does not automatically extend a separate audio input.
Keep -re distinct from looping. It can pace file reading at the native frame rate for live output, but it is not a recovery mechanism. FFmpeg cautions against applying low read rates to actual capture devices or live streams, where throttling can cause packet loss. Do not copy the file-based example unchanged onto a live or network source without understanding the input and the effect of each option.
Finally, distinguish media timing from output health. The local input can be repeating while the encoder, network connection or YouTube ingest is not functioning as intended. Observe FFmpeg’s process and error output, and check the relevant YouTube stream status independently. If the process exits, its last error is more useful than repeatedly moving the loop flag without confirming which input it belongs to.
What input looping cannot fix
-stream_loop -1 is appropriate for repeating a finite input when FFmpeg supports that input type and it reaches EOF. It is not a universal loop for every source. A live/network playlist may rely on a refresh mechanism or a connection that has stopped; looping the input is not evidence that refresh or reconnection will work. Treat that as a source or network diagnosis and consult the relevant tool’s documentation.
It also cannot fix an invalid concat list, missing media, unsupported codecs, incompatible streams, encoder failure or an output destination problem. If FFmpeg exits after the input loop is in the right place, preserve the command and the error output, then diagnose the reported failure. If FFmpeg continues but YouTube does not show an active broadcast, inspect ingest and event state separately. Do not assume that either side’s status explains the other.
A loop is also not a content strategy. Repeating a file can create a noticeable seam or repeat material more often than you intend. For a channel that needs a planned sequence, test the order and transitions, and make sure the list itself expresses the desired schedule. If the specific burden is keeping a local computer on and watching for a dropped process, StreamNeo removes that particular task by taking an uploaded video and running it as a YouTube live stream while your computer is off; it does not change the limits of FFmpeg’s input option or make every source type suitable for looping.
When FFmpeg’s command-line behaviour is unclear, use the official FFmpeg documentation and check the version and input format in use. For YouTube-side status or stream setup, consult current YouTube Help rather than relying on an old checklist. Neither a looping input nor a successful local test guarantees a continuous YouTube broadcast.
Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.
FAQ
Where exactly does -stream_loop -1 go?
Put it before the -i that opens the local file or concat list you want repeated. With multiple inputs, it applies to the next input, so check that this is the input that actually reaches EOF.
Does -re make FFmpeg loop a file?
No. -re paces reading at the file’s native frame rate; -stream_loop -1 requests infinite repetition of an eligible input. They serve different purposes and may both appear before the same local-file -i.
Will this keep YouTube live if a network playlist stops refreshing?
Do not rely on it for that. A network or live playlist has different refresh and connection behaviour, and this option does not establish that those failures recover. Diagnose the source, connection, FFmpeg process and YouTube status separately.
Why is the stream still offline after I added the loop option?
First verify that the flag is before the correct -i and that the input is a finite local source supported by the option. Then inspect FFmpeg’s exit or error output and YouTube’s stream status; an encoder, playlist, connection or ingest issue may be unrelated to EOF.