To make an FFmpeg YouTube stream playlist repeat indefinitely, put -stream_loop -1 before the -i that reads the playlist. For a local-file playlist, -re can also pace the input at its normal playback rate so FFmpeg does not send the files as fast as it can read them.
Those options govern input looping and pacing; they do not keep a process, network connection or YouTube event alive if something else stops. The command below is an illustrative starting pattern, not a tested recipe or a universal fit. Check the files, choose output settings for your material and YouTube’s current guidance, and keep the stream key private.
Check your input files and playlist
Before writing the command, decide whether you are looping one file or a sequence. -stream_loop -1 applies to the input that follows it. If that input is a concat-demuxer playlist, FFmpeg repeats the playlist as an input; if it is a single file, it repeats that file. The placement matters more than the number of clips in the playlist.
Make sure each listed path points to a file the account running FFmpeg can read. Relative paths are interpreted in the context of the process’s working directory, which may not be the directory you expect if you start FFmpeg from a scheduled task or service. Absolute paths are often easier to verify. Use a simple filename convention and keep the playlist and source files in a location that will not be moved while streaming.
Check that the media is yours to broadcast or that you have the necessary rights. A file playing continuously does not change the permissions attached to its music, footage, images or recordings. A playlist of old highlights, for example, may raise rights questions even if the files are already on your computer; the distinction is explored in what to consider before turning old cricket highlights into a replay channel.
Also check the programme as a viewer would experience it. Listen through the joins, look for black frames or silent stretches, and confirm the final item leads into the first in a way that makes sense. A playlist that loops technically can still make a poor continuous stream if the first and last clips clash in volume, subject or visual style. For a devotional channel, check that the transition between bhajans is acceptable; for a study channel, check that there is no spoken introduction that becomes jarring on every cycle.
Put -stream_loop -1 before the input
FFmpeg treats -stream_loop as an input option. In practical terms, it applies to the next input file named with -i; -1 tells FFmpeg to loop that input indefinitely. The option therefore belongs before the playlist’s -i, not after it. The FFmpeg documentation for input options describes the loop option and its placement.
A typical command shape for a local concat playlist is:
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \
-c:v libx264 -preset veryfast -b:v 5M -maxrate 5M -bufsize 10M \
-g 60 -c:a aac -b:a 128k -f flv 'rtmps://YOUR_YOUTUBE_INGEST_URL/YOUR_STREAM_KEY'
Treat every value here as something to inspect, not something to copy blindly. In particular, replace the example destination with the RTMPS ingest URL and stream key provided for your YouTube stream. Select video codec, bitrate, frame rate, keyframe interval and audio settings for the actual programme and current YouTube requirements. The example includes -g 60, but that value only corresponds to a two-second interval for a 30 fps output; a different frame rate requires a different calculation.
The other important option is -re. It reads a file at its native rate, helping to pace output for a live stream. It does not cause looping. FFmpeg’s documentation for the read-rate option explains its purpose and warns against casually applying it to actual capture devices or live inputs, where rate-limiting can cause packet loss. For a local file playlist, it is often relevant; for a live source, reassess it rather than pasting the same command unchanged.
Build a concat-demuxer playlist
For a sequence of local files, create a plain text playlist such as:
file '/absolute/path/clip-01.mp4'
file '/absolute/path/clip-02.mp4'
file '/absolute/path/clip-03.mp4'
Save it as playlist.txt and substitute paths that exist on your system. The concat demuxer reads the entries in order, so the order in the text file is the playback order. If you want a station to return to its opening programme naturally, think about the transition from the last entry back to the first as well as the transitions between adjacent entries.
The command uses -f concat to select the concat demuxer and -i playlist.txt to identify its input. -safe 0 relaxes restrictions on paths in the playlist. That can be useful when you need absolute paths, but it also broadens what the playlist is allowed to reference. Only use it with a playlist and entries you trust; do not take an arbitrary text file from an unknown source and feed it to FFmpeg with relaxed path checks.
The demuxer is not a general-purpose editor that reshapes every clip to match the next one. FFmpeg’s concat demuxer documentation describes the requirement for compatible streams. Files with different stream layouts, codecs or time bases may fail at startup or at a boundary, or produce discontinuities. Similar filenames and the same container extension do not prove that two files are compatible.
If you are planning a regular channel rather than a one-off sequence, keep a record of each file’s technical properties and review additions before putting them in the playlist. The practical decisions involved in hosting and running a continuous output are also covered in the guide to running a YouTube radio stream from a VPS in India. The playlist itself remains a local input; how you operate FFmpeg over time is a separate concern.
Set real-time pacing and output options
The options before -i describe input handling. The options after the input generally describe how FFmpeg encodes and sends the output. Keep those roles distinct when troubleshooting. If the playlist finishes and stops instead of starting over, inspect the placement of -stream_loop -1. If the output races through files, inspect pacing for a local-file source. Changing the video bitrate will not correct either input problem.
In the example, -c:v libx264 selects H.264 encoding, while -c:a aac selects AAC audio. -b:v, -maxrate and -bufsize are rate-control-related settings; their example values are not a recommendation for every resolution or frame rate. -preset veryfast is an encoder-speed choice that trades compression efficiency against the processing work needed for encoding. The right choice depends on the computer’s capacity and the output profile you need, so do not treat the preset as a fix for an incompatible input or an unstable connection.
The destination uses FLV as the output format with an RTMPS-style URL. The transport URL, stream key and selected container/protocol must match the YouTube event and encoder workflow you are using. Do not copy a URL from a tutorial and assume it applies to your event. When output settings need to be adjusted, change one well-understood item at a time and check the preview and stream health rather than making several speculative changes at once.
There is a trade-off between preparing a reliable file and trying to compensate in the live command. A consistent, pre-encoded playlist makes the command easier to reason about and reduces the chance of a boundary problem. A command with many per-input filters can be appropriate for a carefully designed workflow, but it makes the example less portable and the source of a failure harder to identify. For a small business that loops a product showcase, for instance, standardising the finished clips before broadcast is usually easier to maintain than discovering format differences during an overnight stream.
Match settings to YouTube requirements
YouTube’s ingest guidance should determine the output profile, not the illustrative numbers in a sample command. Its current encoder settings include codec choices, frame-rate limits and bitrate recommendations that vary with codec, resolution and frame rate. Consult YouTube’s live encoder settings for the profile you intend to send, then configure FFmpeg accordingly. The page can change, so check it again when setting up a new channel or materially changing the output.
YouTube recommends a two-second keyframe interval and says not to exceed four seconds in its encoder guidance. The -g setting is expressed in frames, so the frame rate matters when translating an interval into a GOP size. At 30 frames per second, 60 frames represents two seconds; at another frame rate, use the corresponding frame count. Do not infer that the sample’s -g 60 is correct for every stream.
Bitrate recommendations also depend on the profile. A 720p stream and a 1080p stream do not necessarily call for the same video bitrate, and codec choice affects the relevant recommendation. Choose a realistic profile for the material and available connection, and avoid assuming that higher bitrate automatically means better results. It can increase the load on both encoding and upload without resolving dropped frames, poor source quality or an unstable network.
Audio needs attention as well as video. Confirm that the selected audio codec and bitrate match the source and YouTube’s current settings guidance. A video can look correct in the preview while its audio is missing, too quiet or distorted. Test representative content, especially if your playlist contains clips from different recording sessions. For a continuous music channel, listening to transitions is as important as checking the opening seconds.
A YouTube stream is a distinct event with its own ingest details and controls. The repeated FFmpeg input does not itself create or manage that event. If you are weighing a local command against a managed approach to continuous playback, the comparison of YouTube 24/7 software and cloud streaming services can help frame the operational trade-offs without changing the need to select suitable YouTube output settings.
Normalise incompatible files when needed
When the concat demuxer reports errors at a file boundary, or the output behaves differently after a particular clip, first inspect the inputs. Compare video and audio stream presence, codecs, dimensions, frame rates and timing properties. Files may look alike in a media player yet differ in the stream layout or time base that the demuxer expects to match. The concat demuxer is not a promise that heterogeneous files will be converted into a common format automatically.
A practical response is to make a consistent set of output files before putting them in the playlist. Choose a common resolution, frame rate, video codec, audio codec and audio layout appropriate to the planned YouTube output. Then review the resulting files and test transitions. This is a preparation step, not a guarantee that every source can be normalised without issue; damaged media, unusual formats and different aspect ratios still require judgement.
Preserve the source files while testing. Normalising may change picture dimensions, add borders or crop image content, alter audio levels, or remove tracks that you intended to keep. Inspect a representative output visually and listen to it before processing the full collection. Where a clip is portrait and the channel is landscape, decide deliberately whether to letterbox, crop or redesign it rather than allowing an arbitrary conversion to decide for you.
If your playlist changes frequently, establish an intake rule: new clips are checked, converted to the established profile if needed, reviewed, and only then added to the broadcast playlist. That is more repeatable than trying to diagnose each new file while a live event is running. For a channel built around a fixed loop, a one-time preparation workflow may be simpler than repeatedly adding filters to the live command.
Protect your stream key and test output
Treat the stream key like a password. YouTube’s encoder setup instructions explain how to use the stream URL and key for an encoder; obtain the values from the appropriate stream in Live Control Room rather than copying a key from a guide. See YouTube’s instructions for setting up a live stream encoder. Never publish a command containing a real key in a forum post, screenshot, shared document or public script repository.
The sample uses placeholders in the output URL for a reason. Replace them locally and avoid leaving the completed command in shell history or logs that others can read. If a key is exposed, use YouTube’s controls to reset it and update the encoder configuration. A key leak is not fixed by changing the playlist or the FFmpeg input loop.
Test with the actual files and intended output profile before relying on the broadcast. Start the stream, inspect the Live Control Room preview, confirm that both picture and audio are present, and look at stream health. Watch through a file boundary and, if practical, through the transition from the end of the playlist back to its beginning. YouTube recommends testing representative audio and motion and monitoring health during the event; a static title card is not a sufficient test of a playlist with varied clips.
If FFmpeg exits, distinguish the failure from the loop setting. The loop only governs repeated input; it cannot prevent a process crash, network interruption or change in YouTube event state. Likewise, repeating local input indefinitely does not mean a single YouTube archive has unlimited duration. YouTube’s encoder guidance says streams shorter than 12 hours are automatically archived, so check the current official page and plan around the platform’s event and archive behaviour rather than treating an input loop as a promise of an endless live session.
For a one-computer workflow, you must also account for power, restarts, network conditions and the person who responds to an alert. If your main difficulty is keeping a local machine running overnight, StreamNeo removes that particular burden by turning an uploaded file into a YouTube live stream that can continue with your computer switched off; it does not remove the need to check rights, configure the channel or monitor the result.
Before relying on any arrangement for a recurring channel, decide who will notice and investigate an interruption, how the event will be restarted, and how you will confirm the audience sees the intended programme. Repeated input is one part of that operating plan, not a substitute for one.
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
Why does FFmpeg stop after one pass?
Check that -stream_loop -1 appears before the -i for the playlist you want to repeat. It is an input option, so placing it after that input does not apply it to the input already opened. Also check whether FFmpeg exits for a separate error rather than reaching the end normally.
Does -re make the playlist loop?
No. -re paces reading of a local file at its native rate; -stream_loop -1 is the option that repeats the input. The two can appear together for local-file live output, but FFmpeg cautions against casually using -re with real live or capture inputs.
Can I concatenate files with different codecs or resolutions?
Do not assume the concat demuxer will adapt files with different stream layouts, codecs or time bases. Check the files and, where needed, normalise them to a consistent profile before concatenation. Review the converted output, because changes to aspect ratio, audio or tracks may need a deliberate choice.
Does an infinite input loop mean YouTube stays live forever?
No. The FFmpeg process, network connection and YouTube event can each stop independently of the input loop. YouTube also documents archive behaviour for streams under 12 hours, so check the current official guidance and plan for event duration, monitoring and restart procedures.