DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
FFmpeg

How to Stream Videos in Random Order to YouTube with FFmpeg

Shuffle your video list before FFmpeg reads it, then use a concat playlist to stream that sequence to YouTube Live. Learn how to loop, configure, test, and troubleshoot it.

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

To stream local videos in random order to YouTube with FFmpeg, shuffle the filenames into a concat-demuxer playlist, then give that playlist to FFmpeg as an input. The concat demuxer plays entries in list order; it does not shuffle them. Add -stream_loop -1 to repeat the same shuffled sequence, or regenerate the playlist with a separate process when you want a new order.

How the shuffled FFmpeg playlist works

Think of this as two separate jobs: a script or manual step decides the order, and FFmpeg reads that order from a text playlist. The concat demuxer processes entries sequentially, so the shuffle must happen before FFmpeg starts. Its input-loop option repeats the sequence as written; it does not reshuffle on each pass. See the FFmpeg concat demuxer documentation and FFmpeg command-line documentation.

Before building the playlist, decide whether you want one shuffled pass, a repeated fixed order, or a fresh order after every pass. The first two are straightforward. A fresh order each time requires an external playlist-generation and process-orchestration step; the implementation depends on your operating system and whether a gap between passes is acceptable.

Check whether your video files are compatible

The concat demuxer expects files to have matching streams, codecs, and time bases. Arbitrary clips may differ in video dimensions, frame rate, audio layout, or other stream properties. Those differences can cause errors or visible and audible artifacts at transitions. Compare representative files before committing to a long stream, and normalize or transcode incompatible clips to a common profile. FFmpeg distinguishes between demuxer concatenation for compatible files and the concat filter when re-encoding is needed; see its FAQ.

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.
  • Check that every listed file exists and is readable.
  • Compare video and audio streams, codecs, dimensions, frame rates, and time bases.
  • Check audio presence and layout so a clip without audio does not create an unexpected transition.
  • Test the complete playlist, especially clip boundaries, before using it for an event.

Create a playlist in shuffled order

Create a plain-text file such as playlist.txt, with one concat entry per clip. Put the entries in the order you want FFmpeg to play them:

file '/absolute/path/to/video-03.mp4'
file '/absolute/path/to/video-01.mp4'
file '/absolute/path/to/video-02.mp4'

Those sample paths are illustrative. Replace them with real paths on your system. Absolute paths avoid ambiguity about the working directory. If you use relative paths, make sure they resolve from the location and working directory used to launch FFmpeg. Filenames containing quotes or unusual characters need correct playlist escaping; validate the list by opening it with FFmpeg before going live.

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.

Shuffle the file list using a method available in your operating system or script environment, then write the resulting order to the playlist. The exact command differs by platform, so do not assume a Unix-only utility is available on Windows or elsewhere. If you change FFmpeg’s concat path-safety options, do so only for a playlist and paths you trust.

Loop and send the playlist to YouTube

This is a conceptual template, not a tested, copy-and-run command. Replace every placeholder, confirm the options supported by your FFmpeg build, and use the current ingest URL and stream key shown for your YouTube stream.

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.
ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt 
  -c:v libx264 -preset veryfast -b:v <video-bitrate> -maxrate <video-bitrate> 
  -bufsize <buffer-size> -g <keyframe-interval-in-frames> 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "<YouTube RTMPS ingest URL>/<stream key>"

-stream_loop -1 loops the playlist input indefinitely. The output is encoded as H.264 video and AAC audio in an FLV output for the RTMPS destination; confirm that this combination and the destination syntax work in your installed build. FFmpeg documents network protocols, including RTMP-related protocols, at its protocols reference.

Choose output resolution and frame rate deliberately, rather than assuming that the source clips all match. The -g value is a frame count, so calculate it from the output frame rate: a two-second keyframe interval is 60 frames at 30 fps or 120 frames at 60 fps. The bitrate and buffer placeholders also need real values suitable for the codec and output mode.

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

Stream copy or encode?

  • Stream copy: -c copy avoids decoding and re-encoding, so it is fast and does not introduce another lossy encoding step. It only fits compatible inputs and output requirements; it cannot apply filters and does not guarantee that the target container or YouTube ingest will accept every file unchanged.
  • Encoding: re-encoding lets you normalize output settings and is generally more appropriate for mixed inputs. It uses processing resources and can affect quality, so test the machine’s ability to sustain the chosen settings and inspect transitions.

Do not assume that looping the concat input guarantees gapless transitions. Test the playlist and output route with the actual files.

Configure YouTube Live and protect your stream key

  1. Open YouTube Live Control Room and create or select the live stream.
  2. Copy the server or ingest URL and stream key shown for that stream, then use them as the FFmpeg output destination. YouTube’s setup instructions are at Create a YouTube live stream with an encoder.
  3. Keep the stream key private. Treat it like a credential: do not publish it in examples, screenshots, public source repositories, or logs.
  4. Start FFmpeg and check whether a preview appears in Live Control Room. For a scheduled event, wait for the preview and select Go live when ready.

Check eligibility before troubleshooting the command: YouTube’s live-streaming getting-started guidance says a channel must be verified, have no live-streaming restriction in the previous 90 days, and be operated by someone at least 16 years old.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose YouTube settings and test before the event

YouTube’s published encoder guidance recommends RTMPS, constant bitrate (CBR), a two-second keyframe interval (not over four seconds), supported codecs, and a bitrate suited to the codec, resolution, and frame rate. Follow the row for your actual codec and output mode in YouTube’s encoder settings, bitrates, and resolutions; the figures below are YouTube recommendations, not guarantees of picture quality.

H.264 SDR output YouTube recommended bitrate YouTube minimum bitrate
1080p at 30 fps 5 Mbps 4 Mbps
1080p at 60 fps 17 Mbps 6 Mbps
720p at 30 fps 6 Mbps 3 Mbps
720p at 60 fps 8 Mbps 3 Mbps

YouTube publishes separate recommendations for AV1 and HEVC, so do not apply the H.264 figures to those codecs. For current settings, use the relevant codec row on YouTube’s page.

Before the stream matters, test the exact playlist and transitions. YouTube recommends leaving 20% upload-bandwidth headroom, previewing before going live, and monitoring audio and video continuously. Include movement and audio similar to the intended stream in your test. See YouTube’s streaming tips and YouTube live-streaming tips. A private or unlisted test can help you verify the setup without presenting the test as the event.

Troubleshoot common failures

Symptom What to check Practical fix
FFmpeg exits while opening the playlist Playlist syntax, path spelling, working directory, permissions, and whether each file opens. Correct the entries and test a short playlist before starting the full run.
Audio or video breaks at a clip boundary Stream layouts, codecs, parameters, time bases, and duration metadata. Normalize or transcode incompatible clips to a common profile; test each transition.
YouTube shows no preview Current stream’s ingest URL and key, channel eligibility, and FFmpeg output or error messages. Copy the destination details again from Live Control Room and verify eligibility before changing encoding options.
YouTube reports stream-health problems Codec, CBR, keyframe interval, bitrate for the selected mode, and available upload bandwidth. Align the output with YouTube’s current settings and leave bandwidth headroom.
The stream is live but unstable Upload capacity, system processing load, and whether the exact files and transitions were tested. Reduce the output demands if needed, monitor the stream, and repeat a test using the event playlist.
The order does not change after a loop -stream_loop -1 repeats the same playlist input. Generate a new shuffled playlist through a separate process between passes; test how the process handles transitions and gaps.

Or let it run in the cloud

If your goal is a YouTube channel that keeps uploaded videos playing while your computer is off, StreamNeo is an alternative to running FFmpeg on a local machine. Upload a recording or build a playlist, add your YouTube stream key once, and go live. StreamNeo loops uploaded videos from the cloud; it does not stream from a camera.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Nothing needs to stay on at home: the stream runs in the cloud.
  • Videos stream as uploaded, up to 4K 60fps, at one flat price per slot with no quality tiers.
  • StreamNeo automatically recovers if YouTube drops the stream.
  • The first day is free, with no card required; one free day is available per account.

The monthly option is $9.99 per month. See StreamNeo pricing for the available billing lengths and details. Start your free day with StreamNeo.

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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.