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

How to Loop a Video into YouTube Live Nonstop with FFmpeg

Use FFmpeg’s infinite input loop with real-time reading, then match YouTube’s ingest settings and test stream health before relying on a nonstop broadcast.

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

To loop a video file into YouTube Live with FFmpeg, put -stream_loop -1 before the input, use -re to send the file at real-time speed, and publish to the RTMPS URL and stream key from YouTube Live Control Room. The command below is a starting template, not a tested configuration for every file or FFmpeg build; test it and watch YouTube’s stream-health panel before relying on it unattended.

Use this FFmpeg loop command as a starting point

ffmpeg 
  -stream_loop -1 -re -i input.mp4 
  -c:v libx264 -pix_fmt yuv420p -r 30 -g 60 
  -b:v 5M -maxrate 5M -bufsize 10M 
  -c:a aac -b:a 128k -ar 44100 
  -f flv 'rtmps://<server>/<stream-key>'

Replace input.mp4 with your file and the destination with the RTMPS URL and stream key shown for your stream in YouTube Live Control Room. Do not put a real stream key in a public script or share it: it functions like a stream password.

The loop option belongs before the input it applies to: -stream_loop -1 -re -i input.mp4. A value of -1 requests infinite looping; -re reads the file at its native rate rather than sending it as fast as FFmpeg can process it. This ordering is shown in a 2022 FFmpeg-user example, not verified here against every build. Check your installed FFmpeg options and test with your actual file.

The example targets H.264 at 1080p30 with a 5 Mbps video bitrate and a 60-frame GOP. That bitrate is YouTube’s current recommendation for H.264 at 1080p30, and a 60-frame GOP at 30 fps is two seconds if the encoder honors the requested frame rate. These are not universal settings: adjust them to the video, intended output and YouTube’s guidance for the selected codec, resolution and frame rate.

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.

Set up YouTube Live and protect the stream key

  1. In YouTube Studio, open Live Control Room and create or select the stream you intend to use. Copy its stream URL and stream key into your local FFmpeg configuration. Follow YouTube’s encoder setup instructions.
  2. Use the secure RTMPS destination when your encoder supports it. YouTube says RTMPS is RTMP over TLS/SSL and recommends it for encrypted transport. If Live Control Room initially displays an RTMP URL, use the lock control to reveal the RTMPS URL. See YouTube’s RTMPS guidance.
  3. Keep the key out of public repositories, screenshots, logs you share, and published command examples. If it is exposed, replace or reset it in YouTube Studio before using the stream again.

Match the video and audio settings to the source

Video codec, resolution and frame rate

YouTube lists H.264, H.265/HEVC and AV1 for encoder streams, with frame rates up to 60 fps. The sample command uses H.264, 30 fps and a conventional pixel format. Do not assume those options preserve the file’s original quality or match every source; the command re-encodes video. Choose the target settings and corresponding bitrate from YouTube’s encoder settings and bitrate recommendations.

Keyframes and bitrate

YouTube recommends a two-second keyframe interval and says not to exceed four seconds. At 30 fps, -g 60 requests a 60-frame GOP, or two seconds when the output really is 30 fps. YouTube recommends 5 Mbps for H.264 at 1080p30; other codecs, frame rates and resolutions have different recommendations. The upload connection must sustain the chosen bitrate, with room for normal variation.

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.

The example sets -b:v 5M and -maxrate 5M with -bufsize 10M. It does not explicitly request constant-bitrate rate control, so do not treat these flags alone as proof the output follows YouTube’s CBR recommendation. Check the options supported by your installed encoder and verify the resulting stream in Live Control Room. YouTube also recommends progressive video, square pixels, and Rec. 709 for SDR.

Audio

The example encodes AAC stereo audio at 128 Kbps and 44.1 kHz, matching YouTube’s listed audio guidance. If the input has no audio, or its audio stream needs different treatment, adapt the command rather than assuming this example fits. YouTube lists AAC or MP3 audio.

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.

Choose between re-encoding and stream copy

The sample re-encodes the video with libx264 and audio with AAC, which can make the output match the chosen settings but requires processing resources. If the input streams already match YouTube’s selected ingest requirements, stream copy may reduce CPU use; it does not make incompatible media compatible. Whether a particular file can be copied reliably across the loop boundary is not established by the available documentation, so inspect the streams and test the exact command. Encoder availability and option names depend on how FFmpeg was built.

Test before leaving the stream unattended

  1. Check your FFmpeg build’s help and available encoders, and inspect the input file’s streams before choosing codecs or copy mode. This command is illustrative, not a verified command for a specific build or file.
  2. Start an unlisted or otherwise appropriate test stream. Confirm that YouTube receives both picture and audio, that the file loops as intended, and that playback remains stable.
  3. Watch YouTube’s stream-health indicators and messages while testing. A running FFmpeg process does not by itself prove that YouTube is receiving a healthy stream.
  4. Observe a loop boundary and test the duration you actually need. File characteristics, encoding load, network availability, ingest health, account settings and operator actions can all affect continuity.

YouTube recommends testing before going live and monitoring stream health. YouTube’s setup page says streams under 12 hours are automatically archived. That statement does not establish that a broadcast lasting longer than 12 hours will be archived as one complete video, so plan separately if you need a complete recording.

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 an option or encoder: The available options and encoders depend on the installed build. Check that build’s help and encoder list, then use supported names and settings.
  • YouTube does not receive the stream: Check that the destination uses the current URL and key for the selected stream. If using RTMPS, verify that you copied the secure URL shown in Live Control Room rather than an RTMP URL.
  • Video arrives but settings or quality are wrong: Recheck the output codec, resolution, frame rate, pixel format and bitrate against the source and YouTube’s guidance. A bitrate of 5 Mbps applies to the cited H.264 1080p30 recommendation, not every format.
  • Audio is missing or unsuitable: Confirm the input contains an audio stream and that the output audio codec and parameters are appropriate. YouTube lists AAC or MP3 and gives 44.1 kHz, 128 Kbps stereo guidance.
  • The loop runs but the public stream is interrupted: A successful repeat of the file does not guarantee an uninterrupted YouTube broadcast. Check FFmpeg output, network conditions and YouTube’s stream-health messages; test the same file and settings for the intended duration.

Or let it run in the cloud

If you want a prerecorded video to keep a YouTube channel live without leaving a computer or home connection on, StreamNeo runs the loop in the cloud. Upload a recording or build a playlist, add your YouTube stream key once, and go live. It plays uploaded videos; it does not broadcast from a camera.

  • Nothing has to stay powered on at home; StreamNeo automatically recovers if YouTube drops the stream.
  • Your uploaded quality streams as made, up to 4K 60fps, at one flat price per slot; there are no quality tiers.
  • The first day is free with no card required. Each slot includes one always-on stream, 10 GB storage pooled across active slots, looping and playlists, and team support.

Monthly service is $9.99 per month. Start your free StreamNeo 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.

Frequently Asked Questions

Does -stream_loop -1 loop forever?

It requests infinite looping of the input; it does not guarantee that the encoder, network or YouTube stream will remain uninterrupted.

Will this command archive a stream longer than 12 hours as one video?

YouTube documents automatic archiving for streams under 12 hours; its cited setup guidance does not establish the outcome for longer broadcasts.

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 *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.