Skip to content
streamneo.
Troubleshooting12 min read

How to Fix FFmpeg Playlist Order in a YouTube Loop Stream

Trace FFmpeg’s concat script, sorting rules and file paths to fix playlist order before changing YouTube stream settings.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

If your YouTube loop plays files in the wrong order, start with FFmpeg’s concat script, not YouTube. The concat demuxer reads its listed file entries sequentially, so the order in the script FFmpeg actually opens is the first thing to verify.

YouTube receives the encoded output after FFmpeg has read the files. Its ingest settings can affect whether the broadcast connects and stays healthy, but they do not rearrange the local playlist. A skipped-looking item or a pause at a transition may instead be a path error, duplicate entry, duration problem or encoder stall.

Separate playlist order from a transition problem

There are two different faults that often look alike on a live channel. In the first, the files are read in an unexpected sequence. In the second, the sequence is correct but the stream hesitates, shows a frozen frame or takes time to move from one file to the next.

Suppose your intended order is opening.mp4, main.mp4, then closing.mp4. If the concat script lists main.mp4 first, FFmpeg will begin with main.mp4 even when the YouTube broadcast page displays the correct title and thumbnail. That is an ordering fault.

If the script has the right three entries but the picture freezes between opening.mp4 and main.mp4, inspect stream compatibility, timestamps, duration metadata and the encoder before changing the list. The next file may be correct but unable to join the outgoing stream cleanly.

A useful first test is to watch the local FFmpeg output or a short recording and write down the first few files that appear. Compare that sequence with the script line by line. Do not infer the local order from the YouTube watch page, because YouTube only sees the finished stream.

For a broader setup context, the guide to setting up FFmpeg with a YouTube stream key covers the delivery command. This article focuses on the playlist that feeds it.

Find the concat script FFmpeg actually opens

The most important question is not “what order did I choose in my folder?” It is “which file-list did this FFmpeg process open?” A playlist displayed by a media manager, shell script or web panel may not be the same file passed to the running command.

Look at the command that starts the stream and identify the input associated with the concat demuxer. Depending on the command, it may appear as a path after an input-format option, or as a file supplied by a wrapper script. Follow that path to the exact text file. If the stream is started by a service, scheduled task or control panel, inspect the generated command rather than only the command you remember entering.

A minimal concat script has one directive per line. For example:

ffconcat version 1.0
file 'opening.mp4'
file 'main.mp4'
file 'closing.mp4'

This shows the intended structure, not a guarantee that these files can be joined by stream copy. The first line matters when FFmpeg is relying on automatic format recognition. It must be exactly ffconcat version 1.0 at the start of the file. A byte-order mark or other characters before it can prevent recognition.

If the script uses relative paths, resolve them from the process’s working directory, not necessarily from the folder where you keep the playlist. A command started manually in /home/channel may resolve file 'main.mp4' differently from a service started in another directory. Use clear paths where practical, and confirm the running process has permission to read every entry.

Do not edit a similarly named backup and assume the live process will use it. Check the filename, directory and startup command together. If you change the script while FFmpeg is already running, restart or reload the process according to the way it was launched, then confirm that the new process has opened the intended file.

Check entries, paths, duplicates and omissions

Read the concat script as a playback queue. Start at the first file line and mark the intended position of every entry. Look for four basic discrepancies:

  • A valid file appears earlier or later than intended.
  • A path points to a different file with a similar name.
  • The same file appears more than once.
  • A file expected in the playlist is missing.

File names can be misleading when numbering is involved. A list containing clip-1.mp4, clip-10.mp4 and clip-2.mp4 may be alphabetically sorted as clip-1, clip-10, clip-2. That is not FFmpeg making a poor playback decision. It is reading the order it was given.

Paths also deserve a literal check. Compare case, spaces, punctuation and extensions. On systems with case-sensitive file names, Aarti.mp4 and aarti.mp4 may not refer to the same file. A relative path containing spaces must be represented in the form expected by the concat demuxer, and quoting or escaping should match the syntax in the FFmpeg documentation.

An omitted file may be more difficult to spot than a misplaced one. Create a small checklist from the intended sequence, then tick each entry in the actual script. If the playlist is long, compare the two lists in a text editor or use the generator’s own preview, but still inspect the final generated file. The final file is the evidence that matters.

A duplicate can also be deliberate. For a devotional channel, you may intend to play an opening prayer before each group of bhajans. Record that intention clearly so a repeated line is not “fixed” by removing it. The goal is not to make every filename unique; it is to make the actual sequence match the schedule.

Inspect generated scripts and sorting rules

Many unexpected orders are introduced before FFmpeg starts. A sorting tool may scan a directory, sort names, remove duplicates, group by extension or use file modification time. FFmpeg then follows the resulting script correctly, even though the result is not the order you had in mind.

Find the code, command or application that creates the concat file. Ask what it sorts by and whether that rule is stable. Common rules include alphabetical filename order, numeric order, creation time, modification time and random order. A tool that displays files in one order may write them in another if its display and export settings differ.

Numeric names need particular care. Natural numeric sorting treats 2 as coming before 10; plain text sorting compares characters and may put 10 before 2. Padding names consistently, such as 001, 002 and 010, can make alphabetical order reflect numeric order, but only if the generator preserves that order.

Modification time is also a weak scheduling rule when files have been copied, edited or downloaded. Two files may have timestamps that do not reflect the intended programme. If the order matters, encode it in the file names or in a manually reviewed manifest rather than relying on when a file reached the folder.

Check whether the generator filters extensions. It may ignore an audio file, include a temporary file, or match both an original and a re-encoded copy. Hidden files and backup names can also enter a broad pattern. The concat script should contain only the media you intend to play.

If you regenerate the script at every restart, a correct manual edit may disappear at the next restart. Fix the sorting rule or source manifest, then generate a fresh script and inspect it. Keep a copy of the intended order beside the generator configuration so a later change can be reviewed.

This is also why changing YouTube settings cannot correct a locally generated order. The mistake is already present in the text file before the first video is encoded.

Verify concat demuxer sequence behaviour

The concat demuxer processes the files listed in its script one after another. It does not search the folder for a preferred order, and it does not ask YouTube which item should come next. The file directives are the sequence to audit.

The script also has format requirements beyond order. The documented header, when used, must be on the first line without a byte-order mark or leading characters. Each path must resolve to a readable file. A malformed directive or inaccessible path can stop processing or cause behaviour that looks like a skipped item.

Looping is a separate question. The concat demuxer’s documented loop option is disabled by default, so confirm that the intended loop setting is actually applied to the concat input. Input options need to be placed where the relevant FFmpeg input can read them. Do not assume that an option placed elsewhere in a long command affects the playlist.

Also check the FFmpeg version and the exact command used by the stream process. A command copied from a different installation may use options differently, or the running service may not be using the binary you tested in a terminal. Record the full command and inspect its input section before changing several options at once.

The demuxer expects compatible streams. The input files should have matching stream characteristics where required, including codecs and time bases. If the files differ, the sequence can be correct while the join produces errors, a brief artefact or a stall. That is a media compatibility issue, not evidence that FFmpeg reordered the entries.

Duration metadata is another separate cause of confusing transitions. FFmpeg uses each file’s duration when placing timestamps for the next file. If a file reports an inaccurate duration, the next item may start too early or too late, and the result can resemble a missing or repeated segment. A duration directive can override stored duration when you have a reliable value, but measure and test rather than adding guessed values.

When re-encoding is needed, compare the concat demuxer with the concat filter. FFmpeg’s FAQ describes the filter, demuxer and protocol as different approaches with different requirements. The demuxer can avoid re-encoding when compatible inputs allow it; the filter is suitable when you need to re-encode or normalise inputs; the protocol is intended for formats that support file-level concatenation. Changing methods alone does not prove that ordering was the original fault.

Test the sequence before streaming

Do not use a live YouTube broadcast as your first debugging session. Make a short local test from the same concat script and the same FFmpeg input section used by the stream. The purpose is to observe the boundaries: which file starts first, which follows it and whether the transition completes.

Choose distinctive test clips if possible. Put a spoken or visible label at the beginning of each file, such as “opening”, “middle” and “closing”, or use three short copies with clearly different pictures. This is more reliable than judging a devotional or ambience playlist where consecutive files may look and sound similar.

Test at least the first several entries, not only the first two. An incorrect generator rule may place the first pair correctly while moving a later item. If the list is long, test a representative beginning, middle and end, then inspect the complete script separately for duplicates and omissions.

Capture FFmpeg’s diagnostic output. Warnings about a missing file, invalid directive, stream mismatch, timestamp discontinuity or failed input provide a more useful trail than the YouTube player alone. Keep the command, script and output together with the date of the test so you know exactly what was checked.

If the local test shows the intended order but the live channel appears to jump, compare the local output with the outgoing encoder process. Check whether another process is publishing to the same channel, whether the stream restarted from a different script, and whether an old process remained running after a configuration change.

If the local test shows the wrong order, stay local. Do not adjust bitrate, keyframes or stream keys until the script and generator produce the intended sequence. If the local test shows the right order but a transition stalls, move to compatibility, duration, timestamps and encoding diagnostics.

Check YouTube when the outgoing stream is unhealthy

YouTube becomes relevant after the local sequence has been verified, or when the broadcast is disconnecting, buffering or reporting encoder health problems. Its ingest configuration governs delivery of the encoded stream, not the order in which FFmpeg reads the concat list.

YouTube’s encoder settings guidance covers protocols, supported codecs, frame rates, bitrate guidance and keyframe behaviour. It recommends a keyframe frequency of two seconds and says not to exceed four seconds. Use the current table for the codec, resolution and frame rate you have chosen rather than copying a bitrate from an unrelated setup.

For the connection details, copy the stream URL and stream key from YouTube Live Control Room as described in YouTube’s live streaming setup instructions. A wrong key or URL can prevent delivery, but correcting it will not change opening.mp4 into the second item in your concat script.

If encrypted delivery is appropriate for your setup, consult YouTube’s RTMPS documentation and follow the current connection instructions. Treat this as an ingest decision, separate from playlist order.

Watch the stream health indicators while testing representative audio and motion. A stream may be locally ordered but unhealthy because the encoder cannot keep up, upload capacity is insufficient or the input transition produces incompatible output. Diagnose the warning shown by YouTube alongside FFmpeg’s own logs, not instead of them.

Do not interpret a delayed viewer playback as proof of a reordered list. Live playback has buffering and delay. Compare identifiable markers in the outgoing test and confirm the local process before changing the playlist.

Choose the right operating arrangement after the fix

Once the script is correct, decide where the process should run. A spare computer can work if it stays powered, connected and monitored. A VPS can suit readers who want a remote machine, but it adds responsibility for installation, updates, storage, network access and process recovery. Neither choice fixes a wrongly generated concat file.

The comparison in VPS versus a spare computer for a YouTube loop is useful when the playlist is already behaving locally and the remaining question is operational. If the issue is a disconnect rather than an order error, see the separate guide to YouTube streams disconnecting on a VPS.

For a channel that should run without leaving your own computer on, StreamNeo removes the need to keep a local FFmpeg process running: upload the finished video, provide the YouTube stream key, and the cloud-run broadcast can be monitored and restarted if it drops. You still need to verify the uploaded file’s order, rights and YouTube configuration; moving the stream does not repair a bad playlist.

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 control the order of my FFmpeg playlist?

No. FFmpeg reads the concat script and sends the resulting encoded stream to YouTube. YouTube ingest settings affect delivery and stream health, not the order of local file entries.

Why does FFmpeg play clip-10 before clip-2?

Your generator may be using alphabetical text sorting, where the characters in 10 are compared before the characters in 2. Use a deliberate numeric sorting rule or consistently padded names, then inspect the generated concat script before restarting the stream.

Why does the next file appear to be skipped at a transition?

First confirm that the file is present in the script and that its path is readable. If the order is correct, investigate incompatible streams, inaccurate duration metadata, timestamps and encoder warnings, because a transition stall is different from a reordered playlist.

Should I change bitrate or keyframes to fix playlist order?

No. Check the script and any script generator first. Change YouTube delivery settings only when the outgoing stream is unhealthy, and use YouTube’s current encoder guidance for the selected codec, resolution and frame rate.

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