October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
FFmpeg

How to Loop Videos on a Raspberry Pi and Stream Them to YouTube

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To loop a prerecorded video from a Raspberry Pi into YouTube Live, use FFmpeg to read the file repeatedly and send it to the YouTube ingest server with the broadcast’s stream key. Set the output to match your Pi’s encoding capability and upload connection, configure YouTube’s current encoder settings, then test and monitor stream health. VLC can preview or play a file locally, but file playback alone does not send a live stream to YouTube.

What you need to set up

  • A prerecorded video file available on the Raspberry Pi.
  • FFmpeg for looping the file and sending an encoded stream to YouTube.
  • A YouTube channel with a live broadcast configured in Live Control Room.
  • The broadcast’s server URL and stream key, which you must keep private.
  • A network connection with upload capacity that can sustain the selected stream bitrate.

This is a file-based workflow, not a camera stream. Raspberry Pi’s rpicam-vid camera-streaming guide covers a different source path.

Configure a YouTube Live broadcast

  1. In YouTube Live Control Room, create or select the broadcast you intend to run.
  2. Copy the server URL and stream key shown for that broadcast. YouTube’s encoder instructions require both in the streaming software; do not share the key or publish it in scripts, screenshots, or logs.
  3. Choose an ingest protocol and encoder settings the Pi can actually sustain. YouTube recommends RTMPS, a secure extension to RTMP. Its current settings guidance lists H.264, H.265/HEVC, and AV1 video options, up to 60 fps, and AAC or MP3 audio. Check the specific broadcast’s Live Control Room and your encoder’s support before selecting a codec or protocol.

YouTube recommends constant bitrate encoding, a two-second keyframe frequency, and says the interval should not exceed four seconds. Follow the settings offered for your broadcast; the published supported options do not establish that every Raspberry Pi can encode every listed codec or quality in real time. YouTube’s encoder setup instructions and live encoder settings guidance are the references to check for current options.

Loop the file and send it with FFmpeg

FFmpeg documents -stream_loop -1 as infinite input looping. The -re input option reads at the file’s native rate and is commonly appropriate when sending a file as a live-paced source. The command below shows the workflow, not a guaranteed copy-and-run configuration: replace the placeholders and select codecs, bitrate, resolution, and audio handling that suit the file, Pi, connection, and YouTube broadcast.

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.
ffmpeg -re -stream_loop -1 -i input.mp4  -f flv "rtmps://<YouTube-ingest>/<stream-key>"
  • input.mp4 is the local prerecorded file; use its actual path and filename.
  • is where you set the output codecs, bitrate, frame rate, resolution, and any necessary audio settings. The exact settings depend on your source and the Pi; no specific model or maximum quality is established here.
  • Use the server URL and stream key provided for the broadcast, following the format supported by your encoder and YouTube. Treat the key as a password.
  • -f flv selects the output container commonly used in this RTMP-style workflow. Confirm protocol and format compatibility for the encoder configuration you choose.

FFmpeg’s command-line documentation defines the loop option and other command behavior. Before relying on a long-running stream, test the exact command and settings on the specific Pi and file.

Choose settings the Pi and connection can sustain

  • Resolution and frame rate: Start with a setting appropriate for the source file and the board’s real-time encoding capability. YouTube lists support up to 60 fps, but that is not a promise that a particular Pi can encode at that rate.
  • Video codec: Select a codec supported by both the chosen FFmpeg build and YouTube’s ingest settings. H.264, H.265/HEVC, and AV1 appear in YouTube’s current options; do not assume the Pi can encode each one adequately.
  • Bitrate: Use constant bitrate as YouTube recommends, and make sure measured upload capacity can sustain the outgoing bitrate. Leave headroom for network variation rather than setting output equal to the connection’s best-case speed.
  • Keyframes: Set a two-second keyframe interval if available; do not exceed four seconds per YouTube’s guidance.
  • Audio: Confirm the file has the audio you expect and use an audio codec accepted for the broadcast, such as AAC or MP3 in YouTube’s listed options.
  • Protocol: Prefer RTMPS where the encoder and broadcast configuration support it.

Preview or play the file locally with VLC

VLC is useful for checking whether the file plays and its sound is correct, but it is not a substitute for the FFmpeg file-looping and live-output step above. Raspberry Pi says VLC is included in Raspberry Pi OS Full, supports many popular media formats, and uses hardware acceleration in Raspberry Pi OS. Its documentation also describes command-line and fullscreen playback.

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.

Raspberry Pi OS Lite does not include VLC by default. Raspberry Pi documents vlc-bin and vlc-plugin-base as the headless playback packages. Check the Raspberry Pi OS audio and video documentation for the playback details relevant to your edition.

Test before leaving the stream running

  1. Run the FFmpeg command with the intended file and settings while watching YouTube Live Control Room for an incoming signal.
  2. Check that both video and audio arrive, and that movement and sound resemble the content you plan to stream.
  3. Check upload speed and YouTube’s stream-health indicators and status messages. If the stream is unstable, lower the bitrate or output demands and test again.
  4. Confirm that the loop returns cleanly to the beginning of the file and that playback remains synchronized over time.
  5. Only rely on the setup after a representative test on the same Pi, network, and encoding settings you intend to use.

YouTube says streams shorter than 12 hours are automatically archived. Do not assume the same behavior for a stream that runs longer; consult the current YouTube guidance for the broadcast you plan.

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.

Common problems and fixes

  • YouTube never detects the stream: Check that the server URL and stream key belong to the selected broadcast, that the key has not been altered, and that the chosen protocol matches the encoder configuration.
  • Stream health warns about bitrate or connection: Verify actual upload capacity, reduce the output bitrate or resolution, and retest. A nominal internet speed does not guarantee stable sustained upload.
  • The Pi drops frames or cannot keep up: Reduce encoding demands—such as resolution, frame rate, or codec complexity—and test again. There is no guaranteed maximum quality for every Pi model in the available platform guidance.
  • There is no audio or the wrong audio plays: Preview the file locally, check that FFmpeg is including the intended audio stream, and confirm the output audio codec is accepted by YouTube.
  • The video plays once and stops: Confirm that -stream_loop -1 is placed as an input option before -i for the file being looped.
  • A camera workflow guide does not match these steps: That guide handles camera-originated video. For an existing recording, use the file input and looping workflow rather than a camera capture command.

Copyright and YouTube policy checks

Looping a file does not change whether you have the rights to its video or audio. Before streaming, confirm you have permission to use all included material and review YouTube’s applicable copyright and live-stream rules. Repeating a recording also does not by itself establish eligibility for monetization; assess the channel and content against YouTube’s current policies rather than assuming that continuous playback qualifies.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or let it run in the cloud

If you want the YouTube stream to continue without keeping a Raspberry Pi or other computer running at home, StreamNeo is a cloud service for looping uploaded videos on YouTube. The setup is three steps: upload a recording or build a playlist, add your YouTube stream key once, and go live. It does not stream from a camera or to other platforms.

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.
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
  • Nothing has to stay powered on at home; StreamNeo loops the uploaded video from the cloud.
  • Each slot streams the upload as made, up to 4K 60fps, at one price per slot without re-encoding or quality tiers.
  • It automatically recovers if YouTube drops the stream.
  • The first day is free with no card, one free day per account.
  • Monthly: $9.99 per month.

Start your free StreamNeo day.

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.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair 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.