On Raspberry Pi OS Lite, install FFmpeg with APT, confirm that your build supports the required streaming protocol, then run an FFmpeg command suited to your actual video source and YouTube event. To restart the process after a reboot or crash, run it as a systemd service. That is a useful do-it-yourself setup, but it cannot by itself guarantee uninterrupted streaming through camera, network, power, or YouTube failures.
What you need to decide before installing
Raspberry Pi OS Lite is the command-line-only edition of Raspberry Pi OS, intended for systems such as headless servers. Raspberry Pi recommends APT for routine package management and updates. See Raspberry Pi OS documentation.
As an Amazon Associate I earn from qualifying purchases.
The exact command and sustainable stream settings depend on details not specified by the title: your Pi model, the input source, desired resolution and frame rate, and whether FFmpeg can copy the input codecs or must encode them. No particular Pi model or FFmpeg configuration is established as capable of a given workload here. Test with the device and representative content you intend to use.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →- A Raspberry Pi running an imaged, booted Raspberry Pi OS Lite system, connected to a stable network and power source.
- An input source FFmpeg can access: for example, a prerecorded file, a camera or capture device, or a network stream. Each requires different input options.
- A YouTube Live event and its ingest URL and stream key, obtained from YouTube Live Control Room.
- Enough sustained upload bandwidth for your chosen bitrate, with capacity left for normal network variation.
Install FFmpeg and verify the build
-
Update the package index and install the distribution package:
#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)
sudo apt update sudo apt install -y ffmpeg -
Check that FFmpeg runs and note the version and build configuration shown on this Pi:
ffmpeg -version -
Check whether the build lists RTMP or RTMPS support:
ffmpeg -protocols | grep -E '(^| )rtmps?$'If the command prints nothing, inspect the complete protocol list with
ffmpeg -protocols. Package versions and enabled codecs or protocols can vary by OS release and architecture; do not assume every Lite image has identical options.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
For a fresh system, Raspberry Pi Imager is the standard route to install Raspberry Pi OS. Raspberry Pi’s current documentation describes the latest release as based on Debian Trixie, with Bookworm as the previous release. Check which OS release and architecture your device actually runs before following older package or hardware instructions.
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
Choose the input and YouTube connection
Prerecorded file
For a file, FFmpeg’s documented real-time input pattern is -re -i input-file. The -re option reads the file at its native rate rather than sending it as fast as possible. FFmpeg documents sending a file to an FLV output over an RTMP URL; see its FFmpeg documentation. For a continuous broadcast, your input and process also need a plan for what happens when the file ends; a one-time file command does not automatically create a playlist or an endless loop.
Camera, capture device, or network feed
Do not copy a guessed device path or input format from a different camera setup. Find the correct Linux device, pixel format, frame rate, and capture options for your hardware. For a network source, confirm its URL, transport, authentication, and whether the incoming codecs can be copied or require re-encoding. Those specifics cannot be made universal without knowing the source.
Get the correct YouTube ingest URL and protect the key
YouTube recommends RTMPS, the secure form of RTMP. In Live Control Room, retrieve the ingest URL and stream key from the stream settings; YouTube Help notes that the default displayed URL may be ordinary RTMP, and that the RTMPS URL is revealed using the lock icon. YouTube’s API documentation specifies port 443 for RTMPS. Use the endpoint supplied for your event rather than constructing one from memory. Never publish a real stream key in a script, support request, screenshot, or log. See YouTube’s encoder settings and bitrate guidance and YouTube Live Streaming API documentation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set encoder options and test the stream
The following is an illustrative file-streaming starting point, not a tested Raspberry Pi command or a performance guarantee. Replace the file path, ingest URL, and key; confirm that your FFmpeg build has the selected encoder; and choose settings the Pi can sustain. The example uses H.264 video, AAC audio, 30 frames per second, and a two-second keyframe interval:
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)
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'
Do not treat the example bitrate as a universal recommendation. YouTube’s current guidance calls for constant bitrate (CBR), recommends a keyframe interval of two seconds and says not to exceed four seconds. It accepts H.264, H.265, or AV1 video and AAC or MP3 audio for RTMP/RTMPS. Its table lists H.264 720p30 at 3 Mbps minimum and 8 Mbps recommended. Use the bitrate row for your actual resolution, frame rate, and codec rather than applying that 720p30 figure to other formats. YouTube recommends testing before the event and monitoring stream health.
- Resolution and frame rate: choose a target the Pi can encode in real time if re-encoding. Higher resolution and frame rate require more encoding capacity and usually more upload bandwidth.
- Bitrate: match YouTube’s guidance for the selected format and make sure the connection can reliably sustain it. Check actual upload capacity and watch YouTube’s stream-health indicators during a test.
- Keyframes: the example’s
-g 60at 30 fps gives a two-second interval. If you change frame rate, adjust the GOP length to preserve the intended interval. - Copy versus re-encode: copying compatible input streams can avoid video encoding load, but only works when the source codecs and container are suitable for the output. Re-encoding gives control over output settings but uses more Pi resources. Confirm your source and FFmpeg build before choosing.
- Codec support: verify the installed build has the encoder and protocol you plan to use; availability can vary by package build and architecture.
Start a private or otherwise appropriate test event, confirm that YouTube receives a stable signal, and inspect the stream health before relying on the setup. Account eligibility and the rules for keeping a particular event live continuously are not established by a working FFmpeg command; check the current Live Control Room for your account and event.
Run FFmpeg at boot with systemd
A systemd service can launch FFmpeg on boot and restart it when the process exits unsuccessfully. Use a dedicated, non-root service account and keep the stream key out of a publicly readable unit file. One approach is to put the command in a root-readable environment file and restrict its permissions; adapt paths and account names to your system.
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 reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute-
Create a service account if you do not already have one for the stream. For example:
Rank #4
Vilros Raspberry Pi 4 Complete Starter Kit- Includes Raspberry Pi 4 Board, Fan Cooled Case, 64GB Preloaded Micro SD Card and More (4GB, Clear Transparent Case)- 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
sudo useradd --system --create-home --shell /usr/sbin/nologin streamerEnsure that account can read the input file and any configuration it needs.
-
Create a protected environment file for the URL and key, for example
/etc/ffmpeg-stream.env. Restrict access so only root can read it:sudo chown root:root /etc/ffmpeg-stream.env sudo chmod 600 /etc/ffmpeg-stream.envPut your actual values in the file, not in a public script or the unit’s world-readable text. The exact environment-variable handling depends on how you write the command wrapper; do not assume that shell quoting or systemd expands arbitrary shell syntax in
ExecStart.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Create
/etc/systemd/system/ffmpeg-stream.servicewith anExecStartthat calls the tested command or a root-protected wrapper script. A minimal unit structure is: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
[Unit] Description=FFmpeg YouTube Live stream After=network-online.target Wants=network-online.target [Service] User=streamer EnvironmentFile=/etc/ffmpeg-stream.env ExecStart=/usr/local/bin/ffmpeg-stream Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.targetMake sure the wrapper is executable, owned and protected appropriately, and uses the correct FFmpeg path, input, and credentials. The example unit is a template, not a complete source-specific command.
-
Load the unit, enable it at boot, and start it now:
sudo systemctl daemon-reload sudo systemctl enable --now ffmpeg-stream.service -
Check the service state and recent logs:
systemctl status ffmpeg-stream.service sudo journalctl -u ffmpeg-stream.service -fAfter confirming a successful test, reboot the Pi and verify that the service starts and YouTube receives the stream again.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Systemd restarts a failed process; it does not repair an unplugged camera, an unavailable network source, bad credentials, an expired or misconfigured YouTube event, inadequate bandwidth, overheating, or loss of power. A restart loop can also repeatedly fail without solving the underlying issue. A Raspberry Pi community project documents unattended YouTube streaming with FFmpeg and systemd, but its existence is not a reliability guarantee for every setup: project documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common failures
| Symptom | Likely cause | What to check or do |
|---|---|---|
| FFmpeg is not found after installation | Installation failed, or the executable is not on the expected path. | Review APT output, run command -v ffmpeg, then check ffmpeg -version. |
| Protocol or encoder is unavailable | The installed package build does not include the requested protocol or codec support. | Inspect ffmpeg -protocols and ffmpeg -encoders; verify the package and architecture before changing the command. |
| YouTube does not receive the stream | Wrong ingest URL or key, RTMP used instead of the intended RTMPS endpoint, or event setup issue. | Copy the current URL and key from Live Control Room, check that the service can reach the endpoint, and verify the event and account status there. |
| Stream starts but drops or buffers | Unstable upload capacity, incorrect bitrate for the connection, or an input/network interruption. | Check YouTube stream health and sustained upload capacity; lower settings to an appropriate YouTube-supported row if needed, and inspect input and network logs. |
| FFmpeg exits immediately | Invalid input path, inaccessible file or device, unsupported format, or malformed output URL. | Run the command interactively as the service user, read the first FFmpeg error, and confirm permissions and source options. |
| Service does not return after reboot | Unit syntax, dependency, path, permissions, or environment configuration is wrong. | Run systemctl status and journalctl -u ffmpeg-stream.service; check the unit with systemd-analyze verify /etc/systemd/system/ffmpeg-stream.service, then reload systemd after edits. |
| Pi cannot keep up with encoding | Chosen codec, resolution, or frame rate exceeds what the particular device and build can sustain. | Test representative content, reduce the output workload, or use compatible stream copy where appropriate. No model-specific performance guarantee applies. |
Or let it run in the cloud
If your project is a prerecorded video or playlist that should loop on YouTube, StreamNeo is a simpler alternative to maintaining a Pi process: upload the video, add your YouTube stream key once, and go live. It runs in the cloud, so nothing has to stay on at home. Every slot streams the uploaded quality up to 4K 60fps at one flat price per slot, with no re-encode or quality tiers, and automatically recovers if YouTube drops the stream. The first day is free with no card; one free day is available per account. Monthly pricing is $9.99 per month. StreamNeo is for uploaded videos and YouTube streams, not live camera input. Learn more at StreamNeo, or start the free day.
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.




