A folder of videos can be sent to YouTube Live in order with FFmpeg by turning the files into a concat-demuxer playlist, looping that playlist, pacing the input in real time, and encoding the result for YouTube. This works best when every file has the same stream layout, codecs and timing characteristics.
The method gives you direct control, but it does not make a mixed folder compatible automatically or guarantee an uninterrupted broadcast. Your computer, power, network connection and FFmpeg process still matter, so test the complete chain before relying on it overnight.
Prepare and order the video files
Start by deciding the exact playback order. The concat demuxer follows the order in its text file, not the order shown by your file manager. Rename files with a consistent sequence if that makes the order easier to inspect, then create a working directory containing only the videos intended for this stream.
For example, a devotional channel might use an opening slate, several bhajans, a short information card and a closing slate. A study channel might arrange lectures by subject, followed by a break screen. Put those files in the sequence viewers should see, and make any repeated elements explicit rather than relying on alphabetical order.
Keep filenames simple where possible. Relative names such as morning-01.mp4 and morning-02.mp4 are easier to use safely than paths containing shell characters, quotation marks or unusual punctuation. If you need to work with spaces or special characters, quote or escape them correctly for the concat file and the shell you are using.
You should also check the files before writing commands around them. Look for missing audio, unexpected portrait dimensions, variable frame rates, very long pauses at the start or end, and files that were only partially copied. FFmpeg can read many formats, but reading a file is not the same as being able to join it cleanly with every other file.
If you are deciding whether this local approach is suitable for a long-running channel, compare its requirements with the issues covered in how to loop a YouTube Live stream from a VPS. A local machine is straightforward when you control it, but it remains part of the broadcast path.
Check that the streams are compatible
The concat demuxer is a playlist reader, not a general-purpose normaliser. FFmpeg's documentation says the files should have the same streams, codecs and time bases. In practical terms, each item should expose matching video and audio streams with compatible dimensions, frame characteristics and encoding details.
A folder is therefore not ready simply because every file ends in .mp4. These examples can cause trouble when joined directly:
| Difference between files | What can happen | Safer action |
|---|---|---|
| One file has no audio | The combined stream may fail or produce irregular audio | Add or remove audio during preprocessing so every file has the same layout |
| Different video dimensions | The decoder or output filter may not receive a consistent frame shape | Scale and pad or crop everything to one chosen format |
| Different codecs or pixel formats | The demuxer may reject the files or pass incompatible packets | Transcode to a common codec and pixel format |
| Different frame timing or time bases | Jumps, warnings or audio-video drift may appear | Normalise timing and inspect the result |
| Damaged or inaccurately timed duration | The next item may begin at the wrong point | Repair or recreate the affected file before joining |
Use ffprobe or another trusted inspection method to compare the streams. You are looking for a repeatable pattern, not merely a matching filename extension. Record the video codec, width, height, frame rate, pixel format, audio codec, sample rate and channel layout for each file.
If the source material is mixed, create a second folder of normalised copies. Choose one output shape and frame rate that your computer and connection can sustain, then convert every source to that pattern. Do not assume that a command which works for three matching files will work unchanged for a folder containing phone recordings, screen captures and downloaded clips.
The best video format for 24/7 YouTube Live streaming in India is useful background when choosing a consistent format, but YouTube's current live requirements should take precedence. YouTube can change its recommendations, and the source material may make a lower, consistent output more sensible than repeatedly forcing high resolution.
Create the concat playlist
Create a plain text file named playlist.txt in the same directory as the videos. Its first line must be the concat marker, followed by one file directive per video:
ffconcat version 1.0
file 'morning-01.mp4'
file 'morning-02.mp4'
file 'morning-03.mp4'
The first line is not a comment. It identifies the file as an FFmpeg concat script and must appear exactly at the beginning. Each following line points to one input file in playback order.
Relative paths keep the file portable and normally allow FFmpeg's default safe-path behaviour to remain enabled. The concat demuxer uses safe mode by default and can reject paths it considers unsafe. That is a useful boundary, not an obstacle to remove automatically.
You will often see -safe 0 in examples. It allows more kinds of paths, including paths that the default rejects, but it should not be added without understanding the filenames and location you are accepting. For a controlled directory with simple relative names, leave safe mode at its default. If you genuinely need absolute or unusual paths, use -safe 0 deliberately and keep the playlist private.
You can read the FFmpeg concat demuxer documentation for the rules around directives, paths, stream matching and duration handling. The demuxer adjusts timestamps as it moves from one file to the next, so incorrect or truncated duration information can show up as a pause, overlap or abrupt transition.
Before connecting to YouTube, run the playlist locally and write a short output file. Watch the joins, listen for audio gaps and inspect the beginning of the final item. This test catches ordering and compatibility errors without involving your live channel.
Loop the playlist and pace it in real time
Two separate input options matter here. -stream_loop -1 tells FFmpeg to repeat the input indefinitely, while -re tells it to read file input at its native rate instead of consuming the files as quickly as the computer can decode them. Both are placed before the relevant -i option.
A conceptual command looks like this:
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \\
-c:v libx264 -preset veryfast -b:v 6000k -maxrate 6000k -bufsize 12000k \\
-g 60 -r 30 -c:a aac -b:a 128k -f flv \\
"rtmps://YOUTUBE_INGEST_URL/STREAM_KEY"
This is an illustrative structure, not a universal command. The bitrate, frame rate, GOP size, encoder availability and destination URL must match your chosen output profile and installed FFmpeg build. The values shown should not be copied as proof that every folder or YouTube channel will accept the same settings.
The placement of the input options is important. If -re or -stream_loop is placed after -i, FFmpeg may interpret it as an output option or apply it differently from what you intend. The FFmpeg command-line documentation explains how options are associated with inputs and outputs.
Real-time pacing protects the live service from receiving the whole playlist immediately. Without it, FFmpeg may process prerecorded material at the fastest rate the machine allows, causing the output timing to be unsuitable for a live ingest. Pacing does not solve a slow computer or an unreliable network; it only makes the input clock behave like a live source.
An infinite loop is also not the same thing as an infinite YouTube event. YouTube's guidance says streams under 12 hours are automatically archived. That does not promise that one event can run forever or that an endlessly repeated playlist will become one complete, indefinitely available recording. Plan controlled restarts if the channel needs long-term operation, and decide how viewers should experience any transition.
Choose an output YouTube can accept
The output settings should be chosen as a group. Resolution, frame rate, codec, bitrate, rate control, keyframe interval and audio settings affect one another. Start with what the source actually contains and what your upload connection can sustain, rather than selecting the largest profile first.
YouTube's live encoder guidance, as listed on YouTube Help's site in October 2026, calls for RTMP or RTMPS, constant bitrate control, video frame rates up to 60 fps and a recommended two-second keyframe interval, with no more than four seconds. Its displayed H.264 recommendations include 10 Mbps for 1080p at 30 fps and 6 Mbps for 720p at 60 fps. The same table also lists 14 Mbps for 1080p at 60 fps and 8 Mbps for 720p at 30 fps. Check the current YouTube live encoder settings before publishing because these recommendations can change.
These figures are settings from YouTube's table, not a promise that your connection can sustain them. Run an upload speed test, leave room for network variation, and watch the stream-health messages. A stable lower profile is more useful than a high profile that repeatedly falls behind.
For H.264 at 30 fps, a two-second keyframe interval commonly corresponds to a GOP of 60 frames. At 60 fps, it commonly corresponds to 120 frames. The relationship depends on the actual output frame rate, so do not copy -g 60 when changing the output to 60 fps without reconsidering the interval.
A simple H.264 output section might include:
-c:v libx264 -preset veryfast -r 30 -b:v YOUR_VIDEO_BITRATE \\
-maxrate YOUR_VIDEO_BITRATE -bufsize YOUR_BUFFER_SIZE \\
-g 60 -c:a aac -b:a 128k -f flv
Replace the placeholders with values selected from the current YouTube guidance and your source. Confirm that your FFmpeg build includes libx264; another build may expose different encoders. If hardware encoding is available, test its rate-control and keyframe behaviour rather than assuming that the encoder name alone proves compliance.
Audio deserves the same attention as video. A missing or inconsistent audio stream is one reason to normalise files before concatenation. Listen for silence, clipping, channel changes and different loudness between items. A quiet devotional track followed by a much louder advert or slate can make an otherwise technically correct stream unpleasant to watch.
Send the output with your stream key
In YouTube Studio, open the live creation area and create or schedule the broadcast. The Live Control Room provides the server URL and stream key for the encoder connection. Copy those values into your local command or configuration, then start FFmpeg and wait for YouTube's preview before making the event public. YouTube describes the creation and control process in its official live streaming instructions.
Treat the stream key as a credential. It tells the encoder where to send the feed and allows YouTube to accept it. Do not put a real key in a public script, screenshot, support ticket, shared document or shell-history example. Use a placeholder in documentation, restrict access to the machine running FFmpeg, and reset the key in Live Control Room if you believe it has been exposed.
The output destination in the example is deliberately incomplete:
rtmps://YOUTUBE_INGEST_URL/STREAM_KEY
Use the server address and key shown for your own broadcast. Do not add spaces, punctuation or quotation marks that are not part of the copied values. Keep the command in a protected file if placing a credential directly in the command line would expose it through process listings or logs on your operating system.
If you schedule the event, start FFmpeg early enough to inspect the preview. If you start the encoder before the event is ready, YouTube may show the incoming feed while the broadcast itself remains unpublished. Follow the controls shown in your current Live Control Room rather than assuming every account has identical prompts or timing.
Preview and monitor the broadcast
Run a private or unlisted test first where that suits the channel. Use representative material, including real audio, movement, fades, captions and the longest or most demanding file. A static test card can hide problems that appear during a busy scene or a transition between two files.
In the preview, check that the image is not stretched, cropped unexpectedly or surrounded by an unintended black border. Listen through more than one device if possible. Then inspect YouTube's stream-health messages for dropped frames, unstable input, audio warnings and encoder problems.
Keep the FFmpeg console visible during the test. Warnings about non-monotonic timestamps, buffer underflows, repeated reconnects or decoding errors deserve investigation before you announce the stream. A process that continues printing output is not necessarily healthy if the preview is several seconds behind or the stream health is deteriorating.
After going live, monitor the first transitions between files. The beginning and end of each item are where mismatched timestamps, different audio layouts and incorrect durations tend to show. You should also check what happens when the playlist returns from its final item to its first item.
A local FFmpeg process needs an operating plan. Disable sleep, ensure the machine has adequate cooling, consider what happens after a power cut, and decide who will notice if the process stops. Your internet connection must sustain the selected upload rate for the whole session. The article on keeping a YouTube FFmpeg stream running during power cuts in India covers practical reliability concerns that sit outside the concat command.
If you need the file and stream to continue while your own computer is switched off, StreamNeo removes the need to keep a local FFmpeg process running by taking an uploaded video, your YouTube stream key and the repeating broadcast into one managed workflow; you should still test the channel and review YouTube's current rules yourself.
Decide whether local FFmpeg is the right fit
Local FFmpeg is a good fit when you want scriptable control, already have a reliable computer and are comfortable checking logs. It also makes preprocessing and custom filters accessible. The trade-off is that you own the maintenance: source files, operating-system updates, power, cooling, network recovery and restarts all remain your responsibility.
A cloud playout workflow trades some command-line control for less dependence on your own computer. It may suit a small business, local news loop or study channel where the main requirement is that an uploaded programme keeps playing after you close the laptop. Review the actual operating model, YouTube connection method and recovery behaviour before choosing one. The comparison in cloud service pricing for 24/7 YouTube prerecorded streaming can help frame the questions, but check every provider's current terms directly.
Whichever route you choose, keep a master copy of the normalised files, the playlist and the output settings. Document the intended order and the steps for resetting the stream key. A short recovery note is more useful at two in the morning than a command copied from memory.
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
Can FFmpeg concatenate any videos in a folder?
No. The concat demuxer expects compatible streams, codecs and time bases. If the folder contains different resolutions, missing audio or different encoding layouts, normalise the files first and test the joined output before sending it to YouTube.
Why are -re and -stream_loop both needed?
They solve different problems. -stream_loop -1 repeats the finite playlist, while -re makes FFmpeg read file input at approximately its native rate instead of processing it as quickly as possible.
Is putting the stream key in the FFmpeg command safe?
A stream key should be treated like a password and kept out of public files, screenshots and shared logs. If it is exposed, reset it from YouTube's Live Control Room and update the encoder configuration.
Can this run forever as one YouTube broadcast?
The command can repeat the input, but that does not guarantee an endless YouTube event, uninterrupted delivery or one permanent archive. Test the complete setup, monitor stream health and plan controlled restarts or another operating method for a channel that must remain available.