Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
FFmpeg

How to Loop a Folder of MP4 Files to YouTube Live with FFmpeg

Use an FFmpeg concat playlist and -stream_loop -1 to repeat MP4s on YouTube Live. Learn how to set the ingest destination, check file compatibility, and test stream health.

By VGSources Team 6 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To loop a folder of MP4s on YouTube Live with FFmpeg, put the files in the order you want in a concat-demuxer playlist, then use -stream_loop -1 before that playlist input and send the output to the YouTube ingest URL with your stream key. The command below is a starting point: the files must be compatible for packet concatenation, and you should test the stream privately or as unlisted before making it public.

Prepare and order the MP4 files

FFmpeg will follow the order in the playlist, not an assumed folder order. Create a UTF-8 text file named playlist.txt beside the videos, with the header on the first line and one file directive per video:

ffconcat version 1.0
file 'video-01.mp4'
file 'video-02.mp4'
file 'video-03.mp4'

The ffconcat version 1.0 header must be the first line exactly for automatic format recognition. Use paths that resolve from the directory where you run FFmpeg. Filenames containing special characters may need escaping or quoting according to the concat-demuxer syntax; see the FFmpeg concat demuxer documentation for the list-file rules.

Check whether the files can be concatenated directly

The concat demuxer joins encoded packets rather than decoding and rebuilding each file. FFmpeg expects the files to have matching streams, codecs and time bases. Different stream layouts or incompatible timing can make the command fail or cause gaps and artifacts at file boundaries. Unequal audio and video durations can also create gaps, and incorrect duration metadata can affect timestamps.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Approach When it fits Trade-off
Concat demuxer (command below) The MP4s have compatible stream layouts, codecs and time bases. Preserves encoded packets instead of decoding and re-encoding, but mismatches can cause errors, gaps or artifacts.
Normalize or decode and re-encode The files differ enough that packet-level concatenation is unsuitable. Can produce a consistent output, but requires decoding and encoding. CPU demand and quality depend on the media and encoding settings.

If the files are not compatible, normalize them to consistent streams and timing or use a decoding-and-re-encoding workflow rather than assuming this packet-level command will make them seamless.

Get the YouTube ingest URL and stream key

  1. In YouTube Studio, open Live Control Room and create or select the stream you intend to use.
  2. Copy the server URL and stream key shown for the encoder connection. Use the exact destination format YouTube provides; the example command below uses placeholders, not a real key.
  3. Keep the key private. Treat it like a password, and reset it if you think it has been exposed. YouTube’s encoder setup guide describes connecting with the stream URL and key; its live stream settings guide covers stream keys and controls.

Run FFmpeg with an endlessly repeated playlist

Replace the destination with the precise ingest URL and key format shown in Live Control Room. Run the command from the directory containing playlist.txt, or adjust the playlist path. This is an illustrative command shape, not a tested universal command; FFmpeg options and available encoders depend on your installed build.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt 
  -c:v libx264 -preset veryfast -pix_fmt yuv420p 
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "rtmps://INGEST_SERVER/APP/STREAM_KEY"
  • -re reads local media at its native rate rather than letting FFmpeg process it as fast as the machine allows. Test with your actual files and output.
  • -stream_loop -1 repeats the next input indefinitely. It must come before -i playlist.txt so it applies to the playlist.
  • -f concat -safe 0 -i playlist.txt selects the concat demuxer and reads the list. -safe 0 permits paths that the default safety check may reject, so use it only with a playlist you trust.
  • -c:v libx264 and -c:a aac select video and audio encoders if they are available in your FFmpeg build. Verify encoder availability and the current YouTube ingest requirements.
  • -r 30 sets a 30 fps output target; -g 60 and -keyint_min 60 set a two-second keyframe interval at that frame rate. The example’s -b:a 128k is an audio bitrate, not a YouTube-mandated value.

FFmpeg input options apply to the input that follows them, so keep -stream_loop -1 before the concat input. For the output, YouTube recommends RTMPS, a secure extension of RTMP. Its published encoder guidance includes RTMP/RTMPS and H.264, H.265/HEVC or AV1 video, with AAC or MP3 audio and constant bitrate encoding. Confirm the current requirements and that your FFmpeg build can produce the codec and protocol you choose in YouTube’s encoder settings guidance.

Choose output settings for the source and connection

The example encodes H.264 at 30 fps; it does not preserve every source file’s original encoding. YouTube’s recommended bitrate depends on codec, resolution and frame rate. Its current H.264 guidance lists 10 Mbps for 1080p at 30 fps and 12 Mbps for 1080p at 60 fps. Those are recommendations for those modes, not universal settings for every stream. Use the current YouTube encoder settings table for your chosen resolution, frame rate and codec, and choose a bitrate your upload connection can sustain reliably.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

YouTube recommends a two-second keyframe interval and says not to exceed four seconds. In the example, a GOP of 60 frames at 30 fps gives a two-second interval. If you change the frame rate, recalculate the GOP to preserve the interval; for example, at 60 fps, 120 frames is two seconds. Verify the actual output settings and stream health in Live Control Room.

Test the event before making it public

  1. Start with a private or unlisted event, then run the FFmpeg command.
  2. Wait for YouTube’s preview and check that video and audio arrive.
  3. Watch the handoff between files: confirm the next clip starts in the intended order and listen for gaps or abrupt audio changes.
  4. Check YouTube’s stream-health indicators and correct warnings before starting a public event. YouTube recommends testing and monitoring the encoder stream.
  5. Only then use the event’s stream-start controls as intended. Whether YouTube starts or stops a stream automatically depends on the selected Live Control Room settings.

Plan for long unattended streams

An indefinitely looping playlist does not guarantee an uninterrupted 24/7 broadcast. FFmpeg still depends on the computer and network staying available, files remaining accessible, and the process continuing to run. For unattended use, plan how you will supervise and restart the process, recover from network or ingest interruptions, preserve access to the media, and monitor the stream. YouTube’s controls include latency and stream-start/stop options; check the settings on your event rather than assuming it will start or end automatically. YouTube’s encoder setup article says streams under 12 hours are automatically archived; check current platform behavior if your event will run longer or archiving matters.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

  • FFmpeg rejects the playlist: Check that the header is exactly the first line, the file is UTF-8, each path is correct, and special characters follow concat-demuxer escaping rules.
  • The stream fails at a file boundary: Compare the files’ stream layouts, codecs and time bases. If they do not match, normalize or decode and re-encode the files before concatenating.
  • There are gaps or artifacts between clips: Check audio and video durations and the MP4 duration metadata. Timestamp differences or unequal stream lengths can affect transitions.
  • FFmpeg reports an unknown encoder: Your installed build may not include the requested encoder. Confirm which encoders it supports, then choose an available codec that YouTube accepts.
  • YouTube does not receive the stream: Recheck the exact ingest server URL and stream key in Live Control Room, the selected protocol, and the output format. If the key may have been exposed, reset it.
  • Ingest is unstable: Check that the upload connection can reliably sustain the selected video and audio bitrates. Compare resolution, frame rate and codec against YouTube’s current settings table, then test again while monitoring stream health.

Check rights and YouTube policies before broadcasting

Only stream MP4s you have the rights and permissions to use. A live broadcast can still raise copyright issues even when its source is prerecorded. Also consider whether the channel’s overall content meets YouTube’s monetization policies: permission to use material and eligibility for monetization are separate questions, and simply looping videos does not establish eligibility. Review YouTube’s current live encoder guidance and applicable copyright and monetization policies before scheduling a public or monetized stream.

Or let it run in the cloud

If you want a YouTube channel to stay live without leaving this FFmpeg setup running on a home computer, StreamNeo is a cloud service for looping uploaded videos and playlists. Upload your recording or playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home; StreamNeo streams uploaded video at the quality it was made, up to 4K 60fps, for one price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card required. Monthly billing is $9.99 per month. See StreamNeo for details, or start your free day.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from Patch Notes

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.