October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Mountain View desk8 min

How to Loop Videos on YouTube Live with Raspberry Pi and FFmpeg

Use FFmpeg’s -stream_loop -1 option to repeat a video on YouTube Live from a Raspberry Pi, with RTMPS setup, encoding guidance, and practical troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can loop a prerecorded video on YouTube Live with FFmpeg by using -stream_loop -1 before the input file, pacing playback with -re, and sending the output to the RTMPS server URL and stream key from YouTube Studio. A compatible file can often be sent with stream copy to reduce Raspberry Pi encoding work, but you must test the exact Pi, file, network, and settings before relying on a long broadcast.

What you need before you start

  • A Raspberry Pi running an FFmpeg build with the required input and output support. Check the installed version with ffmpeg -version; options and available codecs depend on the build.
  • A prerecorded video file. Stream copy is the lower-CPU route only if its streams are compatible with the output container and YouTube ingest settings.
  • A YouTube channel enabled for live streaming, plus the server URL and stream key shown in YouTube Studio. Treat the key like a password: anyone with it may be able to send a stream to your channel.
  • A stable internet connection with upload capacity for the selected video and audio bitrates, plus room for normal network variation.

This procedure is for looping a file, not broadcasting a camera. Camera capture on current Raspberry Pi OS uses a different workflow; Raspberry Pi documentation covers Picamera2 and headless camera operation, but does not establish FFmpeg file-streaming performance across every Pi model (Raspberry Pi Picamera2 manual).

As an Amazon Associate I earn from qualifying purchases.

Create a YouTube live stream and get the connection details

  1. In YouTube Studio, select Create → Go Live.
  2. Create or select the stream and copy the server URL and stream key provided in Live Control Room. Use the RTMPS URL when YouTube Studio offers it.
  3. Keep Live Control Room open. You will use its preview and stream-health indicators to confirm that FFmpeg is connected and sending usable video and audio.

YouTube’s workflow is to enter the supplied URL and key in the encoder, start the encoder, then verify the preview and go live in Live Control Room when the scheduled-stream workflow requires it (YouTube: Go live with an encoder). Do not paste your key into public scripts, screenshots, or support posts.

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

Choose stream copy or re-encoding

Try stream copy first when the file is already suitable

With -c:v copy -c:a copy, FFmpeg passes the existing video and audio streams through instead of encoding them again. This can substantially reduce the Pi’s processing load. It does not convert an incompatible codec, fix unsuitable timestamps, change the bitrate, or guarantee that the file’s pixel format, audio tracks, or container assumptions will work for YouTube. A stream-copy command is therefore a testable starting point, not a promise of compatibility.

#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

Re-encode only if compatibility or output control requires it

Using an encoder such as -c:v libx264 means FFmpeg must encode video. That gives you control over output size, frame rate, and bitrate, but increases compute demand and can overwhelm a particular Pi. Do not assume all Raspberry Pi models can encode the same resolution and frame rate. Test on the target board. FFmpeg documents stream copy and encoding as distinct output behaviors (FFmpeg documentation).

Run the repeating FFmpeg stream

Start with this stream-copy command

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

Replace input.mp4 with the actual file path. Replace the endpoint and key placeholders with the server URL and key from YouTube Studio, combined in the form YouTube provides. Keep the key private. The -stream_loop -1 option repeats the input indefinitely and must appear before the corresponding -i; -re reads a file at approximately its native media rate instead of pushing it as fast as the process can read. Confirm both options against the documentation for your installed FFmpeg version (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

Use the command in a terminal on the Pi. FFmpeg should report that it has opened the input and is sending output; meanwhile, Live Control Room should show a preview and stream health. Do not assume the broadcast is healthy just because the FFmpeg process has not exited.

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

If stream copy is not compatible

Use an encoding command only after checking what the Pi can sustain. For example, this general H.264/AAC shape illustrates the settings to supply; it is not a guaranteed command for every FFmpeg build or Pi:

Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit
ffmpeg -re -stream_loop -1 -i "input.mp4" 
  -c:v libx264 -b:v 5M -maxrate 5M -bufsize 10M 
  -g 60 -keyint_min 60 -sc_threshold 0 
  -c:a aac -b:a 128k -ar 48000 -f flv 
  "<YouTube RTMPS ingest URL>/<STREAM_KEY>"

Those example values correspond to a 1080p30-oriented starting point, not an automatic fit for another resolution or frame rate. Set GOP/keyframe length to about two seconds: for 30 fps, 60 frames; for 60 fps, 120 frames. YouTube says the keyframe frequency should not exceed four seconds. Constant bitrate is recommended. Verify encoder availability with your FFmpeg build and watch for dropped frames, CPU saturation, or delayed output. If the Pi cannot encode reliably, reduce resolution or frame rate, use a compatible pre-encoded source with stream copy, or use a more capable encoder.

Match the stream to YouTube’s ingest recommendations

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

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

These are YouTube’s published H.264 recommendations, accessed in 2026, not a guarantee that a Pi or connection can sustain them. Choose a conservative resolution and bitrate based on measured upload capacity, then test. YouTube recommends a speed test and a representative test with both sound and movement (YouTube encoder settings and bitrates).

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

Test the loop before leaving it running

  1. Run the command for long enough to see the YouTube preview stabilize and the health indicators settle.
  2. Check that moving video and audio are both present. Confirm levels are audible without clipping or unwanted silence.
  3. Observe FFmpeg output and Pi load. If encoding, check for sustained CPU saturation or dropped frames; if copying, check for timestamp or muxing errors.
  4. Let the file reach its end and confirm that playback starts again. The loop option should prevent a normal end-of-file from ending the process.
  5. Test the actual network path and the duration you intend to rely on. A short successful test does not prove a long unattended run will remain stable.

YouTube says streams under 12 hours are automatically archived. That statement does not establish the same archive outcome for streams longer than 12 hours, so check the channel’s current behavior and plan the broadcast lifecycle accordingly (YouTube: Go live with an encoder).

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)
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 Pi-and-FFmpeg workflow, use RTMPS when available. HLS is another YouTube ingest option, but it adds segment and playlist requirements and has higher latency than RTMP because the video is sent in segments. YouTube specifies TS segments of 1–4 seconds, a rolling playlist with no more than five outstanding segments, and HTTPS POST/PUT for HLS ingest (YouTube encoder settings and bitrates; YouTube HLS ingest requirements).

Troubleshooting common failures

  • YouTube shows no preview: Check that the full server URL and stream key are correct, the key belongs to the selected stream, and the Pi can reach the ingest endpoint. Check FFmpeg’s connection and output errors.
  • FFmpeg exits or reports an option error: Run ffmpeg -version and consult the matching FFmpeg documentation. Builds vary in supported options, protocols, and encoders.
  • The stream connects but video or audio is rejected or missing: The input codecs, pixel format, tracks, timestamps, or container may be incompatible. Test with stream copy first, inspect the file, and re-encode to a supported format if needed.
  • Playback runs too fast: Ensure -re is before -i for file input so FFmpeg reads at media rate.
  • The file plays once and stops: Put -stream_loop -1 before the input’s -i, and check that the running command is the one being monitored.
  • Video stutters or YouTube reports poor health: Reduce bitrate, resolution, or frame rate to fit the real upload capacity; if re-encoding, check whether the Pi is overloaded. YouTube’s bitrate figures are recommendations, not a measurement of your local capacity.
  • The loop has a pause, audio gap, or visible jump at the join: The file’s end and start may not form a seamless transition. Edit or re-encode the source with a clean join, then test the transition in the live preview.
  • The broadcast ends after a long run: Check power, network connectivity, FFmpeg output, and the stream’s status in Live Control Room. YouTube’s cited automatic-archive guidance applies to streams under 12 hours; it does not promise archival beyond that duration.

Copyright, reused content, and live-stream responsibility

Looping a file does not grant permission to broadcast its contents. Before going live, confirm you have the rights or permissions required for every video, song, performance, and other included material. YouTube may restrict or interrupt streams that violate its policies, and repeated or continuous playback does not make copyrighted material yours. Also consider whether a channel’s content is sufficiently original for the platform’s applicable monetization policies; permission to use a work and eligibility for monetization are separate questions. Review the current channel and content rules in YouTube Studio before scheduling a long broadcast.

Or let it run in the cloud

If you do not want a Raspberry Pi, power supply, and home internet connection to remain on, StreamNeo runs an uploaded video as a YouTube Live stream from the cloud. The setup is: upload a recording or build a playlist, add your YouTube stream key once, then go live. Your computer can be off; StreamNeo loops the uploaded video and automatically recovers if YouTube drops the stream. Each slot streams the uploaded quality up to 4K 60fps at one flat price, with no re-encode or quality tiers; storage is 10 GB per slot, pooled across active slots. The first day is free with no card (one free day per account), and the same product is available on day, week, month, six-month, or yearly billing with cancellation any time. UPI and cards are supported in India, with card checkout worldwide. See StreamNeo for details. Monthly pricing is $9.99 per month. Start your free StreamNeo day.

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.

Automating recurring broadcasts

The manual FFmpeg loop above does not require YouTube’s API. For API-based automation, Google distinguishes a liveStream resource, which represents encoder delivery settings, from a liveBroadcast resource, which represents an event. Its documentation describes reusing a stream across recurring broadcasts and keeping a continuous broadcast while creating a separate broadcast for a subset of content (YouTube Live Streaming API documentation).

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.

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.