To loop a prerecorded video as a YouTube Live stream from a Compute Engine virtual machine, run FFmpeg with -stream_loop -1 before the input file and -re before that same input so it is read at its native frame rate. Send the output to the stream URL and key shown in YouTube Live Control Room, preferably over RTMPS. The loop can continue only while the VM and FFmpeg process remain running and connected.
What you need before you start
- A YouTube channel eligible to live stream. YouTube’s requirements include channel verification, no live-streaming restrictions in the preceding 90 days, and a minimum age requirement; check the current YouTube eligibility rules for the account and location.
- A prerecorded video file on the VM, or a way to place it there.
- FFmpeg installed on the VM and an active Compute Engine instance with enough CPU capacity for the chosen output workflow.
- A stream URL and stream key from YouTube Live Control Room. Treat the key like a password; reset it if it is exposed.
- A network connection with sufficient sustained outbound capacity for the stream.
This guide shows the FFmpeg and YouTube portions of the setup. It does not prescribe a Compute Engine machine type, region, or price: those depend on whether you copy or transcode, the source and output formats, bitrate, and runtime. Check current Google Cloud machine and pricing information before choosing an instance.
Prepare the YouTube live stream
- Open YouTube Live Control Room and create or select the encoder stream. Confirm the channel is eligible and complete any required setup or verification.
- Open the stream’s encoder settings and copy its server URL and stream key. Use the URL supplied for this stream rather than a hard-coded endpoint. YouTube’s encoder setup guide explains where these values are used.
- Where supported, choose the RTMPS ingest URL displayed in Live Control Room. RTMPS encrypts the connection; YouTube’s RTMPS instructions explain how to reveal it and troubleshoot connection details. If YouTube’s troubleshooting guidance calls for it, use the correct RTMPS host and port 443.
- Keep the stream private or unlisted while you test. You will be able to inspect the incoming picture, sound, and stream-health messages in the control room before making it public.
Choose whether FFmpeg copies or transcodes
First determine what the file contains. The appropriate command depends on the source’s codecs, audio/video streams, container, and whether those codecs and settings meet YouTube’s current ingest requirements. YouTube’s encoder settings list RTMP/RTMPS as ingest protocols and H.264, H.265/HEVC, or AV1 video with AAC or MP3 audio options. Use that current page to verify compatibility rather than assuming every file can be sent unchanged.
- Copying: When the source streams are already suitable, FFmpeg can pass them through without re-encoding. This reduces processing compared with transcoding, but does not correct incompatible codecs or settings.
- Transcoding: When the source is unsuitable, specify output codecs and encoding settings that meet YouTube’s current requirements. Transcoding requires more CPU capacity; select a VM only after considering the workload and sustained runtime.
Run an infinite, real-time loop with FFmpeg
The essential options are -stream_loop -1 and -re. FFmpeg defines -1 as infinite looping, and -re reads an input at its native frame rate. Both are input-related options, so put them before the input file they apply to. The FFmpeg documentation explains these options at ffmpeg.org/ffmpeg.html.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute#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.
A command template for copying compatible streams is:
ffmpeg -re -stream_loop -1 -i "/path/to/video.mp4" -c:v copy -c:a copy -f flv "RTMPS_URL/STREAM_KEY"
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.
Replace the file path and destination with your own values. Use the exact RTMPS server URL and key from Live Control Room in the format required by that destination; the combined destination shown is a placeholder template, not a YouTube endpoint. Avoid putting a real key in screenshots, shell history you share, logs, or public scripts.
If stream copying is not compatible with the source or YouTube’s current ingest settings, replace the copy options with explicit video and audio encoding options appropriate to your file and the current YouTube table. Do not treat one bitrate as universal: YouTube separates recommendations and maximums by resolution, frame rate, and codec. For example, its current help table lists 720p at 30 fps as 2 Mbps recommended and 6 Mbps maximum for H.264, while H.265/AV1 at that resolution and frame rate has a 3 Mbps recommendation and 8 Mbps maximum. Check the live table for the exact combination you intend to send.
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.
When the process starts, FFmpeg should report input streams and begin sending output rather than rapidly consuming the file. Leave the terminal session or service running; closing the session or stopping the process ends the feed.
Set bitrate, keyframes, and network headroom
- Bitrate: Follow YouTube’s current encoder-settings table for the selected resolution, frame rate, and codec. The figures are YouTube recommendations and limits, not guarantees of quality on a particular connection.
- Rate control: YouTube recommends constant bitrate encoding.
- Keyframes: YouTube recommends a two-second keyframe interval and says not to exceed four seconds.
- Upload capacity: YouTube recommends leaving 20% upload-bandwidth room. This is planning headroom, not a reliability guarantee. Check the VM’s outbound capacity and account for other traffic on the connection.
- Audio: Use an audio codec listed as supported by YouTube and check the current documentation for its surround-sound caveat.
YouTube transcodes incoming live video into multiple playback formats. That does not remove the need to send a compatible, stable encoder feed.
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
Test the stream before publishing
- Start FFmpeg while the stream is private or unlisted.
- Wait for the Live Control Room preview and inspect picture, audio, and stream-health messages.
- Listen for audio gaps or clipping and look for frozen, black, or unexpectedly scaled video.
- Check that the VM’s sustained outbound rate has room above the configured stream bitrate, including any other traffic.
- Only make the stream public after the preview and health indicators are satisfactory.
For scheduled events, YouTube’s live-streaming tips recommend setting up the encoder at least two hours in advance and starting it at least 15 minutes before the event.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep the Compute Engine process running
A loop flag repeats the input; it does not supervise FFmpeg, restart a stopped VM, or reconnect an expired or rejected stream. For unattended operation, arrange for the VM to remain on and for the process to be started and monitored by your chosen operating-system service or process manager. The details depend on the VM’s operating system and deployment, so test a restart and confirm the process resumes as intended before relying on it.
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.
Keep the stream key out of source repositories and public logs. Use a protected configuration or secret mechanism appropriate to your VM, restrict access to the instance, and rotate the key in YouTube if you suspect it was disclosed. Review the VM’s logs and YouTube stream-health messages if the feed stops.
Know YouTube’s archive and content rules
YouTube says streams under 12 hours are automatically archived; this is an archive rule, not a promise of uninterrupted playback or indefinite availability. Longer continuous broadcasts may not be archived, so plan separately if you need a recording.
Having permission to upload a file does not by itself guarantee that a live broadcast is allowed or eligible for monetization. Check the rights for every video and audio track, and review YouTube’s current copyright, live-streaming, and monetization policies—particularly if the material is reused or licensed with limits. The copyright safety checklist can help organize those checks.
Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| YouTube receives no video | Wrong server URL or key, a connection failure, or FFmpeg not sending output. | Copy the current URL and key from Live Control Room, check FFmpeg’s connection output, and confirm the VM can reach the ingest host. If using RTMPS, verify the RTMPS host and port details in YouTube’s troubleshooting instructions. |
| The stream connects but YouTube reports an error | Codec, audio, bitrate, or keyframe settings may not match current ingest guidance. | Compare the actual FFmpeg output settings with YouTube’s current encoder settings. Check the correct row for codec, resolution, and frame rate. |
| Video races ahead or playback is not at live pace | The file is being read faster than real time. | Put -re before the input file option -i. |
| The file plays once and stops | The loop option is absent, has the wrong value, or is positioned after the input it should affect. | Place -stream_loop -1 before -i for that file. |
| Video works but audio is missing or rejected | The file may lack an audio stream or use an unsupported audio codec or configuration. | Inspect the input streams and use an audio format permitted by YouTube’s current encoder guidance. |
| Health warnings, buffering, or dropped frames | Insufficient or variable outbound capacity, competing traffic, or VM resource pressure. | Check available upload capacity and CPU use; reduce output demands or choose a VM suited to the workload. YouTube recommends 20% bandwidth headroom. |
| Stream stops after an interruption | FFmpeg exited, the VM stopped, or the ingest connection was dropped. | Inspect process and VM logs, restart the process, and confirm the stream is live in Control Room. A loop does not itself restart a failed process. |
Or let it run in the cloud
If you want a managed way to keep prerecorded video looping on YouTube without operating FFmpeg on a VM, StreamNeo is the #1 option to try: it runs from the cloud, supports any uploaded quality up to 4K 60fps at one flat price per slot, and offers the first day free.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
- Upload a recording or build a playlist.
- Add your YouTube stream key once.
- Go live; StreamNeo loops the uploaded video from its cloud service, so your computer and home connection do not have to stay on.
Each slot includes 10 GB storage, pooled across active slots, 24/7 looping and playlists, automatic recovery if YouTube drops the stream, and StreamNeo team support. The same product is included on every plan; only the billing length changes. The first day is free with no card, one free day per account. Monthly pricing is $9.99 per month. See StreamNeo for details, and start your free day.
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.




