To shuffle videos in a continuous YouTube stream with FFmpeg, randomize a list of compatible files, feed that list to FFmpeg’s concat demuxer, and loop the resulting input with -stream_loop -1. This repeats the same shuffled order indefinitely. FFmpeg’s loop option does not reshuffle the files for each pass; that requires external control logic to prepare and switch to a new order.
Choose what “shuffle” should mean
- One shuffled order, repeated: Create a randomized playlist once, then loop it. This is the simplest setup, but every cycle uses the same sequence.
- A new order after each cycle: Use an external supervisor or playlist source to generate the next order and manage a controlled transition or restart at the cycle boundary. The concat input loop alone does not do this.
Do not rely on editing the playlist file while FFmpeg is already processing it: the documented workflow does not establish that a running input will adopt changes.
Prepare compatible video files
Put the videos you want to stream in a directory and check that their stream characteristics are compatible for concatenation. Differences in codecs, resolution, frame rate, time base, or audio layout can cause playback errors or inconsistent output. If they differ, test and normalize the sources, or use a controller that opens and encodes each file consistently.
FFmpeg’s concat demuxer reads an ordered list; it does not randomize that list. The shuffle step below happens in the shell before FFmpeg starts. The example uses POSIX tools and assumes filenames that do not contain newlines. For paths with spaces or apostrophes, use correct FFmpeg concat-file quoting; the concat demuxer documentation explains quoting and its default safe-path behavior. Prefer simple relative filenames. Set -safe 0 only when you trust the paths and playlist contents.
#1 Best Overall
- 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.
Generate one shuffled FFmpeg playlist
From the directory containing your compatible media files, create the playlist with a randomized file order:
find . -maxdepth 1 -type f ( -iname '*.mp4' -o -iname '*.mov' -o -iname '*.mkv' ) -print
| shuf
| while IFS= read -r file; do
printf "file '%s'n" "$file"
done > shuffled.ffconcat
This simple writer is suitable only for paths that do not contain apostrophes or newlines. If your filenames contain them, escape each path according to FFmpeg’s concat syntax rather than inserting it directly into a quoted file line. Inspect the result before streaming:
Rank #2
- 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.
cat shuffled.ffconcat
The file should contain one file entry per input, in the order you want for one cycle. FFmpeg may reject unsafe paths or directives because concat safe mode is enabled by default; the example command below explicitly disables that check, so use it only with a playlist you created and trust.
Connect FFmpeg to YouTube
- Create or select a stream: In YouTube Studio, open Live Control Room and create or select the stream you intend to use.
- Copy the ingest details: Copy the server URL and stream key displayed by YouTube. Keep the key private. YouTube’s encoder instructions say to enter the Live server URL and stream key in the encoder.
- Set the output destination: Provide FFmpeg with the server URL and key for the protocol YouTube shows for that stream. The template below uses an RTMP-style URL assembled from environment variables; use the exact URL format YouTube provides for your selected ingest protocol.
- Start FFmpeg and check reception: Confirm in Live Control Room that YouTube receives the signal and that the preview looks and sounds right before relying on the stream.
Keep credentials out of scripts that might be shared or committed. Set the variables in your shell, taking care not to expose them in logs or screenshots:
Rank #3
- 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.
export YOUTUBE_RTMP_URL='YOUR_YOUTUBE_SERVER_URL'
export YOUTUBE_STREAM_KEY='YOUR_PRIVATE_STREAM_KEY'
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i shuffled.ffconcat
-c:v libx264 -c:a aac -f flv
"$YOUTUBE_RTMP_URL/$YOUTUBE_STREAM_KEY"
This is a template, not a tested command. Its encoding options are examples, not universal recommendations. The required codec, resolution, frame rate, bitrate, keyframe interval, audio parameters, and output muxer depend on the source files, your FFmpeg build and hardware, and the ingest protocol YouTube assigns. Consult the current FFmpeg documentation and YouTube’s stream settings for the protocol you actually use.
Understand the loop and reshuffle limits
-stream_loop -1 tells FFmpeg to repeat its input indefinitely. Combined with the concat list, it repeats the complete list in the same order. It is not a random-playback option, and it does not create a fresh shuffled list at the start of each pass.
Rank #4
- 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
For per-cycle reshuffling, an external process must create the next order and coordinate a transition or restart when the current cycle finishes. A robust design needs to account for how the next list is opened and how output continuity is maintained; simply replacing the file on disk is not a documented live-update mechanism.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.RTMP and HLS are different ingest choices
YouTube’s encoder workflow commonly uses the server URL and key supplied in Live Control Room. HLS is an alternative with separate format and latency characteristics; do not use HLS-specific settings as if they were universal RTMP requirements.
Best Value
- 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.
- For YouTube HLS ingest: YouTube specifies muxed M2TS, H.264 or HEVC video, AAC audio, a closed GOP, and support for up to 60 fps. Its HLS guide describes segments of one to four seconds and notes relatively higher latency. See YouTube’s HLS ingestion guide.
- Playlist layers are not interchangeable: The source-video order in your concat file determines the order of videos. HLS segment playlists describe how the receiver reconstructs a transmitted stream; they are not the mechanism for shuffling source videos.
Plan for a genuinely continuous broadcast
FFmpeg can keep sending repeated media, but YouTube’s broadcast lifecycle is a separate concern. YouTube says streams under 12 hours are automatically archived; do not assume that one archived video will cover an arbitrarily long continuous broadcast. See YouTube’s encoder streaming guidance.
YouTube’s Live Streaming API distinguishes a broadcast—the watchable event or video—from the stream resource that carries audio and video. Its documentation includes a 24/7 feed as an ongoing use case. For scheduled or API-managed setups, manage the broadcast lifecycle separately from FFmpeg’s media input; see Understanding broadcasts and streams.
Troubleshoot common failures
- FFmpeg rejects the concat list: Check that each line uses valid concat syntax, the referenced paths exist, and safe mode is not rejecting a path or directive. Use relative, ordinary filenames where practical; only disable safe mode for a playlist you control.
- The stream fails when it reaches a particular file: That file may be missing, malformed, or incompatible with the others. Test each input and normalize mismatched media before relying on an indefinite loop.
- YouTube does not show an incoming preview: Verify the server URL, key, and selected protocol in Live Control Room. Confirm FFmpeg is running and that the key has not been copied with extra characters. Keep the key private.
- The stream repeats but does not reshuffle: That is expected with
-stream_loop -1. It repeats the existing concat order; add external cycle-control logic if each pass needs a different order. - The output has unexpected quality or playback problems: The example’s codec settings may not fit your sources or ingest settings. Confirm the selected protocol’s requirements and test resolution, frame rate, bitrate, GOP, and audio settings against the actual media and encoder build.
- The stream runs but archiving or event behavior is wrong: Check the broadcast setup and YouTube’s lifecycle guidance; the encoder’s repeated media input does not itself manage the broadcast resource or guarantee an archive of unlimited duration.
Or let it run in the cloud
If your goal is a YouTube channel that keeps uploaded videos live without keeping a home computer running, StreamNeo is a cloud alternative: upload a recording or build a playlist, add your YouTube stream key, and go live. It loops uploaded videos rather than broadcasting from a camera. Nothing has to stay on at home; videos stream as uploaded, up to 4K 60fps, at one price per slot, and the service automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. Start your free first day on StreamNeo.
Frequently Asked Questions
Does FFmpeg shuffle videos by itself?
No. Shuffle the file list before FFmpeg reads it; the concat demuxer follows that supplied order.
Free tools Windows power users keep installed
One-click scans. No signup required.
Will editing the playlist make a running FFmpeg process reshuffle?
That behavior is not established by the documented workflow. Use external logic to create and activate the next order at a cycle boundary.
Quick Recap
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.




