To stream local videos in random order to YouTube with FFmpeg, shuffle their filenames into a concat-demuxer playlist, then send that playlist to YouTube Live. FFmpeg plays the list in order; it does not randomize entries itself. Add -stream_loop -1 to repeat the same shuffled sequence, and use a common media profile when the clips are not compatible.
How the shuffled FFmpeg playlist works
The order is decided before FFmpeg starts: a script or shell command shuffles the file list, and the concat demuxer reads the resulting playlist sequentially. Looping that input repeats the same order. To get a new order on each pass, an external process must generate a new playlist and restart or otherwise orchestrate playback.
As an Amazon Associate I earn from qualifying purchases.
The concat demuxer is intended for files with matching streams, codecs, and time bases. Differences between files, including duration metadata, can cause gaps or artifacts at transitions. FFmpeg distinguishes joining compatible inputs with the concat demuxer from joining inputs that need re-encoding with the concat filter. See the FFmpeg concat demuxer documentation and the FFmpeg FAQ.
Prepare your videos and decide how to concatenate them
Inspect the files first
Check representative clips for video and audio codecs, resolution, frame rate, audio layout, and duration. A set of exports from one consistent workflow is more likely to fit the concat demuxer’s requirements than unrelated downloads or recordings. If the files differ, normalize them to a common profile before relying on a repeated live playlist.
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Choose stream copy or re-encoding
| Approach | When it fits | Trade-off |
|---|---|---|
Concat demuxer with -c copy |
Inputs have compatible streams and the output container accepts their encoded packets. | Fast and avoids re-encoding loss, but cannot apply filters and is not suitable for every set of files or target container. |
| Normalize clips, then encode or use the concat filter | Inputs vary or you need a consistent output profile. | More flexible, but uses processing resources and re-encoding can affect quality. Test transitions and resource use before relying on it. |
FFmpeg documents the stream-copy and transcoding distinction in its command-line documentation. Do not assume that a playlist that opens will produce clean transitions; inspect the actual output.
Create a shuffled concat playlist
Create a UTF-8 plain-text playlist with one file entry for each video, in the randomized order you want. For example, the file should have this shape, with real paths replacing the examples:
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
file '/absolute/path/video-a.mp4'
file '/absolute/path/video-b.mp4'
file '/absolute/path/video-c.mp4'
This is only a syntax example: the listed filenames must already be in the desired shuffled order. Use absolute paths to avoid confusion about which directory FFmpeg resolves relative paths from. Paths with quotes or unusual characters need appropriate escaping for concat-list syntax.
The exact shuffle command depends on your operating system and shell. For example, shuf is available in some Unix-like environments but is not a universal Windows command. Whatever method you use, verify the generated list before starting. The concat demuxer also has safe-path behavior; only relax safety restrictions when you trust the playlist and its paths.
Rank #3
- Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Send the playlist to YouTube Live with FFmpeg
Use this command as a template
The following is an illustrative template, not a tested, drop-in command. Replace every placeholder with values for your files, selected output profile, current YouTube ingest endpoint, and stream key. Confirm the options work with your installed FFmpeg build.
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>"
-rereads the input at its native rate for a real-time stream rather than sending the playlist as fast as possible.-stream_loop -1infinitely loops the playlist input, so the same generated order repeats.-f concat -i playlist.txttells FFmpeg to read the concat-demuxer list.-safe 0relaxes path restrictions; use it only for a playlist and files you trust.-c:v libx264and-c:a aacencode video and audio to common YouTube live codecs. Encoding uses CPU resources; the selected resolution and frame rate must match what you intend to send.-b:v,-maxrate, and-bufsizeneed values chosen for the output profile. Keep bitrate settings consistent with the codec and YouTube’s guidance.-gsets the GOP/keyframe interval in frames, so calculate it from frame rate. For a two-second interval, use 60 frames at 30 fps or 120 frames at 60 fps.- The output destination combines the server URL and key shown for your YouTube live stream. Use the endpoint YouTube gives you rather than copying a key or URL from someone else’s example.
For protocol and output details, consult FFmpeg’s protocol documentation as well as its command-line documentation. If you choose -c copy instead of encoding, the input streams and target output must be compatible; copy mode cannot normalize, filter, or repair mismatched clips.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Decide whether the order should change each time around
The command above loops the same playlist forever. It does not reshuffle when it reaches the end. A fresh random order for every pass requires a separate playlist-generation and process-orchestration step. Its design depends on your operating system and how you handle the transition between passes; test it rather than assuming a seamless handoff.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSet up YouTube Live and protect your stream key
- Confirm the channel is eligible to livestream. YouTube’s current getting-started guidance says a channel must be verified, have no live-streaming restriction in the past 90 days, and the user must be at least 16.
- Open YouTube Live Control Room and create or select a stream. Follow YouTube’s encoder setup instructions.
- Copy the server or ingest URL and stream key shown for that stream into the FFmpeg output destination. Keep the key private: do not put a real key in a public example, screenshot, source repository, or log.
- Start FFmpeg and check the Live Control Room preview. For a scheduled stream, wait for the preview and press Go live when the event is ready.
Choose settings and test the stream
YouTube’s published encoder guidance recommends RTMPS, constant bitrate (CBR), supported codecs, and a two-second keyframe interval, with an interval no longer than four seconds. Its settings depend on codec and output mode, so use the row for your actual codec rather than treating one bitrate as universal. YouTube’s current H.264 SDR table recommends the following video bitrates:
Best Value
- [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
- 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
- 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
- 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
- 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
| Output | YouTube-recommended bitrate | YouTube-listed minimum |
|---|---|---|
| 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 |
These are YouTube recommendations for H.264 SDR, not guarantees of stream quality. YouTube lists separate values for AV1 and HEVC. Check its current encoder settings, bitrate, and resolution page when choosing a profile.
- Leave upload-bandwidth headroom; YouTube recommends 20% above the stream’s bitrate.
- Preview before going live and continuously monitor audio, video, and stream health.
- Test the exact playlist, including clip boundaries, with motion and audio similar to the intended stream. A private or unlisted test may be appropriate before a public event.
See YouTube’s streaming tips and live streaming tips for preflight and monitoring guidance.
Troubleshoot common FFmpeg and YouTube problems
| Symptom | What to check and do |
|---|---|
| FFmpeg exits while opening the playlist | Check the concat-list syntax, path spelling, working directory, file permissions, and whether every listed file can be opened. Confirm paths with spaces or unusual characters are escaped correctly. |
| Video or audio breaks at a clip boundary | Compare the clips’ streams, codecs, parameters, time bases, and duration metadata. Normalize incompatible inputs or use a re-encoding approach, then test the transitions again. |
| YouTube shows no preview | Check that the ingest URL and stream key are the ones for the current Live Control Room stream. Confirm channel eligibility and inspect FFmpeg’s output and errors. |
| YouTube reports stream-health issues | Check codec, CBR configuration, keyframe interval, bitrate for the selected profile, and available upload bandwidth. |
| The stream starts but is unstable | Increase bandwidth headroom, monitor continuously, and test the complete playlist and transitions on the same connection before the event. |
| The sequence repeats without changing order | This is expected with -stream_loop -1: it repeats one playlist. Add external playlist generation and orchestration if each pass needs a new shuffle. |
Or let it run in the cloud
If the goal is to keep a prerecorded YouTube stream running without leaving your own computer on, StreamNeo runs uploaded videos from the cloud. Upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home; it streams the uploaded quality up to 4K 60fps at one flat price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly is $9.99 per month. StreamNeo is for prerecorded video sent to YouTube, not a camera feed. Start at StreamNeo’s free trial.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.




