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
- In YouTube Studio, select Create → Go Live.
- 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.
- 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.
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
- 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
- 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.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →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
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
- 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).
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Test the loop before leaving it running
- Run the command for long enough to see the YouTube preview stabilize and the health indicators settle.
- Check that moving video and audio are both present. Confirm levels are audible without clipping or unwanted silence.
- Observe FFmpeg output and Pi load. If encoding, check for sustained CPU saturation or dropped frames; if copying, check for timestamp or muxing errors.
- 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.
- 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
- 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)
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 -versionand 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
-reis before-ifor file input so FFmpeg reads at media rate. - The file plays once and stops: Put
-stream_loop -1before 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.
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
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.




