The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Run FFmpeg as the foreground process of a systemd service, then set Restart=on-failure so systemd starts it again after qualifying failures. This handles a process that exits; it does not prove YouTube is receiving a healthy broadcast. Check the service logs and YouTube Live Control Room after a restart.
What systemd can—and cannot—recover
A systemd restart policy is useful when FFmpeg exits with an error or is terminated by an abnormal condition. With Restart=on-failure, systemd retries after a nonzero exit and certain abnormal failures. A deliberate systemctl stop does not trigger an automatic restart. The policy and delay are subject to systemd’s start-rate limiting, so repeated failures can stop further attempts until you diagnose the cause. See the systemd.service manual.
This is process-level recovery, not a guarantee that a YouTube stream will resume correctly. If FFmpeg remains running while an input or output connection is broken, systemd may have no process exit to react to. FFmpeg-level recovery options address failures inside the encoder process, but the right options depend on the FFmpeg version and which connection failed. Do not assume an input reconnect option repairs an output connection.
Before creating the service
- Install FFmpeg and identify its absolute path, such as
/usr/bin/ffmpeg; confirm that it matches your system. - Choose the Linux account that should run the process and a working directory it can access.
- Prepare the actual input file or other input arguments, plus the codec and output options appropriate to your stream. The example below is a template, not a tested or universal encoding command.
- In YouTube Live Control Room, get the live server URL and the stream key for the intended broadcast. YouTube’s encoder setup instructions explain where to enter those values. If using RTMPS, use the RTMPS address shown there and confirm that your FFmpeg build supports the protocol; see YouTube’s RTMPS instructions.
- Treat the stream key as a secret. Do not publish it or leave a real key in a publicly shared unit-file example. Restrict access to the configuration that contains it, or use an appropriate secret-injection method for your environment.
Create a systemd unit for FFmpeg
Create /etc/systemd/system/youtube-ffmpeg.service with a text editor running as an administrator. Replace the sample account, directory, input, encoding arguments, ingest URL, and key with values for your installation.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Raspberry Pi 5 with 8GB RAM: Model SC1112 featuring a quad-core ARM Cortex-A76 processor running at 2.4GHz. Enhanced Connectivity: Includes dual 4K micro HDMI ports, USB-C power input, and high-speed USB 3.0 ports. PCIe Expansion Support: FPC connector enables M.2 NVMe SSDs when using compatible adapters. Fast Storage Options: Works with microSD cards for booting, or optional NVMe storage for advanced projects. Built for Projects & Learning: Ideal for programming, home labs, DIY electronics, automation, and Linux-based development.
[Unit]
Description=FFmpeg YouTube Live stream
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=streamer
WorkingDirectory=/srv/youtube-stream
ExecStart=/usr/bin/ffmpeg -re -i /srv/youtube-stream/input.mp4 -c:v libx264 -c:a aac -f flv rtmp://YOUR_INGEST_URL/YOUR_STREAM_KEY
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
The output address is deliberately illustrative. Substitute the ingest URL currently displayed by YouTube and the corresponding protected key; for RTMPS, use YouTube’s RTMPS URL if your installed FFmpeg supports it. Keep FFmpeg in the foreground: systemd needs to track it as the service’s main process. Do not add daemonizing or backgrounding behavior to ExecStart.
Choose a restart delay deliberately
RestartSec=5s is only a sample delay, not a universal recovery target. RestartSec= sets the wait before a restart attempt. Pick a delay suitable for the deployment and consider how repeated starts interact with systemd’s rate limits. The systemd manual documents restart conditions, delay controls, and rate limiting; it does not make this sample value appropriate for every service.
Load, enable, and inspect the service
- Reload unit definitions after creating or changing the file:
sudo systemctl daemon-reload. - Enable the service at boot and start it now:
sudo systemctl enable --now youtube-ffmpeg.service. - Check systemd’s view of the service:
systemctl status youtube-ffmpeg.service. - Follow the service journal for FFmpeg output and errors:
journalctl -u youtube-ffmpeg.service -f. - Separately open YouTube Live Control Room and confirm that the intended stream is receiving data and reporting a healthy state. A running process or active systemd unit alone does not confirm successful ingest.
After editing the unit, apply the changes with sudo systemctl daemon-reload and deliberately restart it with sudo systemctl restart youtube-ffmpeg.service. A manual stop is not a valid automatic-restart test: systemd suppresses the restart when its own stop operation terminates the service.
Test recovery without mistaking a restart for a working stream
Use a controlled failure during a non-public test stream. Observe the service logs and status to see whether systemd starts a new FFmpeg process, then verify the resulting ingest in YouTube Live Control Room. Do not infer stream health solely from a changed process ID, a successful systemd start, or a quiet log.
Rank #3
- 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
A systemd restart starts the command again; it does not guarantee that FFmpeg resumes at the exact point of interruption. For a file input, the command’s normal input behavior applies when it starts again. If the encoder stays alive but cannot write to YouTube, a process restart policy may not activate. Version-specific FFmpeg recovery behavior should be checked against the documentation for the installed build.
Troubleshoot failures in order
The service exits immediately or repeatedly
- Run
systemctl status youtube-ffmpeg.serviceand inspectjournalctl -u youtube-ffmpeg.servicefor the exit status and FFmpeg’s own error message. - Check that the executable path, input path, working directory, user permissions, and command arguments are valid for the service account.
- Confirm that the input can be read and that the selected FFmpeg build supports the requested codecs and output protocol.
Systemd stops retrying
Repeated attempts may hit systemd’s start-rate limit. Diagnose the underlying error first rather than repeatedly clearing the failure state or increasing limits without understanding why the process exits. Check the unit’s logs and the installed systemd documentation for the applicable rate-limit behavior.
Rank #4
- Broadcom BCM2712 2.4GHz quad-core 64-bit Arm Cortex-A76 CPU, with cryptography extensions, 512KB per-core L2 caches and a 2MB shared L3 cache
- Dual-band 802.11ac Wi-Fi Bluetooth 5.0 / Bluetooth Low Energy (BLE)
- 2 × USB 3.0 ports, supporting simultaneous 5Gbps operation / 2 × USB 2.0 ports
- Gigabit Ethernet, with PoE+ support (requires separate PoE+ HAT)
- The Raspberry Pi 27W USB-C Power Supply is recommended for delivering the power you need to keep you Raspberry Pi running at peak performance
FFmpeg runs, but YouTube does not receive the stream
- Confirm the server URL and stream key are current and belong to the intended YouTube live setup.
- If using RTMPS, verify that the URL came from YouTube Live Control Room and that the installed FFmpeg build supports RTMPS.
- Check FFmpeg’s output logs and YouTube Live Control Room independently. Process liveness does not establish successful ingest.
- If FFmpeg remains running after output failure, investigate encoder-level recovery or monitoring appropriate to the installed version;
Restart=on-failureonly responds to qualifying service failures.
Or let it run in the cloud
If your goal is a continuously looping YouTube stream rather than maintaining a Linux host and service, StreamNeo runs uploaded videos from the cloud: upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home. Every slot streams the uploaded file as made, up to 4K 60fps, at one flat price per slot; it also includes automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly billing is $9.99 per month. StreamNeo is for uploaded video and YouTube streams, not live camera input. Start your free first day with StreamNeo.
Quick Recap
Best Value
- Design for Raspberry Pi: Supports installation of 4 Raspberry Pis and 4 ssds, compatible with any 2.5” Solid State Drive (7mm/9mm) and Rpi 4B/3B+, and other B/B+ models.
- The SSD mounting bracket also has two holes reserved for the SD card extension adapter ASIN: B09CKRDFTH, which allows you to access the SD card from the front of the rack.
- Easy to Setup: Just use two included thumbscrews to mount the rackmount, which adopts a screw-in design, which helps you install and replace quickly and easily, no tools needed!
- Applications: This is a hardware solution to get ingenious use of the Raspberry Pi, with this kit and open source software OpenMediaVault, you can use the Pi as a NAS Server, Surveillance station, or even a Web server.
- Optional accessories: Single mounting bracket: B09GFQLPTY; Micro SD card extension adapter ASIN: B09CKRDFTH. I/O Panel: B09FXRQPFM
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.
Recommended Free Tools

