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 DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
DocumentaryTube
concat demuxer

How to Shuffle Videos with FFmpeg in a Continuous YouTube Stream

Randomize a concat-demuxer playlist and loop it with FFmpeg for a continuous YouTube stream. Learn why the order repeats, how to reshuffle between cycles, and what to check in YouTube Studio.

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

To shuffle videos in a continuous YouTube stream, create an ordered concat-demuxer playlist with the video filenames randomized, then tell FFmpeg to loop that playlist indefinitely. The sequence will repeat in the same order on each pass. FFmpeg’s input-loop option does not reshuffle the files; getting a new order each cycle requires external control logic.

What FFmpeg will—and won’t—shuffle

FFmpeg’s concat demuxer reads files in the order listed in a text file. Shuffle that list before FFmpeg opens it, and you get one shuffled cycle. The -stream_loop -1 option repeats the input indefinitely; it does not generate a new random order on each repeat. [FFmpeg documentation; concat demuxer documentation]

This is a shuffle of whole source videos, not a shuffle of YouTube’s ingest segments. HLS segment playlists govern the order in which a live media stream is reconstructed; they are not a mechanism for randomizing the videos feeding FFmpeg.

Prepare compatible video files

Concat inputs should have compatible stream characteristics. If the videos differ in such properties as codecs, resolution, frame rate, or audio layout, test them together before going live. Normalize mismatched files to a consistent format, or use a controller that opens and encodes each file consistently. The encoding settings that work depend on your source media, FFmpeg build, hardware, and the ingest protocol selected in YouTube Studio.

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.

Keep source files and the playlist in a location FFmpeg can read throughout the broadcast. Relative filenames with ordinary characters are easiest to handle. Paths containing spaces or apostrophes need correct quoting in the ffconcat file.

Create a randomized concat playlist

On a POSIX shell, this example randomizes the matching filenames and writes an ffconcat file. Run it from the directory containing the videos; change the glob to match your file extensions and naming scheme.

find . -maxdepth 1 -type f ( -iname '*.mp4' -o -iname '*.mkv' ) -print0 
  | shuf -z 
  | while IFS= read -r -d '' file; do
      printf "file '%s'n" "${file#./}"
    done > shuffled.ffconcat

This simple writer is intended for filenames without apostrophes. For filenames with apostrophes, use FFmpeg concat syntax with proper escaping; do not assume shell quoting rules alone make a path valid in the playlist. FFmpeg’s concat documentation describes quoting and the demuxer’s safe-path behavior. Safe mode is enabled by default and may reject unsafe paths or directives. Prefer portable relative paths; use -safe 0 only when you trust the playlist contents and paths. [FFmpeg concat documentation]

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.

Check that the file begins with ffconcat version 1.0 if using that header format; otherwise, the example above can be used as a concat list with -f concat. Review the generated list before starting: it should contain one file entry per intended source, in the desired randomized order.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Connect FFmpeg to YouTube and loop the sequence

  1. Get the ingest details. In YouTube Studio, create or select a stream in Live Control Room and copy the server URL and stream key shown for that stream. Keep the key private. YouTube’s encoder instructions say to enter its Live server URL and stream key in the encoder. [YouTube Help: Create a YouTube live stream with an encoder]
  2. Set the destination securely. Put the server URL and key into environment variables or another protected configuration rather than publishing them in a script or command log. The example below assumes the server URL is a base URL and appends the key; follow the exact URL format shown in Studio if it differs.
  3. Start FFmpeg. This is a conceptual template, not a tested command. Adjust encoding and output settings for your media, system, and YouTube ingest protocol.
  4. Confirm receipt. Watch Live Control Room for the incoming preview and status. Verify picture and sound before relying on the stream.
export YOUTUBE_RTMP_URL='PASTE_SERVER_URL_HERE'
export YOUTUBE_STREAM_KEY='PASTE_STREAM_KEY_HERE'

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"

In this template, -re reads the input at its native pace, -stream_loop -1 repeats the complete concat input indefinitely, and -f concat selects the concat demuxer. The example uses H.264 video, AAC audio, and FLV output as a starting point for an RTMP-style workflow, not a universal preset. No specific bitrate, resolution, frame rate, keyframe interval, or audio bitrate is established here; choose them for the files and the protocol details YouTube supplies for your stream.

Choose between a repeating order and a fresh shuffle

Repeat one shuffled order

The command above is the simple option: FFmpeg reads the randomized list and repeats that same list in the same order. It is appropriate when a repeatable sequence is acceptable.

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.

Reshuffle at each cycle

To get a fresh order after every full pass, an external supervisor or playlist source must generate the next order and arrange a controlled transition or restart at the cycle boundary. FFmpeg’s documented input loop does not itself do this. Do not assume that changing the playlist file while FFmpeg is already reading it will change the active sequence; that behavior is not established by the documentation cited here. A restart-based approach may interrupt the feed, so plan how the next cycle begins if continuity matters.

RTMP or HLS ingestion

Use the protocol and server details presented for your stream in YouTube Studio; do not mix protocol-specific examples. YouTube Help describes RTMP as a common encoder setting. HLS is a distinct ingest option with its own format requirements and comparatively higher latency.

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

For YouTube HLS ingestion, Google specifies muxed M2TS, H.264 or HEVC video, AAC audio, a closed GOP, and support up to 60 fps. Its HLS guidance also describes segments of one to four seconds and media playlists that specify reconstruction order. Those HLS requirements should not be applied blindly to an RTMP output command. [Google for Developers: Delivering Live YouTube Content via HLS]

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

Plan for a genuinely continuous broadcast

A looping FFmpeg input can keep sending media, but the encoder’s input loop and YouTube’s broadcast lifecycle are separate concerns. YouTube describes a broadcast as a distinct live event/video and a live stream resource as the audio-video transmission associated with it; its API documentation gives a 24/7 live feed as an ongoing-feed use case. If managing broadcasts through the API or scheduled events, account for the broadcast resource lifecycle as well as FFmpeg’s media loop. [YouTube Live Streaming API: Understanding Broadcasts and Streams]

YouTube says streams under 12 hours are automatically archived. Do not assume that one archived video covers an arbitrarily long continuous broadcast. The help guidance also says to stop sending content from the encoder to end a stream. [YouTube Help: Create a YouTube live stream with an encoder]

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Copyright and channel-policy checks

Having the technical ability to loop a file does not grant permission to broadcast it. Use videos and audio you created or are authorized to stream, and check the relevant rights for every item in the playlist, including music, footage, and embedded material. Review YouTube’s current live-streaming and monetization rules for your channel before scheduling a long-running feed; technical continuity does not by itself establish policy compliance or monetization eligibility.

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.

Troubleshoot common failures

  • FFmpeg rejects a playlist path: Check path syntax, quoting, and whether concat safe mode is rejecting the entry. Use relative, portable paths where possible; disable safe mode only for trusted playlist contents.
  • The stream stops or errors at a particular file: Inspect that source for unreadable media or incompatible streams. Test the playlist end to end and normalize files with differing characteristics before relying on a continuous run.
  • YouTube does not show an incoming preview: Confirm that the URL and key are copied from the selected stream in Studio, that the chosen output format matches the ingest protocol, and that FFmpeg is still running. Keep the key private and replace it if it has been exposed.
  • The order repeats instead of changing: This is expected with -stream_loop -1. Regenerate the order and use external cycle-control logic if each pass needs a new shuffle.
  • The broadcast archive does not cover the full run: YouTube’s help page states that streams under 12 hours are automatically archived. For an ongoing feed, plan broadcast lifecycle and archival expectations rather than assuming unlimited single-event archiving.

Or let it run in the cloud

If you want a YouTube channel to keep playing uploaded videos without leaving a home computer on, StreamNeo is a cloud alternative: upload your recording or build a playlist, add your YouTube stream key once, and go live. It loops the uploaded videos from the cloud, not from a camera. Your computer and home connection do not need to stay on, it automatically recovers if YouTube drops the stream, and the uploaded quality is kept as made up to 4K 60fps for one flat price per slot. The first day is free with no card; there is one free day per account. You can choose daily, weekly, monthly, six-month, or yearly billing and cancel any time. Every slot includes 10 GB of storage, pooled across active slots, 24/7 looping and playlists, and StreamNeo team support. UPI and cards are available in India; card checkout is available worldwide. For five or more slots, contact support.

Monthly pricing: $9.99 per month. Learn more at StreamNeo, or start the free first day.

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 the Screening Room

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.