Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsInstall FFmpeg on Raspberry Pi OS Lite with APT, verify that your build supports RTMPS, then configure an input and a YouTube stream command that fit your source and Raspberry Pi. To start it after reboot and restart a failed FFmpeg process, run it as a systemd service. That helps with process failures; it does not by itself guarantee an uninterrupted 24/7 broadcast.
The exact command depends on whether you are streaming a prerecorded file, a camera, or a network feed—and on what your Pi can encode. The example below is a starting point for a file, not a tested performance guarantee for every Pi.
What you need to decide first
- Raspberry Pi OS release and architecture: package versions and FFmpeg features can vary. Raspberry Pi describes Lite as a command-line-only edition without a graphical desktop, suitable for headless use. See Raspberry Pi OS.
- Input source: a prerecorded file, camera, and network feed each need different input configuration.
- Encoding approach: re-encoding gives you control over output settings but uses compute; copying a compatible source avoids that encoding work but depends on its format and stream layout.
- YouTube event and account: confirm the event is configured in Live Control Room and that the account is eligible to stream. The requirements for leaving a particular broadcast live continuously are not established here.
Raspberry Pi recommends APT for routine package management and updates. For a new device, install Raspberry Pi OS with Raspberry Pi Imager and choose Lite; for an already imaged device, continue below. The current Raspberry Pi OS documentation identifies Trixie as the latest release and Bookworm as the previous release, so do not assume a tutorial written for an older release has the same package version or options.
Install FFmpeg and check RTMPS support
-
Update the package index:
sudo apt update -
Install FFmpeg from the distribution repository:
sudo apt install -y ffmpeg -
Inspect the installed version and build configuration:
Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.#1 Best Overall
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM- Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
- Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
- CanaKit Premium High-Gloss Raspberry Pi 4 Case with Integrated Fan Mount, CanaKit Low Noise Bearing System Fan
- CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply (US Plug) with Noise Filter, Set of Heat Sinks, Display Cable - 6 foot (Supports up to 4K60p)
- CanaKit USB-C PiSwitch (On/Off Power Switch for Raspberry Pi 4)
ffmpeg -version -
Check the protocol list for RTMP or RTMPS:
ffmpeg -protocols | grep -E '(^| )rtmps?$'
The package name is ffmpeg, but the available version, codecs, and protocols depend on the OS release, architecture, and repository build. If the protocol check returns no RTMPS entry, verify the build and package sources for that image before relying on an RTMPS output command.
Get the YouTube ingest URL and protect the key
Create or select the live stream in YouTube Live Control Room, then copy the server URL and stream key from Stream settings. YouTube recommends RTMPS, which is RTMP carried over TLS/SSL; its documentation specifies port 443. In YouTube Help’s Choose live encoder settings, bitrates, and resolutions, the RTMPS URL is revealed using the lock icon. The default displayed URL may be ordinary RTMP, so check which endpoint you copied.
- Treat the stream key like a password. Do not publish it in a script, repository, screenshot, or support log.
- Use the complete RTMPS URL and key in the output URL format expected by your FFmpeg build and YouTube’s current Live Control Room settings.
- If you replace or reset a key, update the service configuration too; an old key can leave FFmpeg unable to connect.
Configure FFmpeg for the actual source
Prerecorded file
For a file that should be sent at its intended playback rate, FFmpeg documents the real-time input pattern -re -i input-file. A schematic command that re-encodes video and audio is:
Rank #2
- Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1. 5GHz
- 2. 4 GHz and 5. 0 GHz IEEE 802. 11b/g/n/ac wireless LAN, Bluetooth 5. 0, BLE
- 2 Ă— USB 3. 0 ports, 2 x USB 2. 0 Ports
- 2 Ă— micro HDMI ports supproting up to 4Kp60 video resolution
- Micro SD card slot for loading operating system and data storage
ffmpeg -re -i /path/to/input.mp4
-c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k
-r 30 -g 60 -c:a aac -b:a 128k -ar 44100
-f flv 'rtmps://YOUR_YOUTUBE_INGESTION_URL/YOUR_STREAM_KEY'
Replace the placeholders with the actual input path and YouTube endpoint/key. This example requests 30 fps and a 60-frame GOP, giving a two-second keyframe interval at that frame rate. Its 2.5 Mbps video rate is illustrative, not a universal recommendation or a tested Raspberry Pi performance result. Confirm that the Pi can sustain the chosen resolution and encoding settings and that the uplink can sustain the total output.
Camera or network input
Do not copy the file command unchanged. A camera requires the correct Linux capture device and format; a network feed requires its real URL, transport, credentials, and stream layout. Those details are specific to the hardware and source, so there is no universal camera path or network-input command here. Check the input with FFmpeg before adding the YouTube output, and determine whether the source can be copied as-is or needs re-encoding.
Copying versus re-encoding
The example uses libx264 and AAC to re-encode. That gives direct control over output settings but makes the Pi do encoding work. If the input already has a YouTube-compatible video and audio stream at suitable rates and timing, stream copying may reduce CPU use; it will not make an incompatible input compatible. Check the codecs and stream properties of the actual source, and test the resulting output before relying on it.
Rank #3
- Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
- 1GB, 2GB, 4GB or 8GB LPDDR4-3200 SDRAM (depending on model)
- 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE Gigabit Ethernet
- 2 USB 3.0 ports; 2 USB 2.0 ports.
- Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with previous boards)
Match YouTube’s settings to the Pi and uplink
YouTube’s encoder guidance calls for constant bitrate (CBR), recommends a two-second keyframe interval (not more than four seconds), and lists H.264, H.265, or AV1 video and AAC or MP3 audio for RTMP/RTMPS. Use the current YouTube encoder settings and bitrate table for the resolution, frame rate, and codec you actually select; rates vary by those choices.
As one specific reference point, YouTube lists H.264 720p30 at 3 Mbps minimum and 8 Mbps recommended. That row is not a bitrate recommendation for other resolutions, frame rates, or codecs. The illustrative command above uses a lower rate, so change it to match the applicable YouTube guidance and your source rather than treating the sample as a ready-to-use 720p30 preset.
- Choose resolution and frame rate the Pi can encode continuously, if re-encoding.
- Set the bitrate for the applicable YouTube table row and ensure the upstream connection can reliably carry it, including audio and network overhead.
- Use a keyframe interval YouTube recommends; at 30 fps,
-g 60corresponds to two seconds. - Test with representative content and monitor YouTube’s stream health before leaving the system unattended.
Run FFmpeg at boot with systemd
A systemd unit can launch FFmpeg after boot and restart a process that exits unsuccessfully. Keep credentials out of world-readable unit files and run the service as a dedicated, non-root account. The following is a template; adapt paths, user/group, input, and secure key handling for your installation.
Rank #4
- Vilros Complete Starter Kit for Pi 4 Includes Raspberry Pi 4 Model B Board and all the accessories you need to get started.
- 9-PART KIT WILL HAVE YOU READY TO GET UP AND RUNNING: Kit Includes 1. Raspberry Pi 4 Model B Board 2. Case With Easy to connect Built-in fan 3. 64GB Micro SD card Preloaded with RP OS 4. Vilros Pi 4 Compatible Power Supply with Inline on/off switch (power supply color may vary white/black) 5. Micro HDMI to Standard HDMI cable (5ft) 6. Micro SD to USB adapter to reflash card if desired 7. Neoprene Storage Bag to store all parts when not in use 8. Set of 4 Heatsinks 9. Vilros QuickStart Guide instruction booklet for Pi 4
- PASSIVE & ACTIVE COOLING: The included case is well-vented and the kit also includes a set of heatsinks with thermal stickers for easy application and a pre-installed fan to keep the board cool in any use.
- CONVENIENT ACCESSORIES: The power supply features an inline on/off switch neoprene bag that holds and protects all the parts when not in use and the QuickStart guide is updated and written for Raspberry Pi 4.
- IMPORTANT: Kit does NOT include Keyboard, Mouse or Monitor
-
Create a dedicated account if you do not already have one, and ensure it can read the source and any protected configuration needed by FFmpeg.
-
Create
/etc/systemd/system/youtube-stream.service:[Unit] Description=FFmpeg YouTube Live stream Wants=network-online.target After=network-online.target [Service] Type=simple User=stream Group=stream WorkingDirectory=/home/stream ExecStart=/usr/bin/ffmpeg -re -i /path/to/input.mp4 -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -r 30 -g 60 -c:a aac -b:a 128k -ar 44100 -f flv rtmps://YOUR_YOUTUBE_INGESTION_URL/YOUR_STREAM_KEY Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.targetThis template shows the structure, not secure key storage: putting a real key directly in
ExecStartcan expose it through service configuration and process inspection. Use permissions-restricted configuration or another suitable secret-handling method, and adjust the command to match it. Confirm the executable path withcommand -v ffmpeg. -
Load and enable the unit, then start it:
sudo systemctl daemon-reload sudo systemctl enable --now youtube-stream.service -
Check its state and recent logs:
sudo systemctl status youtube-stream.service sudo journalctl -u youtube-stream.service -n 100 --no-pager -
Test recovery by stopping or restarting the service during a planned test, then verify that FFmpeg reconnects and YouTube receives the stream. Reboot the Pi and confirm the service starts again.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Best Value
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)- Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
- CanaKit 3.5A USB-C Power Supply with Noise Filter (UL Listed) specially designed for the Raspberry Pi 4 (5-foot cable)
- CanaKit USB-C PiSwitch (On/Off Power Switch)
- Set of 3 Aluminum Heat Sinks for the Raspberry Pi 4
Restart=on-failure addresses a process exit; it cannot repair a disconnected camera, unavailable network source, bad or expired event/key setup, inadequate upload bandwidth, overheating, or lost power. Those need separate monitoring and recovery measures.
Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| FFmpeg reports an unknown protocol or cannot open the RTMPS output | The installed build may lack RTMPS support, or the URL is malformed. | Check ffmpeg -protocols, verify the copied RTMPS endpoint, and confirm that the URL and key are assembled in the format required by the selected FFmpeg output. |
| YouTube does not receive the stream or rejects the connection | Wrong ingest URL, wrong key, wrong event configuration, or network access problem. | Copy current values from Live Control Room, check the service logs and outbound connectivity, and confirm the event is ready to receive an encoder. |
| FFmpeg exits immediately with an input error | Incorrect file path, unavailable permissions, unsupported input, or wrong camera/network parameters. | Run the input portion interactively as the service user and verify the source is readable and has the expected format. |
| Stream health reports unstable bitrate or dropped frames | The uplink cannot sustain the selected output, or the Pi cannot encode it in real time. | Compare the chosen output against YouTube’s relevant bitrate row, reduce resolution/frame rate or bitrate as appropriate, and assess whether copying a compatible source is feasible. |
| Service restarts repeatedly | FFmpeg is failing on the same input, credentials, or connection issue; systemd is restarting the process but not correcting the cause. | Read journalctl -u youtube-stream.service, fix the underlying error, then retest the service. |
| Stream stops after the Pi loses power, overheats, or loses its source | Systemd only supervises a running host and process; it cannot restore failed hardware or an absent source. | Address power, cooling, source availability, and network resilience independently, then test recovery under realistic conditions. |
Or let it run in the cloud
If the project is a loop of prerecorded videos rather than a camera or live network feed, StreamNeo is a cloud option for keeping a YouTube channel live without leaving a Pi or home connection running. Upload a recording or build a playlist, add the YouTube stream key, and go live. StreamNeo loops uploaded video; it does not broadcast a camera feed.
- Nothing has to stay on at home; the stream runs from the cloud.
- Uploaded video streams as made, up to 4K 60fps, at one flat price per slot rather than quality tiers.
- Automatic recovery is provided if YouTube drops the stream.
- The first day is free, with no card required; it is one free day per account.
- Every slot includes one always-on stream, 10 GB storage per slot pooled across active slots, looping and playlists, and support. The same product is on every plan; only the billing length changes.
Monthly billing is $9.99 per month. UPI and cards are available in India; card checkout is available worldwide. See StreamNeo pricing for the available billing periods, and try the first day by starting a StreamNeo account.
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.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →




