Skip to content
streamneo.
Setup Guides11 min read

How to Set FFmpeg to Loop a Folder of Gaming VODs on a Linux Server for YouTube

Build an explicit FFmpeg playlist, loop it on Linux, pace playback for YouTube Live and check the result in Live Control Room.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

To loop gaming VODs from a Linux server to YouTube Live, make an explicit playlist and tell FFmpeg to repeat it. FFmpeg does not discover and order a folder for you; the playlist defines what plays and in which order.

The concat demuxer is a practical choice when the videos have compatible streams and timestamps. You still need to test transitions, encode to settings suited to your chosen resolution and frame rate, and confirm the preview and stream health in YouTube Live Control Room before starting a broadcast.

Prepare the Linux server and video files

Choose a working directory and a stable location for the VODs. For example, you might keep the source files under /srv/vods/ and the playlist at /srv/vods/playlist.txt. Use the Linux account that will run FFmpeg when checking permissions; a file readable by your login may not be readable by a service account.

Install or select an FFmpeg build that includes the encoder and output protocol you intend to use. Check the available options with ffmpeg -encoders and ffmpeg -protocols, and confirm that libx264 and RTMPS are supported if you use the example below. The exact packages and build features vary between distributions, so do not assume the system's default installation has every option.

Inspect the files before you make a playlist. ffprobe can show the streams, codecs, resolution, frame rate, audio layout, time base and duration. For example:

ffprobe -v error -show_streams -show_format /srv/vods/part-01.mp4

The concat demuxer joins compatible packets from one file to the next. FFmpeg's concat demuxer documentation requires matching stream layout, codecs and time base. Different resolutions, frame rates, audio layouts or stream counts can cause errors or visible or audible problems at a transition. Compare representative files before relying on the playlist overnight.

Keep the playlist separate from the media. Do not make a script that scans every file in a directory and then writes its own output into that same directory: generated files or unrelated clips can end up in the sequence. If your YouTube channel is not enabled for live streaming yet, check the steps in YouTube channel verification before debugging the encoder.

Create an explicit concat playlist

Write the sequence you want into a plain text file. Each file line names one input, and line order is playback order. An explicit playlist avoids depending on shell glob ordering or on an automatic directory scan.

ffconcat version 1.0
file '/srv/vods/part-01.mp4'
file '/srv/vods/part-02.mp4'
file '/srv/vods/part-03.mp4'

Save it as /srv/vods/playlist.txt, then inspect it yourself: check spelling, paths and intended sequence. Paths containing unusual characters or quote marks need careful handling in the concat script format; test the playlist rather than guessing how a path will parse.

The header is optional when you pass -f concat on the command line, but including it makes the file's intended format clear. Absolute paths require -safe 0 in common setups. That setting relaxes path checks, so use it only for a playlist you control. An alternative is to keep the playlist beside the videos and use relative paths, which avoids relying on unrestricted absolute paths.

Before streaming, confirm the account that will run FFmpeg can read the playlist and every referenced file. A quick check is to run ffprobe against each input as that account. A missing or unreadable item can stop the job at startup or when playback reaches it; keeping the list short enough to audit helps make failures easier to diagnose.

Repeat the playlist deliberately

Use -stream_loop -1 as an input option before the playlist's -i option. The negative one requests indefinite input looping. A minimal test command that decodes the sequence without sending it to YouTube is useful before adding encoding and network settings:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i /srv/vods/playlist.txt -f null -

Let it pass at least one transition and return to the start. Watch the output for missing-file errors, timestamp warnings and decode failures. This is not a guarantee that a later encoded stream will be clean, but it catches basic playlist problems before you involve YouTube.

The -stream_loop option applies to the input that follows it, which is why its position matters. Keep the playlist order deliberate if one VOD should always lead into another. When the loop returns from the last entry to the first, inspect that boundary too; it is another transition, not a special seamless join.

A longer gaming sequence may include different sessions, game modes or commentary. Decide whether a fixed order is appropriate for viewers arriving at any time, and revise the playlist when you change the programming. If a missing file must not halt a long-running sequence, plan a manual check or a separate recovery approach rather than assuming the concat demuxer will skip it. For a different FFmpeg use case, the single-video 4K/60 fps loop example is a useful comparison, but the settings still need to match your own sources and output target.

Pace playback as a live source

A file can be decoded faster than its recorded duration. For a live broadcast, -re asks FFmpeg to read the input at its native rate, so the output is paced like playback instead of racing through the playlist. Put it before the input, alongside -stream_loop.

Pacing does not make every machine fast enough to encode in real time. Decoding, scaling and H.264 encoding consume CPU or other available processing resources; the load depends on the inputs, output dimensions, frame rate, encoder and preset. Run a representative test and watch system load. If processing cannot keep pace, the output may lag, drop frames or fail to maintain a stable feed.

Network capacity is a separate constraint. The outgoing stream needs sustained upload headroom above the selected video and audio bitrates, plus room for fluctuations and other traffic. YouTube Help recommends a speed test to check upload bitrate in its encoder settings guidance. Measure from the server or network path that will actually transmit the stream; a test on a different household connection is not a substitute.

Encode for YouTube Live ingest

Here is a starting template for a 30 fps H.264 video with AAC audio. It is not a universal preset: check the current YouTube table for your resolution and frame rate, and test the result on your server.

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i /srv/vods/playlist.txt \
  -c:v libx264 -preset veryfast -pix_fmt yuv420p \
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 \
  -b:v 5M -maxrate 5M -bufsize 10M \
  -c:a aac -b:a 128k -ar 44100 \
  -f flv 'rtmps://SERVER_FROM_LIVE_CONTROL_ROOM/STREAM_PATH/STREAM_KEY'

The example uses a two-second keyframe interval because 60 frames at 30 fps is two seconds. If you choose another frame rate, adjust the GOP and keyframe interval to approximately two seconds. YouTube recommends a two-second keyframe frequency and says not to exceed four seconds. Its current guidance also recommends CBR; choose the bitrate according to the current resolution and frame-rate table rather than copying a value from an unrelated setup.

For context, YouTube's published H.264 recommendations include 14 Mbps for 1080p at 30 fps and 8 Mbps for 720p at 30 fps; its table also lists minimum bitrates. These are platform recommendations, not a guarantee that a particular source, server or connection will work well. Verify current values directly in YouTube's live encoder settings before configuring a broadcast. The template's 5 Mbps is an example value, not a general recommendation for every resolution.

The audio options in the example use AAC stereo at 128 Kbps and 44.1 kHz, settings in YouTube's guidance. Check that the source actually has audio and that the selected output layout is appropriate. A VOD with no audio stream or an unusual channel layout may need separate handling rather than relying on a command copied unchanged.

The concat demuxer is most useful when the source files already match. If they differ materially, you have two broad choices:

Input approach When it fits Trade-off
Concat demuxer Files have compatible streams, codecs and time bases Less processing than decoding and re-encoding, but mismatches or inaccurate durations can produce errors, gaps or artefacts
Concat filter and re-encode Sources need to be decoded and made uniform More processing and more setup, but gives you a route to standardise mixed inputs

FFmpeg's concat filter FAQ describes the filter approach for re-encoding. Alternatively, normalise the files as a separate preparation step and then test them with the demuxer. Neither approach removes the need to inspect transitions. For another workflow perspective, the guide to looping pre-recorded video with OBS covers a different tool, not a shortcut around source compatibility.

Send the feed and inspect Live Control Room

Replace the placeholder destination with the exact RTMPS server URL and stream key shown in Live Control Room. Do not paste a key into a public script, shared terminal recording or support post. Treat it like a password: restrict access to the command or environment where you store it, and regenerate it through YouTube if it is exposed.

YouTube recommends RTMPS as an encrypted ingest option. Use the exact address supplied for your broadcast rather than constructing a URL from an example. The YouTube Live Control Room help explains how to manage the live stream setup. Confirm that the installed FFmpeg build supports RTMPS and that your network permits the connection before treating a connection error as a YouTube-side problem.

Start FFmpeg, then watch Live Control Room for the incoming preview and stream-health messages. Check that the picture is moving, the audio is present and the reported health is acceptable before pressing the control to start the broadcast. If the preview does not appear, check the destination URL, key, protocol support and outbound network access. If the preview is present but health warnings appear, use the message and local CPU and upload observations to narrow down whether the issue is encoding, input or network related.

For a channel built around gaming replays, a fixed playlist is only one programming choice. The Kannada internet radio YouTube guide is relevant if you also need to think through how a continuous channel is presented to viewers; the technical checks for ingest remain specific to the feed you are sending.

Test transitions and plan recovery

Test a representative section of the playlist, not just its first few seconds. Include clips with the most different properties, the last-to-first loop boundary, and any source with unusual audio or frame rate. Look and listen for black frames, frozen pictures, abrupt audio cuts, silence, drift or a stall. Do not promise viewers seamless transitions until your own files and command have survived that test.

The concat demuxer adjusts timestamps so that later files follow earlier ones, but unequal stream lengths can create gaps, and inaccurate duration information can cause artefacts. If errors appear at the transition, compare ffprobe output across the affected files. Normalise them to matching properties or use a decode/filter/re-encode workflow; do not assume one flag will reconcile arbitrary VODs.

Recovery is also part of a real 24/7 setup. Decide who will notice a stopped process, what logs they will check and how they will restart the encoder safely. A shell process that exits on an error does not restart itself. If you use a process supervisor or system service, test its restart behaviour and ensure it does not repeatedly reconnect with a bad key or broken playlist. A guide to restarting a YouTube bhajan stream after disconnection discusses recovery as a separate concern; whatever method you use, verify the actual behaviour rather than assuming a restart means the feed is healthy.

During a test, monitor CPU, memory, disk access and upload from the Linux server. Leave headroom rather than sizing the bitrate exactly to a speed-test result. If you need the channel to keep running while your own computer is off and do not want to maintain a Linux process, StreamNeo removes the specific burden of leaving and recovering that computer-based broadcast running; it turns an uploaded video into a YouTube stream, but the channel and files still need your checks.

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 FFmpeg automatically find every video in a folder?

No. Create an explicit concat playlist with the file paths in the order you intend. A directory scan or shell glob is not a substitute for checking the resulting sequence, especially if the folder contains unrelated or temporary files.

Can I loop VODs with different codecs or resolutions?

The concat demuxer expects compatible stream layouts, codecs and time bases, so mixed files may fail or show problems at transitions. Normalise the files first, or use a concat filter and re-encode to a consistent output, then test the joins.

Why does playback fail when it reaches the next video?

Check that the next path is correct and readable by the FFmpeg account, then compare that file's streams and time base with the preceding one. A mismatch, damaged input or duration issue may be the cause; inspect FFmpeg's output and test the affected files separately.

How do I know YouTube is receiving the stream properly?

Check for a moving preview and stream-health messages in Live Control Room before starting the broadcast. Confirm the URL, key, codec, keyframe interval, bitrate and network path if the preview or health status is not as expected.

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 ↗