To loop a video file into a YouTube Live broadcast from a Hetzner VPS, run FFmpeg with -re -stream_loop -1, then send its output to the RTMPS server URL and stream key shown in YouTube Live Control Room. The loop repeats the input; it does not keep the FFmpeg process, network connection, or YouTube broadcast alive by itself. The command below is a starting template, not a tested configuration for every file or server.
What you need before starting
- A YouTube channel that can create a live stream, plus access to Live Control Room.
- A video file on the VPS that FFmpeg can read.
- FFmpeg with the encoder you plan to use. For the example below, that means a build with
libx264. - A Hetzner VPS with enough CPU capacity to encode your video, if encoding is required, and adequate outbound network capacity for the selected bitrate. No specific Hetzner plan or server size is established here; benchmark the actual workload and check the provider’s current specifications.
Install FFmpeg from a trusted distribution source for your operating system, then check the installed build and available encoders before using the command. For example, ffmpeg -version shows build details; ffmpeg -encoders can help confirm encoder availability.
Create a YouTube stream and protect its key
- In YouTube Studio, open Live Control Room and create or select a stream.
- Copy the server URL and stream key displayed for that stream. Use the RTMPS URL where YouTube offers it: RTMPS is RTMP carried over TLS/SSL. YouTube notes that the interface may initially show ordinary RTMP; use its lock control to reveal the RTMPS URL if available. Follow the current RTMPS instructions and use the exact endpoint displayed rather than assuming a fixed URL.
- Treat the key as a credential. YouTube describes stream keys as like a stream’s password and address; do not publish one, commit it to a public repository, or leave it in a script that others can read. See YouTube’s stream-key guidance.
Run FFmpeg in a loop
Use this command shape, replacing the input path and RTMPS destination with your own values:
ffmpeg -re -stream_loop -1 -i /path/to/video.mp4
-c:v libx264 -preset veryfast -b:v 5000k -maxrate 5000k -bufsize 10000k
-g 60 -c:a aac -b:a 128k -f flv
'rtmps://<server-url-from-live-control-room>/<stream-key>'
-stream_loop -1 asks FFmpeg to repeat the input indefinitely; -re reads file input at its native rate, which is useful when live output packet timing matters. These options do not reconnect a failed process or guarantee a continuous YouTube event. See the FFmpeg manual.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors#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.
The example encodes video as H.264 and audio as AAC, then sends an FLV stream. YouTube’s current encoder guidance lists H.264, H.265 and AV1 video, AAC or MP3 audio, constant bitrate (CBR), and a 2-second keyframe interval recommendation with a 4-second maximum. The example is deliberately conventional; check YouTube’s current encoder settings and confirm your installed FFmpeg build supports the codecs you select.
Choose bitrate, keyframes and server capacity
Bitrate and network headroom
The example’s 5 Mbps video bitrate matches YouTube’s H.264 recommendation for 1080p at 30 fps. It is not a universal setting: resolution, frame rate, source complexity, audio bitrate and codec affect the appropriate output. YouTube advises leaving about 20% upload headroom above the combined primary and backup stream bitrate. Although a VPS sends traffic from the server rather than your home connection, its available outbound capacity and stability still matter. See encoder settings and streaming tips.
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.
If encoding taxes the VPS, reduce resolution, frame rate or bitrate, or choose a more capable server after benchmarking the actual file. Stream-copying with -c:v copy can avoid video re-encoding when the source codec, container and stream characteristics are compatible with YouTube and the output; it also means you cannot use the encoder settings in this example to change the video. Check the stream’s preview and health rather than assuming a copied source is suitable. The reviewed guidance does not establish which Hetzner server size can encode a given format.
Keyframe interval
For 30 fps, -g 60 requests a 60-frame GOP, or a 2-second interval. If the frame rate differs, adjust the GOP so the interval remains aligned with YouTube’s 2-second recommendation; do not exceed the 4-second maximum in its encoder guidance. A fixed GOP in frames does not represent the same duration at every frame rate.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.
Test the stream before relying on it
- Start with an unlisted stream so you can check the setup before making it public.
- Run FFmpeg and wait for incoming video to appear in Live Control Room’s preview. For a scheduled stream, YouTube’s encoder workflow says to click Go live after the preview arrives.
- Check stream health and watch the broadcast playback, including audio and video, before treating the setup as ready. YouTube recommends testing and monitoring quality; its streaming tips also address connection disruptions.
YouTube says streams under 12 hours are automatically archived in its encoder setup guidance. Do not infer that a looping input makes a YouTube event run forever: platform events, FFmpeg, and network connections have separate limits and failure modes.
Keep the process running and plan for failures
A shell session closing, a process crash, server maintenance, or a network interruption can stop a broadcast even while the input is set to loop. For a longer-running setup, run FFmpeg under an appropriate process supervisor and configure restart behavior and logs for your operating system. Test recovery deliberately; a restart may reconnect the encoder, but it does not ensure YouTube resumes the same live event without intervention.
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
The FFmpeg manual documents a FIFO muxer pattern that can attempt recovery after a temporary network outage. It is an optional technique, not a guarantee of uninterrupted service. Use it only after understanding its behavior and testing it with your FFmpeg build and YouTube workflow.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common problems
| Symptom | Likely checks and fixes |
|---|---|
| FFmpeg reports that an encoder is unavailable | Check ffmpeg -encoders and install or select a build that includes the chosen encoder, such as libx264. Alternatively, select an available compatible encoder and verify its settings. |
| Input file cannot be opened | Confirm the path is correct, the file exists on the VPS, and the user running FFmpeg has permission to read it. Test the file locally with FFmpeg before starting the live output. |
| No preview appears in Live Control Room | Confirm FFmpeg is still running, the stream URL and key match the selected YouTube stream, and the exact RTMPS destination from Live Control Room is being used. Check FFmpeg’s error output and YouTube’s stream-health panel. |
| Stream drops or health warnings appear | Check VPS outbound stability and capacity, CPU load, and whether the selected bitrate leaves the headroom YouTube recommends. Reduce the encoding workload or bitrate if needed, and configure supervision and logging to identify process exits. |
| Video or audio quality is wrong | Check source frame rate, resolution, audio presence and chosen output settings. Inspect the preview and a watch-page playback; adjust encoder settings to YouTube’s guidance rather than assuming the example fits every source. |
The stream ends despite -stream_loop -1 |
The option loops the input only. Check whether FFmpeg exited, the connection failed, the server restarted, or YouTube ended the event. Review logs and Live Control Room; arrange process recovery separately from input looping. |
Or let it run in the cloud
If maintaining a VPS and FFmpeg process is more work than you want, StreamNeo keeps an uploaded video or playlist streaming to YouTube from the cloud: upload the video, add your YouTube stream key, and go live. Nothing has to stay on at home; it streams your upload at its original quality up to 4K 60fps for one flat price per slot, and it can recover automatically if YouTube drops the stream. The first day is free with no card. The Monthly price is $9.99 per month. Start your free day with StreamNeo.
Quick Recap
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.
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.




