If you want FFmpeg to play videos from several folders in a planned order, create one concat-demuxer playlist containing the paths you want to use. FFmpeg then reads that list from top to bottom, rather than scanning folders and deciding the order itself.
The folder scan, sorting, shuffling and rotation logic must happen separately. You can generate the list with a script or another file-management method, then give the finished list to FFmpeg as one input. The example below explains the division of labour, but it is not a tested FFmpeg command or a complete YouTube Live configuration.
Plan the rotation before touching FFmpeg
Start by deciding what “rotate between folders” means for your channel. Several folders might represent different programmes, such as devotional songs, morning prayers, instrumental music and evening bhajans. They might also represent sources, languages or visual themes.
Write the intended order in plain language first. For example:
- one clip from
folder-a - one clip from
folder-b - two clips from
folder-a - one clip from
folder-c - repeat the pattern with the next suitable files
That is a schedule, not a feature provided by the concat demuxer. The demuxer will only follow the order you give it. If you want all files from one folder followed by all files from another, your list must be written that way. If you want to alternate folders, the list must contain alternating paths.
You also need to choose how files are selected within each folder. Alphabetical order is easy to reproduce, but filenames such as clip-10.mp4 can sort unexpectedly beside clip-2.mp4 unless the naming scheme uses consistent padding. A shuffled order can make a long channel feel less repetitive, but you need a method that records or recreates the chosen order rather than leaving it to an operating system’s directory listing.
A separate schedule is useful when the channel has clear time blocks. You could prepare a morning list, an afternoon list and an overnight list, each containing files from several folders. This makes the desired result visible before streaming and gives you a file to inspect when something plays out of sequence.
Do not treat “continuous” as the same requirement as “automatically discovers new files”. A finite list can be repeated, but that does not establish that FFmpeg will notice a newly copied video or an edited playlist while the current process is running. If you need files added during the day to appear without intervention, that is a separate automation problem which must be designed and tested for your operating system and FFmpeg version.
For a broader view of unattended prerecorded channels, see this guide to starting an always-on YouTube channel with prerecorded videos in India. It covers the operational questions that sit around the media list, rather than replacing the need to build and check that list.
Collect file paths outside the concat demuxer
The concat demuxer does not search several directories for you. It does not know that folder-a, folder-b and folder-c should be combined, and it does not infer whether the order should be alphabetical, random or calendar-based. It reads the file directives already present in the playlist.
This means the workflow has two distinct stages.
First, a collection step finds the candidate media. That step might inspect selected folders, exclude temporary files, ignore hidden files, sort names, shuffle a batch or apply a timetable. It should also reject files that do not belong in the intended programme. For example, a folder may contain a thumbnail, a subtitle file or an unfinished copy alongside the videos.
Second, a playlist-writing step converts the selected paths into concat-demuxer directives. The resulting text file is the hand-off between your folder logic and FFmpeg. You should be able to open it in a text editor and see the exact sequence that will be attempted.
Keep the collection process deterministic while testing. If it reshuffles the list every time, a failure can be difficult to reproduce. Begin with a small, known set of files from each folder. Once the order and media properties are understood, you can add more files or introduce a controlled shuffle.
Paths need careful handling. A space in a filename, an apostrophe, a backslash or a non-ASCII character can change how a path is interpreted. The correct quoting and any safety-related option depend on the operating system, the way the list is generated and the FFmpeg version in use. Do not copy quoting rules from a different shell and assume they have the same meaning on Windows, Linux or macOS.
Absolute paths are often easier to understand during initial testing because they make the intended location explicit. Relative paths can make a project easier to move, but they depend on the directory from which FFmpeg is launched and on the concat demuxer’s path-handling rules. Choose one approach, document it, and test it from the same working directory used by the unattended process.
If your files live on an always-on home computer, storage and network interruptions become part of the problem. A playlist can be perfectly written and still fail when a drive is asleep, disconnected or being used while a file is copied. The article on running a 24/7 rain sounds YouTube channel from an Indian home PC is relevant to that wider reliability question.
Write one ordered concat list
A concat playlist is a plain text file with one file directive for each media file. The order of the lines is the playback order. To rotate across folders, write paths from those folders in the sequence you have already chosen.
For example, a static list might look like this:
file '/media/folder-a/clip-01.mp4'
file '/media/folder-b/clip-02.mp4'
file '/media/folder-a/clip-03.mp4'
This is only a syntax illustration. It is not a tested command, not a complete YouTube Live setup and not a promise that these particular paths exist or that the files are compatible. You must confirm the appropriate quoting and concat safety settings for your operating system and FFmpeg build before turning the illustration into a production command.
The important point is that the folders appear only because their paths were placed in the list. The demuxer does not perform a folder rotation. In the example, the second entry comes from folder-b because the list writer put it there, not because FFmpeg detected a second folder.
A generator can produce a list with one file from each folder at a time, or it can create blocks. Consider these two policies:
| Rotation policy | Resulting list pattern | Useful when |
|---|---|---|
| Folder blocks | All selected files from A, then B, then C | Each folder represents a programme block |
| Round-robin | A, B, C, then the next A, B, C | You want frequent changes between categories |
| Weighted rotation | A, A, B, A, C, then repeat the rule | One category should appear more often |
| Scheduled batches | A prepared list for a particular time period | The channel follows a timetable |
None of these policies is supplied by the concat demuxer. They are choices made by the process that writes the text file. Keeping that distinction clear prevents a common debugging mistake: changing FFmpeg options when the actual error is in the generated order or in the set of files selected.
Inspect the finished list before launching a long stream. Check the first several entries, the transitions between folders and the final entries. Remove temporary paths, duplicated files and files that are still being written. A list that is correct at 9 am can become stale later if the underlying folders change.
Understand how the concat demuxer sequences files
The concat demuxer treats the listed media as a sequence. It reads one file, then moves to the next, adjusting timestamps so that the following file can continue after the preceding one. The official FFmpeg documentation describes this as a virtual input that reads files one after another.
That timestamp handling is why a concat list can be useful for a fixed programme. You do not need to build a separate input for every folder. The playlist becomes the input description, while the individual media files remain the items in the sequence.
It does not mean that every transition will be visually or audibly seamless. Different durations, audio layouts, frame rates and other properties can expose gaps or unexpected behaviour. The demuxer is sequencing compatible inputs, not repairing a collection of unrelated productions.
The FFmpeg FAQ distinguishes the concat demuxer from the concat filter. The demuxer is suited to cases where the files already match sufficiently for the intended workflow and re-encoding is to be avoided where possible. The filter is the relevant route when a re-encoding workflow is needed to bring inputs together.
This also explains why a playlist file is not a complete broadcast system. It describes which media should be read and in what order. It does not decide your YouTube ingest address, stream key, output encoding, reconnection policy, monitoring method or response to a failed source file. Those parts require separate decisions and current documentation.
A finite playlist can also be repeated, but repetition and live updating are different. Repeating a known list means the same entries are played again. Live updating means a separate process changes or replaces the selection while streaming. The latter can involve race conditions, partial files and restart behaviour, so do not promise yourself that editing the text file will be picked up cleanly without testing.
Check paths and media compatibility
Before you attempt an overnight broadcast, test the list with representative files from every folder. A successful first clip does not prove that the transition to the second folder will work. Problems often appear only when the next file has different streams or a path that is quoted incorrectly.
The concat demuxer’s documented requirements include matching streams, codecs and time bases. In practical terms, compare at least these properties across the intended set:
- video codec and basic stream structure
- audio codec and channel layout
- frame size and aspect ratio
- frame-rate and time-base behaviour
- presence or absence of audio
- rotation metadata and unusual subtitle or data streams
The files do not need to have identical content. They do need to be prepared consistently enough for the method you have chosen. A devotional video with stereo audio and a silent visual loop may not be interchangeable merely because both are MP4 files.
A frequent source of trouble is mixed dimensions. One folder may contain phone exports in portrait format, another may contain landscape recordings, and a third may contain downloaded material with a different frame size. Different aspect ratios can also produce an unwanted crop, padding or failure depending on the rest of the processing chain.
If the inputs do not match and re-encoding is acceptable, use a workflow designed to normalise them before concatenation, or use the concat filter as appropriate. The 2024 FFmpeg-user discussion is community advice about varied formats, dimensions and aspect ratios, not a guarantee for every build. Treat it as a reason to test representative files, not as proof that one command will solve every mixed library.
Normalising files ahead of time can make the later playlist simpler. You might create a prepared library with consistent video dimensions, audio presence and encoding choices, then generate lists only from that library. The trade-off is additional processing and storage, and a normalisation step can change quality or file size. Keep the original files separately if they may be needed for another use.
Check the transition in a short local test. Include at least one file from each folder and let FFmpeg reach the boundaries between them. Watch and listen for a frozen frame, missing audio, a timestamp warning, an unexpected aspect ratio or a sudden end. Save the console output so you can distinguish a path problem from a stream-compatibility problem.
Treat the playlist snippet as an illustration
The three-line example is deliberately small. It demonstrates the relationship between a text list and a sequence of paths, but it omits the parts that make a real YouTube Live workflow environment-specific.
A production setup would need decisions about how the list is generated, where it is stored, which FFmpeg version is installed, how files are quoted, whether the inputs are compatible, how a finite list is repeated and what happens when one file is missing. It would also need a current YouTube configuration checked against YouTube’s own instructions.
For YouTube’s current guidance, consult the official YouTube Help page for live streaming with an encoder. Check the current ingest address, stream-key handling and output recommendations there rather than treating an old example as a permanent platform configuration. The research for this article does not establish a current, complete YouTube command.
Keep the media-list test separate from the destination test. First establish that the files can be read in the intended order. Then verify the output settings and YouTube connection in a controlled broadcast. This separation reduces the number of variables when a stream stops or a transition fails.
If your aim is to keep a channel running while your computer is switched off, the operating model changes. A local FFmpeg process depends on the machine, storage, power and network remaining available. A cloud-based workflow can remove the need to leave that computer running: StreamNeo takes an uploaded video and a YouTube stream key, then runs the resulting YouTube broadcast remotely with automatic monitoring and restart, without requiring local installation.
That is a different workflow from configuring your own FFmpeg folder scanner. It may suit a finished, stable video file, but it does not remove the need to check rights, channel settings, source content and YouTube’s current rules. If you are comparing local and remote operation, also read how to reduce VPS costs for a nonstop prerecorded YouTube stream and how to stream a folder of videos to YouTube Live continuously from Linux.
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 scan several folders automatically?
No. The concat demuxer reads the paths listed in its text file. A separate script or process must find the files, choose the order and write the list.
Can I alternate folders instead of playing one folder at a time?
Yes, if the playlist generator writes the paths in an alternating pattern. For example, it can place an entry from folder A, then folder B, then folder C, but that pattern comes from the generated list rather than from the concat demuxer.
What if the videos have different sizes or codecs?
Do not assume that a shared file extension makes them compatible. Check the streams, codecs, dimensions and time bases; if they differ, test a normalisation or concat-filter workflow that re-encodes where appropriate.
Will editing the playlist add new files to a live stream?
Not necessarily. A static list and a continuously refreshed list are different requirements, and this article does not establish a reliable live-refresh method. Test the exact watcher, restart and failure behaviour before depending on it for an unattended channel.