Skip to content
streamneo.
Setup Guides14 min read

How to Loop a Video Folder into a YouTube Live Stream with FFmpeg

Build an ordered video playlist, loop it with FFmpeg, and test YouTube’s encoder preview before going live.

sn.
StreamNeoPublished 5 October 2026
Worth sharing?

A folder of videos will not play in a deliberate order just because FFmpeg can read its files. To stream it repeatedly to YouTube Live, create an explicit playlist, check that its media can be joined reliably, then send the encoded feed to the stream URL and key shown in YouTube Live Control Room.

The loop option repeats the input; it does not guarantee an uninterrupted broadcast. Test the playlist and YouTube preview before going public, and plan how you will notice and respond if the encoder, network, or event stops.

Decide the playback order before touching FFmpeg

Start with the sequence a viewer should see, rather than the order your computer happens to return files from a directory. A devotional channel might want an opening prayer, a group of bhajans, a short interval card, and then the first track again. A study channel might want a set of focus sessions in a fixed order, while a local news loop may need the latest bulletin first. Write that sequence down and keep it as the source of truth.

Directory listings can be misleading. Files named track1, track10, and track2 may be sorted differently by a file manager, shell, or script. Dates embedded in filenames may reflect when you exported a file rather than when it belongs in the programme. If order matters, use meaningful names such as 01-opening.mp4, 02-bhajan-a.mp4, and 03-bhajan-b.mp4, then inspect the playlist itself before you start an encoder.

Decide whether the sequence should restart as a whole or whether individual items need to repeat. The concat-demuxer approach below treats the playlist as one ordered input, then loops that input. It is not a scheduling system: it will not insert a new file at a particular time or skip an item because of a calendar event. For a one-off change between files during a live session, a different workflow may suit you; see the guide to switching videos without a black frame.

Keep a working copy of the playlist and media together, preferably in a folder whose path is simple and stable. Avoid moving or renaming source files after preparing the list. Absolute paths make it clearer which files FFmpeg will open, especially if the command is launched by a scheduled task or from a different working directory. Paths containing apostrophes or unusual characters need correct escaping in concat-demuxer syntax. Do not guess at quoting: check the installed FFmpeg documentation and test those paths locally.

Build an explicit playlist

The concat demuxer reads a text file containing one file entry per line. The order of those entries is the playback order. A minimal-looking example, using uncomplicated absolute paths, is:

file '/home/channel/video/01-opening.mp4'
file '/home/channel/video/02-bhajan-a.mp4'
file '/home/channel/video/03-bhajan-b.mp4'

Save the list as something recognisable, such as playlist.ffconcat, and read it back line by line. Check that no file is missing, duplicated accidentally, or out of sequence. Use a short test playlist first if the full folder is large. A plain text list is useful precisely because you can review what will play without relying on a hidden directory sort.

The example paths are not universal quoting instructions. The concat format has its own syntax, and shell quoting is a separate layer from the contents of the playlist file. A path that contains a quote, backslash, or unusual character can be parsed differently from what you intended. Consult the FFmpeg documentation for the concat demuxer and input options, then test the actual list using your installed build before sending it to YouTube.

There are two common ways to prepare a folder. With an explicit concat list, you retain a set of separate assets and can change their order by editing the text file. With a pre-rendered long video, you first combine and normalise the assets into one file, then loop that single file. The playlist is easier to revise without rebuilding a long export, but transitions may expose differences between source files. A single normalised file adds a preparation step and uses disk space, while giving you one asset to test. Neither method removes the need to check the playback and output.

Approach Useful when Trade-off
Concat-demuxer playlist You have a defined order and may change the sequence later Paths and quoting need care; stream-copy joins can be sensitive to differences between files
Pre-rendered, normalised video Source files vary and you prefer to test one combined asset Requires an export step and extra storage; changing one item may mean creating the combined file again

If you run FFmpeg from a shell script, avoid building the sequence from an unchecked wildcard if the viewing order matters. A generated list can be convenient, but inspect its output before use. Keep a copy of the exact playlist used for each event so that, if a transition fails, you can reproduce the same sequence while diagnosing it.

Check every file for compatibility

A playlist that is syntactically correct can still produce a poor or failing stream. Files may differ in video codec, dimensions, frame rate, time base, audio codec, channel layout, or whether they contain audio at all. The concat demuxer does not make those differences disappear. FFmpeg's documentation and the media files themselves should guide your choice of stream copy or re-encoding.

Stream copy passes encoded streams through without decoding and encoding them again. It can save processing work when the files have compatible stream properties and already meet your intended output settings. But matching filenames or extensions do not prove that streams match, and a sequence can still fail or behave oddly at a boundary. Test transitions, not only the first seconds of the first file.

Re-encoding or pre-normalising can make the output more consistent: for example, you can prepare assets with a common frame size, frame rate, video encoding and audio layout. This costs processor capacity, and what is workable depends on source resolution, frame rate, filters, codec and encoder preset. No single preset is suitable for every computer or file set. Test a representative portion of the actual playlist on the machine that will encode the stream.

Inspect each file’s streams and duration with a media inspection tool, and note any file with no audio track, a different aspect ratio, or a different frame rate. Then play the files in sequence and listen for changes in loudness or missing sound. If the playlist contains silent video as well as video with audio, decide deliberately how the output audio should behave. Optional audio mapping and synthesised silence are possible engineering choices, but the right solution depends on the assets and the command; do not assume a universal mapping will fit them all.

YouTube’s supported ingest recommendations are not a promise that every file or FFmpeg build will work. Consult its current encoder settings guidance for the selected stream’s resolution, frame rate, bitrate, audio and keyframe recommendations. Treat those settings as something to verify at setup time, not values to copy blindly from an old tutorial. The final output must also match the options supported by your installed FFmpeg build.

For a useful test, include at least one transition between each type of asset you expect in the final programme. Watch the picture for black frames, unexpected aspect ratios, frozen frames or abrupt changes in motion. Listen with headphones as well as checking a meter: a moving audio meter does not tell you whether the right track is audible or whether it is painfully louder than the previous item.

Configure FFmpeg to repeat the playlist

FFmpeg’s -stream_loop -1 input option requests that the input be looped indefinitely; -stream_loop 0 means not to loop. Because it is an input option, place it with the input it applies to. The FFmpeg command-line documentation describes the option and the command structure. Check the documentation for your installed version before relying on a copied command.

The following is a shape to adapt and test, not a universal, validated command:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.ffconcat \\
  -c:v libx264 -preset veryfast -pix_fmt yuv420p \\
  -c:a aac -b:a 128k \\
  -f flv 'rtmps://URL_FROM_YOUTUBE/STREAM_KEY'

Here -re paces file input in real time, the concat demuxer reads the ordered list, and the loop option repeats that input. The video and audio options illustrate a common encoding shape, and FLV is the output container used in this example. They are not a guarantee that the command will work for your FFmpeg build, every asset set, or the ingest endpoint YouTube assigned. In particular, do not treat the sample audio bitrate, pixel format or preset as official universal recommendations. Use YouTube’s current guidance and test the actual output.

The sample ends with a placeholder only. Do not replace it with a real key in an article, shared script, screenshot, public support post or source-control repository. Some shells retain commands in history, and command-line arguments may be visible to other users of a computer. Use a private working environment and whatever credential-handling approach is appropriate to your setup. If the key is exposed, reset it in YouTube Studio and update the encoder configuration.

Before starting, check that your FFmpeg build includes the required demuxer, encoders and output protocol. The available protocols can be inspected with the build’s supported FFmpeg options; consult its documentation rather than assuming that a binary downloaded for another purpose includes RTMPS support. If you see an “unknown encoder” or protocol error, the command may be syntactically plausible but the installed build does not support the requested output.

A successful loop of the local input only means FFmpeg can continue reading the playlist. It says nothing about network reliability, process crashes, YouTube event behaviour or whether the channel remains eligible to stream. If keeping your own computer on overnight is the weak point, compare the trade-offs between a low-cost VPS and other FFmpeg setups against the work you are willing to do to maintain the machine and connection.

Get the event URL and protect the key

Open YouTube Studio and use Live Control Room to create or schedule an encoder stream. Copy the stream URL and stream key shown for the event you intend to use. Check that the selected event, URL and key all belong together; reused settings can retain an earlier key, so do not assume a previous encoder configuration is still pointing at the right event. YouTube explains the encoder workflow and stream setup.

YouTube describes stream keys as the stream’s “password and address”. Treat them like credentials, not ordinary configuration text. Anyone who obtains a key may be able to send a feed to the associated event. Keep it out of public examples and screenshots, and do not paste it into an issue report. If you think it has been shared, reset it in Studio and replace the saved value in your encoder.

Check channel readiness before the planned broadcast. YouTube says a channel must be verified and must not have had a live-streaming restriction in the preceding 90 days; it also says first-time activation of live streaming can take up to 24 hours. Its current live streaming eligibility information is the place to recheck requirements, because account status and interface details can change. Do this well before the time viewers expect the stream.

For a scheduled stream, make sure you have selected the intended event in Live Control Room, rather than an older test or a similarly named event. For a simple first run, a private or unlisted test can help you confirm that the feed arrives without making it public. The visibility choice is not a substitute for checking the stream itself: inspect the picture, sound and playlist transition in YouTube’s preview.

Send the feed and check the preview

Start FFmpeg only after the playlist has been reviewed and the correct event’s URL and key are ready. Watch the process output for connection or encoding errors, but do not use a line saying that frames are being processed as proof that viewers can see and hear the intended programme. Confirm that the event receives a feed and that YouTube’s preview shows the right video and audio.

Check the opening and at least one transition. Confirm that the image has the intended aspect ratio, that the audio is audible and that the next file begins in the expected order. A feed can connect while the content is wrong: a stale playlist, an unexpected audio track or a stretched picture may all be visible in preview before the public event starts. For scheduled encoder streams, YouTube’s workflow is to wait for the preview and then choose Go live in Live Control Room.

If no preview appears, first verify that you copied the URL and key for this event, that the encoder is pointed at the selected ingest protocol, and that the network can reach the destination. Check whether your FFmpeg build supports that protocol. These checks narrow the problem without assuming one cause. If the feed arrives but stutters or fails at a transition, test the relevant files and normalise mismatched media rather than repeatedly restarting the same playlist without changing anything.

If the preview is black, silent or at an unexpected frame rate, inspect the input and output mapping and the media properties again. A command can run while sending the wrong stream or no audio. Make a short controlled test after each change so you can tell which adjustment helped. For more background on keeping an encoder on a local connection, the JioFiber setup guide covers the connection side; it does not replace checking the incoming preview for this playlist.

Once the preview is correct, use the event’s controls to begin the public stream. Keep Live Control Room open long enough to confirm that the event is live. To stop, follow the controls for that event and stop the encoder as intended; do not assume that closing the terminal or browser has the same effect as ending the broadcast cleanly.

Monitor the stream after launch

A loop can repeat for a long time without attention only if the whole chain continues to work. The playlist may repeat locally while the encoder process, power, computer, network connection or YouTube event has a problem. Decide who will check the broadcast and what they will do if the picture freezes, audio disappears or the event ends. Monitoring is part of the operating plan, not a property provided by -stream_loop -1.

Check both the encoder’s status and the viewer-facing stream. Encoder logs can show a process exit, connection error or repeated warnings; the public stream reveals whether sound and picture actually reach viewers. If you are not in the same place as the encoding computer, arrange a way to inspect the stream and reach the person responsible. A phone check can help, but keep in mind that mobile data or muted playback can conceal a problem.

Plan for a restart carefully. If FFmpeg stops, first identify whether the playlist, media, protocol, network or YouTube event caused it. Restarting blindly can create a second feed or send output to the wrong event. After a restart, verify the preview and event status again. If the key was exposed, replace it before restarting. Do not promise viewers that a repeated input guarantees a continuous 24/7 service.

YouTube says live streams under 12 hours are automatically archived. That is useful for reviewing a test or recovering a section of content, but it is not a guarantee that an indefinitely repeated input can remain one event without interruption. Review YouTube’s current event guidance and decide whether your publishing plan needs scheduled sessions or a different operating approach. If you want to avoid leaving a home computer running, StreamNeo addresses that specific need by taking an uploaded video and running it as a YouTube live stream while your computer is off; you still need to check the channel, content and event workflow.

Keep a record of the playlist version, FFmpeg build, output settings and event used for each test. That makes a later failure easier to compare with a working setup. Change one thing at a time when diagnosing: alter the media, encoding options or connection plan separately, then observe the preview. A note such as “audio absent after item four” is more useful than “stream broken”, particularly if someone else has to take over.

If a stable unattended operation matters, include human response and recovery in your plan. An encoder can be configured to loop, but it cannot decide whether a YouTube event should be public, whether the content is still current, or how to handle a platform notice. Read the relevant official guidance periodically and check your live stream during the hours when viewers rely on it.

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

Does -stream_loop -1 loop every file in a folder?

No. FFmpeg does not turn a folder into a playlist automatically. Make an explicit concat-demuxer list in the order you want, then apply the loop option to that playlist input.

Can I use -c copy to avoid re-encoding?

Only consider stream copy when the files’ stream properties are compatible with one another and with the output you need. Even then, test the joins: differences in codecs, timestamps, dimensions or audio layouts can cause problems at boundaries. If the files differ, normalise or re-encode them and test the result.

Why does YouTube show no preview when FFmpeg is running?

A running process does not prove that the feed has reached the correct event. Confirm the event’s URL and key, protocol support in your FFmpeg build, outbound connection and the selected ingest configuration. If the feed arrives but looks or sounds wrong, inspect the source streams and output mapping.

Does an infinite input loop mean my stream will stay live indefinitely?

No. The option repeats FFmpeg’s input; it does not prevent a process failure, network outage or YouTube event ending. Monitor the event and plan for recovery, and check YouTube’s current live-stream guidance rather than treating the loop as an uptime guarantee.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Setup Guides guides ↗ · All topics ↗