To loop a video playlist from a Linux server to YouTube Live, use FFmpeg’s concat demuxer to read the files in order and -stream_loop -1 to repeat that input indefinitely. Send the output to the exact ingest URL and stream key shown in YouTube Live Control Room, then check the preview and stream health before relying on it.
This method suits a fixed sequence of compatible video files. It does not create a YouTube broadcast by itself, and the loop option is not an uptime guarantee: the server, files, network, encoder and YouTube ingest all still need to work.
How the Linux playlist reaches YouTube Live
The concat demuxer presents a list of media files to FFmpeg as one sequential input. FFmpeg reads that input, encodes or passes through the audio and video, and sends the resulting feed to YouTube’s ingest endpoint. With the input loop set to -1, FFmpeg repeats the list rather than stopping after the final item.
There are two separate parts to set up. In YouTube Studio, create or schedule an encoder stream and obtain its ingest URL and stream key. On Linux, prepare the file list and run FFmpeg with options that fit the media and the stream configuration. The stream key identifies the feed YouTube accepts; it is not a playlist setting.
This approach is useful for a devotional channel repeating a sequence of recordings, a study channel rotating a set of focus videos, or an ambience station with a fixed order. It is less convenient if clips need transitions, overlays, frequent changes, or substantially different encoding characteristics. For a workflow that switches among prerecorded videos through OBS, see how to make OBS switch between prerecorded videos on YouTube Live.
The method below is a starting point, not a tested deployment recipe. The sample command has not been run against your media, server or YouTube stream. Validate those parts with a preview stream before scheduling a broadcast that others depend on.
Prepare a concat-demuxer file list
Create a plain text file that lists the videos in the order you want them played. For example, save this as /srv/videos/playlist.txt:
file '/srv/videos/intro.mp4'
file '/srv/videos/main-01.mp4'
file '/srv/videos/main-02.mp4'
Each file entry points to a path the account running FFmpeg can read. Absolute paths are straightforward for a server setup, but they require the -safe 0 option in the command shown later. Use that option only with a playlist file you control: the list itself tells FFmpeg what paths to open.
The concat demuxer works most predictably when files have compatible streams. In practice, check that the clips have compatible codecs, time bases and stream characteristics before treating them as one continuous input. A difference in video size, frame rate, audio layout or codec can cause errors or an uneven hand-off. Incorrect duration metadata can also contribute to timestamp gaps or visible and audible glitches at a file boundary.
Inspect the files before the scheduled broadcast. ffprobe can show the streams and format information for an individual file, or you can use another media-inspection workflow you trust. Compare the files rather than checking only the first one. If the list contains material from different sources, make a short test that crosses from one clip to the next and listen as well as watch.
Keep the list simple while you are diagnosing it. First try two representative clips, then add the rest after the transition behaves as expected. If you edit the list while the stream is running, do not assume FFmpeg will reload it in the way you intend; plan a controlled restart and check the preview again.
The FFmpeg concat demuxer documentation describes the list format and the compatibility considerations. For a playlist that needs transitions, graphic overlays or different treatment for each clip, a pre-rendered combined video or a filter-based production workflow may be more suitable than direct concatenation.
Set the playlist input to repeat indefinitely
FFmpeg’s -stream_loop is an input option. A value of -1 means infinite looping, and the option must appear before the input it applies to. With the concat demuxer, that means placing it before -i /srv/videos/playlist.txt. The -re option tells FFmpeg to read the input at its native real-time rate rather than process it as quickly as possible.
Here is an illustrative command, with a placeholder for the output URL:
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i /srv/videos/playlist.txt \\
-c:v libx264 -preset veryfast -b:v 10M -maxrate 10M -bufsize 20M \\
-pix_fmt yuv420p -r 30 -g 60 \\
-c:a aac -b:a 128k -ar 44100 \\
-f flv 'YOUTUBE_INGEST_URL_WITH_STREAM_KEY'
Do not paste the placeholder literally. Replace it with the current output address and credential format for your stream. The example selects H.264 video, AAC audio, a 30 fps output and a 60-frame GOP, which corresponds to a two-second keyframe interval at that frame rate. It does not resize or normalise the source clips. If a source differs from those assumptions, adapt the encoding and test the result rather than expecting the options to make every input suitable.
The bitrate values in the sample are illustrative, not a measurement of your server’s connection or a universal recommendation. YouTube’s current encoder guidance gives different targets by resolution and frame rate; choose a setting for the output you actually intend to send. If you use stream copy instead of re-encoding, CPU demand may be lower, but the input streams and output requirements still need to line up. A command that works for one compatible list can fail on another.
The -stream_loop -1 option repeats the entire concat input. It does not fix unreadable files, missing audio, mismatched streams or a broken network connection. FFmpeg’s command-line documentation explains the input loop option; check the version and build installed on your server as part of testing.
Configure output for YouTube Live
The output side of the command needs to match the encoder workflow YouTube presents for your stream. The sample uses the FLV muxer, H.264 video and AAC audio. Those choices are a starting point for an RTMP or RTMPS encoder feed, not a guarantee that every installed FFmpeg build or every source file is configured correctly.
For re-encoding, set the output frame rate, pixel format, video bitrate and keyframe interval deliberately. The -pix_fmt yuv420p option is commonly used for broad playback compatibility. -r 30 requests 30 frames per second at output, while -g 60 sets a 60-frame GOP for a two-second interval at 30 fps. Confirm actual output behaviour in the preview; source frame rates, variable frame rate media and other filters can affect what reaches the encoder.
Audio deserves its own check. The example uses AAC at 128 kbps and 44.1 kHz, but the right setup depends on the material and the current YouTube guidance. Listen for silence, clipping, unexpected channel changes and gaps at every file boundary. A video preview can look correct while audio is absent or badly levelled.
If you need to resize or standardise heterogeneous source material, add and test the relevant FFmpeg filters rather than assuming the command does it automatically. Transcoding takes CPU, and a busy or undersized server can fall behind real time. If the playlist consists of compatible streams already meeting the intended output settings, stream copying may be worth evaluating; check transitions and preview output before adopting it for a long run.
For a different operating model, a scheduled livestream for an always-on radio station may help you think through the YouTube event and channel side separately from the Linux encoder. The scheduled event does not replace the process that sends the feed.
Use the stream URL and protect the stream key
In YouTube Studio, create or schedule an encoder stream and open its settings in Live Control Room. Copy the stream URL and stream key shown for that stream. YouTube’s encoder setup instructions explain the server and key fields; its stream settings guidance covers the stream configuration.
Some encoder interfaces keep the URL and key in separate fields. A command-line FFmpeg output often represents them together in the output URL. Follow the current values and format shown for the actual stream, rather than assuming that a generic address or an old example is still correct. Use RTMPS when YouTube offers it for the stream and your FFmpeg build supports it. YouTube’s protocol guidance describes its RTMP and RTMPS options.
Treat the stream key as a password. Do not place it in a public script, shared terminal screenshot, public issue report or log that other users can read. A key embedded directly in a shell command may be saved in shell history, depending on how you run it. Restrict access to any file or process configuration holding it, and avoid printing it while troubleshooting. If you believe it has been exposed, reset it in Studio and update the encoder with the new value.
Check that the stream URL and key belong to the same stream configuration. If YouTube does not receive the feed, an old key, a copied URL from another event, an unsupported protocol or a typo can look like an FFmpeg failure. Confirm the displayed details in Live Control Room before changing encoding options at random.
Apply YouTube encoder guidance and test the preview
YouTube publishes encoder settings for supported ingest workflows. Its current encoder settings page lists H.264, CBR, AAC or MP3 audio, frame rates up to 60 fps, and a recommended keyframe frequency of two seconds, not exceeding four seconds. Check the page again when configuring a stream because the guidance and interface can change.
For H.264 at 1080p and 30 fps, YouTube lists 5 Mbps as a minimum and 14 Mbps as recommended. For 720p at 30 fps, it lists 3 Mbps minimum and 8 Mbps recommended. These are YouTube’s published encoder figures, not a measurement of available upload capacity from your particular server. You need stable headroom on the sending connection and must select a resolution and rate your material and connection can sustain.
Run a preview test with representative material before depending on the channel. Start FFmpeg, then wait for the incoming feed to appear in Live Control Room. Check the preview and stream health, look at the output resolution and frame rate, and listen to the audio. Let the test cross file boundaries and include a period long enough to reveal repeat or timestamp problems. A single frame visible in the preview is not enough to establish that the whole playlist behaves correctly.
For a scheduled stream, follow the current Live Control Room prompt to go live when ready. YouTube’s streaming tips recommend preparing encoders in advance and starting ahead of a scheduled event; use its current timing guidance for your event rather than leaving the first test until the start time. At the end, use the Studio controls to end the stream and stop FFmpeg cleanly. Check the current stream settings for auto-start or auto-stop behaviour instead of assuming it is enabled.
A preview verifies a specific combination of files, command, key, server and network at that time. It cannot rule out later faults such as a server restart, connection loss or a damaged file. For ongoing use, decide who will notice a failed process or a poor preview, and what they will do to restore the broadcast. If you are investigating a feed that already drops, this guide to common causes of a YouTube Live stream disconnecting is a useful troubleshooting companion.
Choose direct looping or a prepared programme
The concat-demuxer method is a good fit when you have an ordered list of compatible files and want FFmpeg to repeat it without manually duplicating the list. It keeps the source playlist visible and editable, but it also makes file compatibility and list syntax part of the broadcast setup. It does not provide transitions or a polished hand-off between clips by itself.
A pre-rendered combined file can be easier when the clips have different formats, need fades, or require titles and overlays. Preparing that file adds a separate render and storage step, and changing the running order means producing another version. A filter-based FFmpeg workflow offers more control but needs more configuration and testing. The choice depends on the media and how often you need to change the programme, not on a universal best method.
| Approach | Useful when | Main trade-off |
|---|---|---|
Concat demuxer with -stream_loop -1 |
The playlist order is fixed and files have compatible streams | Simple list, but compatibility and boundary behaviour need checking |
| Pre-rendered combined video | Clips need transitions, overlays or normalised output | More preparation and a new render when the programme changes |
| Filtered or managed playlist workflow | You need per-clip processing or regular changes | More moving parts to configure and test |
Also consider the server’s available CPU if you transcode, the upload connection’s consistency, how you will protect the stream key, and how you will notice a stopped process. If you want to avoid keeping a Linux machine running and watching the encoder process yourself, StreamNeo removes that specific operational burden: you upload a video, provide your YouTube stream key, and the broadcast runs with your computer switched off, with monitoring and automatic restart if it drops. It is YouTube-only, so it is not a fit if you need to send the same feed to other platforms.
The FFmpeg audio bitrate guide for a sleep-sounds YouTube stream is relevant if the playlist is audio-led and you are choosing audio output settings. Whichever approach you choose, test the full path from the media to the YouTube preview before treating it as ready for an audience.
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 YouTube’s playlist Loop control create a live broadcast?
No. A YouTube playlist’s Loop control concerns playback of that playlist; it does not send a live encoder feed or create a broadcast. For this Linux method, FFmpeg reads the files and sends the feed to the URL and key in Live Control Room.
What does -stream_loop -1 repeat?
It repeats the input that follows the option, which in this example is the concat-demuxer file list. Put the option before that input. It does not repair incompatible media or restart a failed FFmpeg process.
Can I stream-copy instead of using libx264?
Possibly, if the files’ streams are compatible with one another and with the output requirements. Stream copying can reduce encoding work, but mismatched inputs or output settings may cause failures or poor transitions. Test the actual playlist in Live Control Room before relying on it.
What should I do if the preview does not appear?
Check the stream URL and key in Studio, the selected protocol, FFmpeg’s error output, and whether the installed build supports the protocol you selected. Then check file readability and the server’s network connection. Change one thing at a time and confirm the result in the preview and stream health panel.