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

To loop a prerecorded video on YouTube Live from a Raspberry Pi, use FFmpeg with -stream_loop -1 before the input file, pace playback with -re, and send the output to the RTMPS server URL and stream key shown in YouTube Studio. The command below is a starting point: stream-copy works only when the file’s codecs and streams are compatible, so test the exact Pi, file, and network before relying on a long broadcast.

What you need before you start

  • A Raspberry Pi running an operating system with FFmpeg installed. Run ffmpeg -version to check the installed build and its available options.
  • A prerecorded video file accessible to the Pi. For the simplest low-CPU workflow, use a file whose video and audio streams can be copied into the FLV output without conversion.
  • A YouTube channel that can start a live stream, plus its ingest server URL and stream key from YouTube Studio.
  • A stable internet connection with sufficient measured upload capacity for the bitrate you plan to send.

The Pi model matters most if you need to transcode. Stream-copy avoids video encoding, but it does not correct an incompatible source or guarantee that every Pi can encode a chosen resolution and frame rate. Raspberry Pi’s official Picamera2 manual covers the current camera stack and headless operation; it does not establish a universal FFmpeg file-streaming performance guarantee for every board. Raspberry Pi Picamera2 manual.

Get the YouTube Live stream URL and key

  1. In YouTube Studio, select Create → Go Live.
  2. Create or select the stream and locate the server URL and stream key in the stream’s settings.
  3. Copy both values for FFmpeg. Treat the stream key like a password: anyone who has it may be able to send video to your channel’s ingest endpoint.
  4. Prefer RTMPS if YouTube Studio provides it. YouTube recommends RTMPS as the secure extension of RTMP. YouTube encoder settings.

YouTube’s workflow is to enter the URL and key in the encoder, start the encoder, then check the preview and stream health in Live Control Room. Depending on the scheduled-stream workflow, you may need to start the broadcast there after the encoder preview is ready. YouTube live streaming setup.

Try a loop with FFmpeg

For a compatible MP4 with supported video and audio streams, use this command shape, replacing the file path, ingest URL, and key with your own values:

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
ffmpeg -re -stream_loop -1 -i "input.mp4" 
  -c:v copy -c:a copy -f flv "<YouTube RTMPS ingest URL>/<STREAM_KEY>"

Keep the RTMPS URL and key exactly as YouTube supplies them; some interfaces provide them as separate fields, while this command form combines the server URL and key. Do not paste a real stream key into a public script, screenshot, or forum post.

What the options do

  • -re reads the file at its native media rate instead of sending it as fast as the Pi can read it. For a file-based live stream, this helps keep output paced like playback.
  • -stream_loop -1 repeats the input indefinitely. Place it before the corresponding -i.
  • -i "input.mp4" selects the source file.
  • -c:v copy -c:a copy copies the video and audio streams instead of re-encoding them. This reduces encoding work but only succeeds if the streams and container assumptions are suitable for the chosen output.
  • -f flv selects the FLV output format commonly used for RTMP-family ingest.

FFmpeg documents stream-copy and encoding as distinct output behaviors. If this command errors, produces no audio, or is rejected by YouTube, inspect the source codecs and timestamps and test a compatible file before changing settings. The installed build can affect available options and encoders; confirm against its documentation. FFmpeg documentation.

Rank #2
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (4GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (4GB 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
  • CanaKit Mega Heat Sink - Black Anodized

Choose settings YouTube and the Pi can sustain

YouTube’s encoder guidance lists H.264, H.265 (HEVC), or AV1 video for RTMP/RTMPS, frame rates up to 60 fps, constant bitrate encoding, and a recommended two-second keyframe interval that should not exceed four seconds. It lists AAC or MP3 audio and 128 kbps for stereo AAC/MP3. YouTube encoder settings.

The published H.264 bitrate guidance below is YouTube’s recommendation, accessed in 2026. These figures are platform guidance, not a guarantee that a particular Pi, source file, or connection can sustain them.

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
Output YouTube H.264 bitrate guidance
720p at 30 fps 3 Mbps minimum; 8 Mbps recommended
1080p at 30 fps 5 Mbps minimum; 14 Mbps recommended
1080p at 60 fps 6 Mbps minimum; 17 Mbps recommended

With stream-copy, the file’s existing video properties and bitrate pass through; the command does not resize the picture or make the bitrate constant. If you need a specific output resolution, codec, or bitrate, re-encode instead. That adds CPU demand and may exceed the capacity of a particular Raspberry Pi, so start with a conservative setting and measure performance on the exact board.

For a re-encode, FFmpeg’s general command structure uses an encoder such as -c:v libx264 rather than -c:v copy. Set a constant video bitrate and keyframe interval appropriate to the chosen frame rate, and include compatible audio settings. Encoder availability and exact command behavior depend on the FFmpeg build; verify locally rather than assuming a copied command will work. Check YouTube’s published recommendations and run a test with representative motion and sound before broadcasting. YouTube encoder settings.

Rank #4
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

Test the stream before leaving it running

  1. Run the command and watch FFmpeg’s output for connection errors, repeated timestamp warnings, or an exit.
  2. Open YouTube Live Control Room and confirm that the preview shows moving video and audible sound.
  3. Check YouTube’s stream-health indicators and compare the actual output to the encoder recommendations.
  4. Let the exact video loop for a meaningful test period on the same Pi, network, and settings you intend to use. Confirm the picture, sound, and connection remain stable.

YouTube advises testing and monitoring stream health. A speed test helps establish whether your upload connection is suitable, but it does not prove that Wi-Fi, the Pi, or the full setup will remain stable over a long broadcast. YouTube encoder settings.

Plan for long-running broadcasts

YouTube states that streams under 12 hours are automatically archived. That statement does not establish the same archive outcome for streams longer than 12 hours, so check your channel’s current behavior and plan the broadcast lifecycle accordingly. YouTube live streaming setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
CanaKit Raspberry Pi 5 Essentials Starter Kit (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 32GB EVO+ Micro SD Card pre-loaded with 64-bit Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit 45W PD Power Supply for the Raspberry Pi 5
  • Display Cable - 6 foot (Supports up to 4K 60p)

The Raspberry Pi workflow depends on the board, power, storage, network, and FFmpeg process all continuing to work. If you automate recurring broadcasts through YouTube’s API, Google distinguishes liveStream resources (encoder delivery settings) from liveBroadcast resources (events) and documents reusing a stream across recurring broadcasts. That is separate from the manual file-loop command. YouTube Live broadcast lifecycle.

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

RTMPS or HLS?

For this basic FFmpeg setup, RTMPS is the simpler default when YouTube Studio supplies it and the encoder supports it. YouTube also supports HLS ingest, but it has higher latency because video is sent in segments and requires more configuration. HLS ingest requires TS segments, 1–4 second segment duration, a rolling playlist with no more than five outstanding segments, and HTTPS POST/PUT. YouTube ingestion protocol comparison.

Troubleshoot common problems

FFmpeg cannot connect or YouTube receives no signal

  • Recheck the ingest URL and stream key character for character, and make sure the key belongs to the selected stream.
  • Use the RTMPS server URL supplied by YouTube when available; do not assume a server address from another guide is current.
  • Check the Pi’s network access and FFmpeg’s output for connection or authentication errors.

The command exits or reports an unsupported codec or format

  • The source streams may not be compatible with FLV ingest or the selected YouTube settings. Try a known-compatible file or re-encode to a supported format.
  • Confirm that your FFmpeg build has the requested encoder if you switch from stream-copy to encoding.
  • Inspect audio and video streams separately; one incompatible stream can prevent a successful output even if the other is suitable.

The stream is choppy or stream health is poor

  • Reduce the target resolution, frame rate, or bitrate if the connection cannot sustain the output; use measured upload capacity and YouTube’s recommendations as guides.
  • If re-encoding, check whether the Pi is overloaded. Stream-copy avoids video encoding only when the input is compatible.
  • Test on the intended network and monitor the Live Control Room health indicators rather than relying on a brief local playback check.

Video repeats but audio is missing, delayed, or fails at the loop point

  • Test the source audio track by itself and inspect FFmpeg output for timestamp or stream errors.
  • Try a different compatible file or re-encode the audio to a supported format. Loop boundaries and timestamps can expose source-file issues that are not obvious during a short preview.

Copyright and YouTube policy checks

Having a video file does not by itself establish that you have the rights to broadcast its music, visuals, or other material. Before looping it publicly, confirm you have permission or a suitable license for the content and consider the effect of repeatedly broadcasting the same material on your channel’s policy obligations. Check YouTube’s current rules for copyright, live streaming, and monetization rather than assuming that a technically successful stream is policy-compliant. Copyright safety checklist.

Or let it run in the cloud

If you do not want to keep the Pi and home connection running, StreamNeo is a cloud service for keeping a YouTube channel live from uploaded videos. Upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home; it streams the uploaded quality up to 4K 60fps at one flat price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly service is $9.99 per month. Start the free day on StreamNeo.

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

For planning the DIY setup, use the upload-time calculator to estimate how long the source file may take to upload, or the cloud vs PC cost calculator to compare operating costs.

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 Starter Kit PRO - Turbine Black (128GB Edition) (4GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (4GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (4GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$209.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
Bestseller No. 4
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. 5
CanaKit Raspberry Pi 5 Essentials Starter Kit (8GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); Includes 32GB EVO+ Micro SD Card pre-loaded with 64-bit Pi OS, USB MicroSD Card Reader
$229.99

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.