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

You can loop a prerecorded video to YouTube Live from a Raspberry Pi with FFmpeg: create a YouTube live event, copy its server URL and stream key into an FFmpeg command, then run the file as a realtime stream. The Pi must stay powered and connected while it streams, and its ability to encode the video depends on the Pi model, FFmpeg build, source file, and network. Test the intended video before relying on it for a long broadcast.

What you need before you start

  • A YouTube channel with live streaming enabled. YouTube says first-time activation can take up to 24 hours. YouTube’s encoder setup guide explains the activation and event workflow.
  • A Raspberry Pi with a working internet connection and enough upload capacity for the stream. The sources do not establish a universal Pi model, bandwidth threshold, or guaranteed resolution.
  • A video file accessible to the Pi, plus an installed FFmpeg build that can read the file, encode the selected video and audio formats, and send RTMPS output.
  • A YouTube event’s server URL and stream key. Treat the key like a password: do not publish it, include it in screenshots, or share it in a public script repository.

FFmpeg may need to decode and re-encode your file, which can put more load on the Pi than passing through a compatible stream. Check the installed FFmpeg capabilities and test CPU load, temperature, dropped frames, and YouTube stream health before scheduling a long run.

Create a YouTube Live event and get its stream details

  1. In YouTube Studio, open Live Control Room and create a stream or schedule one. If live streaming has not been enabled on the channel before, allow for YouTube’s stated activation delay of up to 24 hours.
  2. Open the event’s streaming settings and copy the server URL and stream key exactly as shown. YouTube’s interface and available settings can change, so follow the current event page rather than reusing an old key or URL.
  3. Keep the event open in Live Control Room so you can watch its preview and stream health after FFmpeg connects. YouTube’s setup guide describes starting the broadcast by having the encoder send content and stopping it by stopping the encoder.

Prepare and test an FFmpeg command

This illustrative command reads a file at its normal playback rate, loops it indefinitely, encodes H.264 video and AAC audio, and sends an RTMPS output. Replace the example file path, server URL, and key with your own values. It is a starting point, not a tested Raspberry Pi command or a universal compatibility guarantee.

ffmpeg -re -stream_loop -1 -i "/path/to/video.mp4" 
  -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k 
  -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -ar 44100 
  -f flv "rtmps://YOUR_SERVER_URL/YOUR_STREAM_KEY"

FFmpeg documents -re for reading input at its native rate for realtime output and -stream_loop -1 for infinite looping. Put both options before the input’s -i. Remove -stream_loop -1 if you want the stream to stop when the file ends. Check the FFmpeg documentation and the installed build’s supported encoders and protocols; a build that lacks the needed RTMPS or encoder support will not run this example as written.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

What the example settings mean

  • -c:v libx264 selects software H.264 encoding. It may be too demanding at the source resolution or frame rate on some Pi setups; verify actual load and output rather than assuming every model can handle it.
  • -b:v, -maxrate, and -bufsize are example video rate-control values, not YouTube requirements. Choose settings that your network can sustain and that match the content and chosen resolution.
  • -g 60 sets a 60-frame GOP in this example. YouTube recommends a two-second keyframe frequency and says not to exceed four seconds; because the example does not specify a frame rate, adjust the GOP to match the actual output frame rate and target interval.
  • -c:a aac -b:a 128k -ar 44100 requests AAC audio at the example bitrate and sample rate. Confirm the source has usable audio and listen to the YouTube preview.
  • -f flv selects the output container commonly used for RTMP-family ingest. Use the RTMPS server address YouTube supplies and verify protocol support in your FFmpeg build.

YouTube’s current encoder guidance lists H.264, H.265/HEVC, and AV1 video options, AAC or MP3 audio, CBR, RTMPS, and a recommended two-second keyframe frequency with a four-second maximum. Supported choices in YouTube’s guidance do not guarantee your installed FFmpeg build or Pi can encode them. Check YouTube’s encoder settings, bitrates, and resolutions against your actual output and available encoder.

Run a representative preflight test

  1. Start the command with the same file type, motion, audio, resolution, and frame rate you expect to use. YouTube recommends testing with audio and movement similar to the planned broadcast.
  2. Check FFmpeg’s output for encoder errors, reconnects, or dropped frames, and watch the event preview and stream health in Live Control Room.
  3. Observe the Pi’s CPU load and temperature during the test. If it struggles, try a lower resolution or frame rate, or use a compatible hardware encoder only after verifying its name and behavior on that system.
  4. Check the upload connection over a meaningful period. A brief successful test cannot rule out later packet loss, network interruption, power loss, or thermal problems.

A community Raspberry Pi project, YouTube-Pi4-StreamMachine, reports using 854×480 at 30 fps to stabilize ingest on a jittery uplink. That is one project’s configuration, not a universal minimum, recommended setting, or performance guarantee for other Pi models and networks.

Rank #2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
  • Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized

Keep the broadcast running and end it safely

For a looping broadcast, leave FFmpeg running and prevent the Pi from losing power or network access. The Pi is the encoder, so local failures can stop the feed. YouTube says streams shorter than 12 hours are automatically archived after the encoder stops sending; do not assume a single continuous event becomes a permanent archive beyond that documented limit. See YouTube’s live stream setup and archive guidance for current platform behavior.

To end the encoder, stop the FFmpeg process. Confirm the event has stopped in Live Control Room. If you intended to broadcast only once, remove the loop option on the next run so playback ends with the file.

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.
Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit

Troubleshooting

  • YouTube does not show an incoming stream: Check that the event is the one you intended, the server URL and key were copied exactly, the key has not been changed, and FFmpeg supports RTMPS output. Keep the key private while checking it.
  • FFmpeg rejects the input or encoder: The installed build may not support the source codec, selected encoder, or output protocol. Inspect the build’s available capabilities and use a supported combination; a file that cannot be decoded by that build cannot be streamed by this command.
  • The Pi drops frames or the stream becomes unstable: Encoding load, network jitter, packet loss, or thermal behavior may be contributing. Test at a lower resolution or frame rate, check CPU and temperature, and inspect YouTube’s stream-health messages. No particular setting guarantees stability across Pi models.
  • Video plays but audio is missing or wrong: Confirm the source contains the intended audio track and that FFmpeg’s selected audio encoder is available. Listen to the preview before leaving the stream unattended.
  • The video stops at the end: Put -stream_loop -1 before -i for infinite looping. Without it, FFmpeg reaches the end of the file and stops reading it.
  • The stream key may have been exposed: Replace or reset it in YouTube’s event settings, then update the command with the new key. Do not leave a working key in a publicly accessible file or terminal screenshot.
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 the Pi’s power, network, or encoding capacity is a concern, StreamNeo is a cloud service for keeping a prerecorded YouTube stream running. Upload your video, add your YouTube stream key, and go live. Nothing has to stay on at home; it loops uploaded video, supports any uploaded quality up to 4K 60fps at one flat price per slot, and automatically recovers if YouTube drops the stream. The first day is free with no card, one free day per account. Monthly billing is $9.99 per month. StreamNeo is for YouTube streams, not camera broadcasts.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$419.99
Bestseller No. 3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit
$189.99
Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
  • 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
  • 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
  • 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
  • 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
Rank #4
SANOOV Raspberry Pi 5 4GB Kit, 4GB RAM Single Board Computer with Active Cooler and ABS Case, Complete Raspberry Pi 5 Starter Kit for IoT Robotics Retro Gaming
  • All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
  • Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
  • Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
  • Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
  • Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online

See StreamNeo or start the free first 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.