Skip to content
streamneo.
Tools12 min read

How to Loop a Video Playlist for YouTube Live Using FFmpeg

Build and test an FFmpeg playlist loop for YouTube Live, with compatibility checks, real-time pacing, encoding guidance and troubleshooting.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

FFmpeg can loop a playlist into YouTube Live by reading a concat playlist repeatedly, pacing file input in real time, encoding the result and sending it to YouTube’s ingest endpoint. The critical limit is that concat demuxing expects compatible input streams; it will not make a mixed folder of arbitrary files consistent.

The command below is a starting pattern, not a universal recipe. First compare the files’ stream layouts, then select output settings for your resolution and frame rate, test privately or unlisted, and watch both FFmpeg’s output and YouTube’s stream health.

How FFmpeg turns files into a live stream

A video file normally plays as quickly as a computer can read and decode it. A live encoder must instead deliver audio and video in time with a clock, so that a viewer receives roughly one second of programme over each second of wall-clock time. FFmpeg can read a file at its native rate, encode the streams and mux the result into a format suitable for YouTube ingest.

For several files, the concat demuxer presents compatible inputs as one longer input to FFmpeg. An input option, -stream_loop -1, tells FFmpeg to repeat that input indefinitely. With -re before the input, file reading is paced at the input’s natural rate rather than being sent as fast as possible. The output can continue until you stop the process or an error, machine, or connection interrupts it.

This is a useful arrangement for a fixed sequence: for example, a local news loop with an intro, a set of reports and a closing slate. It is different from a live playlist system that changes items while broadcasting. You generally prepare the sequence in advance, validate the files, start FFmpeg and leave the process running.

The concat demuxer joins packets; it does not decode each item, resize it, change its frame rate or convert its audio. FFmpeg’s concat demuxer documentation and FAQ describe the compatibility requirement and the alternative of concatenating through filters when conversion is needed. That distinction determines whether this simple pattern is suitable.

If you are comparing a script you operate with an unattended playlist workflow, this guide to using a YouTube 24/7 streaming service with a playlist covers the operational alternative. The command-line method gives you direct control, but it also leaves process supervision and recovery to your setup.

Check playlist compatibility first

Before making a playlist, inspect every file. You need to compare the video and audio streams, including whether each file has the same kinds and number of streams, codecs, time bases and other relevant properties. Differences in dimensions, frame rate, audio layout or stream presence can also create failures or visible and audible discontinuities. A file with no audio is not interchangeable with one that has an audio stream simply because both play in a desktop player.

Use ffprobe, which is distributed with FFmpeg, to inspect each item. For example:

ffprobe -v error -show_streams -show_format video-01.mp4

Run it for each file and compare the video and audio sections. You can reduce the output to selected properties with -show_entries, but the full stream report is useful when diagnosing an unfamiliar file. Do not assume that matching filenames, container extensions or displayed resolution mean the underlying streams match.

There are two practical paths. If the files already have matching streams and play cleanly, test the concat demuxer. If they differ, make normalized copies with consistent properties, or use a filter graph that decodes, converts and concatenates the inputs before encoding. The filter route takes more processing and setup, but it is the appropriate route when conversion is required. Re-encoding each source to a common format before joining can also make a repeatable playlist easier to operate.

Approach Best fit Main trade-off
Concat demuxer Inputs already have matching streams and time bases Less conversion work, but strict about input compatibility
Concat filter Inputs need conversion to common dimensions, frame rate or audio layout Flexible processing, but requires a filter graph and encoding
One prepared file A fixed sequence can be combined and checked ahead of time Simple to stream, but edits require preparing the file again

Treat this table as a choice of workflow, not a claim that one method repairs every source. FFmpeg’s documentation describes the concat filter as the route for inputs that need to be re-encoded consistently. If you want to see a related operational failure mode, the article on preventing black screens between gaming videos discusses why a clean transition matters to viewers; the compatibility check comes earlier in the process.

Create the concat playlist file

Create a plain-text file named playlist.txt in a working directory. Put one file entry on each line, in the order you want viewers to see the videos:

file 'video-01.mp4'
file 'video-02.mp4'
file 'video-03.mp4'

Use paths that make sense from the directory where you will run FFmpeg. Relative paths are often simpler to manage than absolute ones, especially if you move the folder. The concat demuxer has safety restrictions on paths; the sample command below uses -safe 0 so the list can include paths the default safety mode might reject. Only use a playlist you created or trust, and avoid putting unexpected text or untrusted paths in it.

If a filename contains an apostrophe or unusual characters, take care with concat file syntax rather than copying the basic example blindly. Test with a short list first. A typical mistake is editing the playlist but launching FFmpeg from a different working directory, so that the listed files cannot be found. Another is adding a file before checking that its streams match the rest.

Keep the list as the single source of order: insert, remove or reorder entries there, then run the inspection and test steps again. This makes the intended sequence visible and easier to review than burying file names in a long shell command.

Loop the input and pace it in real time

Here is an illustrative command for a 30 fps H.264 output, with AAC audio. It assumes the playlist is compatible and that your FFmpeg build has the named encoder and muxer:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \\
  -c:v libx264 -pix_fmt yuv420p -preset veryfast \\
  -b:v 5000k -maxrate 5000k -bufsize 10000k -g 60 \\
  -c:a aac -b:a 128k -ar 44100 \\
  -f flv "$YOUTUBE_RTMP_URL/$YOUTUBE_STREAM_KEY"

-f concat selects the concat demuxer, and -i playlist.txt supplies its list. The input options -re and -stream_loop -1 appear before that input. -re paces the read at native frame rate. Without it, a file source can be read faster than real time, which is not the behaviour wanted for a conventional live feed. -stream_loop -1 requests indefinite repetition of the input. Check the documentation that accompanies your installed FFmpeg version, since the online manual tracks the project’s newest revision.

The -g 60 example is a 60-frame GOP. It corresponds to two seconds only at 30 frames per second; at a different frame rate, calculate the frame count for the keyframe interval you intend to use. Do not copy the example’s frame rate or bitrate setting to a different output format without changing the related values.

The URL in the command is a placeholder. Put the ingest URL and stream key from your YouTube Live Control Room into protected environment variables or another secret store, rather than writing the key into a public script, terminal screenshot or shared log. YouTube treats the stream key like a password. The YouTube encoder guidance explains ingest and encoding setup.

Choose compatible output encoding settings

The input compatibility decision and output settings are separate. Even when the source files concatenate correctly, you still need to choose a codec, pixel format, resolution, frame rate, bitrate and keyframe interval for the broadcast. The example uses H.264 video, yuv420p, AAC audio and FLV output as a starting combination, not a guarantee that your build, source material or chosen output will suit every channel.

YouTube’s current encoder page lists RTMP or RTMPS ingest, H.264, H.265/HEVC and AV1 video options, AAC or MP3 audio, frame rates up to 60 fps, and CBR bitrate encoding. It recommends a two-second keyframe frequency and says not to exceed four seconds. For an H.264 stream, YouTube lists 5 Mbps minimum and 14 Mbps recommended for 1080p at 30 fps; for 720p at 30 fps it lists 3 Mbps minimum and 8 Mbps recommended. These are YouTube’s encoder settings, not a promise about viewer quality or connection performance, and values are specific to the listed format. Check the current YouTube bitrate and resolution guidance before selecting a target.

In the sample, -b:v sets the video bitrate target, while -maxrate and -bufsize constrain rate behaviour around that target. For a CBR-oriented setup, tune these values using the current YouTube table and the output format you selected. The audio bitrate is separate from video bitrate. Keep enough sustained upload capacity for the total stream rate plus normal network variation; a speed test helps, but does not prove that a connection will remain steady overnight.

If your source is 25 fps, for instance, do not leave a 30 fps-oriented keyframe calculation in place without deciding how you want to handle frame rate. Similarly, a 720p stream should not inherit a 1080p bitrate just because the example command includes it. Once chosen, keep the resolution, frame rate, bitrate and GOP aligned, then test motion and audio that resemble the actual programme.

Send output to YouTube Live

First confirm live streaming is enabled for the channel and create or select a stream in YouTube Live Control Room. YouTube says initial enablement can take time, so do not make the first check minutes before a planned broadcast. Its setup instructions for live streaming explain the account and stream setup steps; the stream details provide the ingest URL and key for the encoder.

Choose RTMPS when it is available in the Control Room and supported by the way you are sending. YouTube recommends encrypted RTMPS ingest. Keep the stream key private: anyone with access to it may be able to send a feed to the associated stream. If you believe it has been exposed, replace it in YouTube rather than merely deleting the text from a local script.

Run the FFmpeg command and watch its terminal output. The process should continue emitting progress rather than racing through the file immediately. In Live Control Room, check whether YouTube receives the feed and whether the preview, audio and stream-health indicators behave as expected. Use private or unlisted visibility for a test when suitable, and switch to the intended visibility only after checking the complete workflow.

A locally operated computer gives you control over files and command changes, but the machine, application and connection must remain available. If unattended operation is the priority, compare that with a hosted arrangement rather than assuming a script itself handles machine restarts. For readers weighing that choice, this comparison of cloud services for an always-on meditation music stream addresses the operating trade-offs without changing the FFmpeg compatibility requirements.

Test, inspect errors, and troubleshoot

Do a short end-to-end test before relying on a playlist overnight. Use a representative portion of the sequence, including a transition between files, and check video motion, audio continuity, aspect ratio, and whether the loop returns cleanly to the first item. YouTube advises testing with similar movement and audio to the real programme. A static devotional image with a continuous bhajan track, for example, may expose audio gaps differently from a folder of varied news clips.

When something fails, separate the likely cause before changing flags:

  • If FFmpeg reports that streams differ or a file cannot be opened, inspect paths and stream layouts. A demuxer flag cannot convert incompatible inputs.
  • If the picture or sound changes abruptly at a join, inspect the source files and test a normalized version or concat filter workflow.
  • If encoding falls behind, check local CPU capacity and the selected preset, resolution and frame rate. A lighter preset may reduce processing demand, with a possible quality trade-off.
  • If FFmpeg continues sending but YouTube reports ingest or stream-health problems, inspect the connection and the selected bitrate separately from decode and concat errors.
  • If the feed stops, retain a useful local log and identify whether the process exited, the source failed, the machine slept or the network dropped.

Do not add random resilience options until you know which layer failed. Source decode, encoding load, local process supervision and network delivery are different problems. YouTube’s stream-health messages and FFmpeg’s log give complementary evidence; neither alone explains every interruption. A separate guide to monitoring an FFmpeg YouTube stream on a VPS is relevant if you have chosen to operate the process on a VPS, while a local setup needs equivalent checks appropriate to that machine.

After the test, restart from a clean state and confirm the actual playlist order, stream key handling, output settings and recovery plan. Keep the command and playlist documented, but keep secrets outside shared notes. A successful short test is evidence that the configuration worked under those conditions; it does not guarantee an unattended run will remain uninterrupted.

Choosing an operating arrangement

FFmpeg is a sensible fit when you want to understand and control the pipeline, can prepare compatible files and have someone or something responsible for the computer and connection. It is also useful for a single file or a playlist whose contents rarely change. The main cost is operational attention: you own installation, command configuration, logs, machine power, updates and recovery after a failure.

A hosted workflow can remove the need to leave your own computer on, which matters if the channel should continue while you are away. StreamNeo removes that particular burden when a prepared upload needs to run as a 24/7 YouTube stream: you upload once and the broadcast can continue with your computer switched off. That does not change the need to prepare rights-cleared content, check YouTube’s current rules, and confirm that the chosen material plays as intended.

The choice is not a claim that one setup is better for every channel. If you need shell access, custom filter graphs or direct control over each encoding option, running FFmpeg may suit you. If the playlist is fixed and the main requirement is an unattended broadcast without keeping a personal machine running, a hosted workflow may be worth testing. In either case, verify the result on YouTube before depending 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 each playlist file?

It repeats the concat input as a whole, so FFmpeg reads the listed sequence and then starts that input again. Check the transition from the last item back to the first during a test; looping does not remove gaps or discontinuities in the source material.

Can the concat demuxer handle videos with different codecs or dimensions?

Do not assume that it can. The demuxer expects matching streams and related properties, and it does not resize, convert or repair arbitrary inputs. Normalize the files first or use a concat filter workflow when they need conversion.

Is the sample command guaranteed to work as written?

No. It assumes a compatible playlist, an FFmpeg build with the named encoder and muxer, a suitable frame rate and bitrate, a valid ingest URL and key, and a connection that can sustain the output. Verify each of those conditions and test the stream with your own files.

What should I check if YouTube shows a warning?

Compare YouTube’s stream-health message with FFmpeg’s output and determine whether the problem is input decoding, encoding load or delivery to ingest. Recheck the current YouTube guidance for your selected resolution and frame rate, then test again with representative video and audio.

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 Tools guides ↗ · All topics ↗