The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Run FFmpeg as a long-running systemd service with Restart=on-failure and a measured RestartSec= delay. That brings FFmpeg back after an abnormal exit, but it does not fix a bad stream key, a rejected YouTube ingest, or an ongoing network or encoding problem. For stronger recovery, match the retry method to the failure: FFmpeg protocol reconnect options for supported inputs, FIFO muxer recovery for certain output interruptions, and systemd for a process that exits.
What systemd can—and cannot—recover
systemd supervises the FFmpeg process. If FFmpeg exits with a failure, systemd can wait for the configured delay and launch it again. Its service manual recommends Restart=on-failure for long-running services. Restart attempts are still subject to systemd start-rate limits, and repeated launches will not make a persistent error disappear. systemd.service(5)
As an Amazon Associate I earn from qualifying purchases.
Recovery happens at different layers:
- Input connection: FFmpeg protocol reconnect options may retry a supported input connection.
- Output connection: FFmpeg’s FIFO muxer has output recovery options for some interruptions.
- Process exit: systemd can restart FFmpeg after it exits abnormally.
None guarantees uninterrupted playback for viewers. A restart policy cannot repair invalid credentials, a persistent upstream outage, an unsupported option, or a YouTube ingest configuration that rejects the stream.
Configure FFmpeg as a systemd service
This illustrative unit shows the main structure. Replace the executable path, input, encoding arguments, and destination with values for your machine and stream. It is a starting point, not a tested drop-in configuration; check your installed systemd and FFmpeg versions and validate option placement against your local FFmpeg build.
#1 Best Overall
- 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)
[Unit]
Description=FFmpeg YouTube stream
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/ffmpeg -re -i /path/to/input -c:v libx264 -c:a aac -f flv rtmps://example.invalid/live/STREAM_KEY
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
The example uses a placeholder destination. Do not copy it as a working YouTube URL or put a real stream key in a unit file that other users can read. Store credentials using an appropriately protected configuration mechanism, and avoid exposing them in logs or published command output.
Choose a restart policy and delay
Restart=on-failurerestarts after abnormal failure and is the systemd manual’s recommended choice for long-running services.RestartSec=5is an example delay, not a universal ideal. Measure a suitable delay for your stream and failure pattern rather than allowing rapid retries.Restart=alwaysis not a substitute for diagnosing exits. Pick a policy deliberately, based on whether a clean exit should also trigger another launch.
The basic loop is: FFmpeg fails, systemd waits for RestartSec, then attempts to start it again. If it fails too often in a short period, systemd’s start-rate limiting can leave the unit failed instead of retrying indefinitely. Understand StartLimitIntervalSec= and StartLimitBurst= as implemented by your systemd version before changing limits; unlimited rapid restarts are not a safe default. systemd.unit(5)
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
Enable and inspect the service
Save the unit under a suitable system service name, then reload systemd’s unit definitions and enable/start the service using the appropriate systemctl commands for your unit. Confirm that the unit is active and inspect its logs before relying on it for a scheduled broadcast. The exact unit name and service-file location depend on your installation.
Use FFmpeg reconnect options only for supported inputs
FFmpeg’s protocol options distinguish conditions such as a disconnected connection, network connection errors, streamed inputs, retry limits, and end-of-file. Options such as reconnect, reconnect_on_network_error, reconnect_streamed, and reconnect_at_eof apply according to the input protocol’s support and behavior; they are not interchangeable universal switches. Consult the protocol documentation for the protocol you actually use and place options correctly for your FFmpeg build. FFmpeg Protocols Documentation
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)
In particular, do not assume these input-side flags will reconnect an outgoing RTMP or RTMPS YouTube publisher. An input reconnect can help when a supported source disconnects; it does not supervise FFmpeg after the process exits, and it does not itself repair output-side publishing failures.
Consider FIFO muxer recovery for output interruptions
If FFmpeg remains alive but the output connection is interrupted, the FIFO muxer offers a different recovery layer. Its options include attempt_recovery and recovery_wait_time; its documented example uses -f fifo, -fifo_format flv, and recovery parameters for a generic RTMP destination. This is an output-side technique, distinct from systemd restarting the entire process. The example is generic RTMP guidance, not YouTube-specific validation, so check the current FFmpeg documentation and test your actual build and destination before depending on it. FFmpeg Formats Documentation: fifo
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
Check YouTube ingest and encoder settings
A service can restart successfully while YouTube continues to reject or drop its output. YouTube recommends RTMPS for Live ingest. Its encoder guidance specifies constant bitrate (CBR), recommends a 2-second keyframe frequency, and says the interval must not exceed 4 seconds. Supported video codecs listed in the guidance include H.264, H.265 (HEVC), and AV1; audio options include AAC and MP3. Choose a bitrate from YouTube’s current resolution- and frame-rate-specific table rather than treating one number as universal. YouTube Help: Choose live encoder settings, bitrates, and resolutions
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesYouTube’s instruction is direct: “Make sure to test before you start your live stream.” Test the full path to YouTube before the scheduled broadcast, including the stream key, protocol, codec, bitrate, keyframe interval, and the point at which the stream is meant to be live.
Best Value
- 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
Troubleshoot repeated stops and restart loops
| Symptom | Likely layer | What to check |
|---|---|---|
| The source disappears, but FFmpeg is still running | Input | Confirm that the input protocol supports the reconnect option you chose; inspect the input-specific error and retry behavior in FFmpeg’s protocol documentation. |
| The publishing connection fails while FFmpeg remains alive | Output | Inspect FFmpeg’s output error and YouTube’s stream status. Consider FIFO muxer recovery only if it fits the output failure and is supported by your FFmpeg build. |
| FFmpeg exits after an error | Process | Check the service journal and FFmpeg error output, then confirm the unit uses the intended restart policy and delay. |
| The service rapidly restarts, then stays failed | systemd start-rate limiting or recurring failure | Inspect the unit’s journal, identify the original FFmpeg error, and review your systemd version’s start-limit settings. Do not mask a persistent error by simply increasing retry frequency. |
| FFmpeg runs, but YouTube does not accept the stream | Credentials, ingest, or encoding | Verify the current stream key and dashboard status, then validate RTMPS, codec, CBR bitrate, and keyframe settings against YouTube’s current guidance. |
Use journalctl -u <unit> to inspect the service journal, replacing <unit> with the actual service name. Check FFmpeg’s own logs as well: systemd explains whether the process was restarted, while FFmpeg’s error output is needed to identify why it stopped or lost output. Keep stream keys out of copied logs.
Or let it run in the cloud
If maintaining FFmpeg, systemd, and a host is more work than you want, StreamNeo keeps a YouTube channel live 24/7 from uploaded videos: upload a recording or make a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home; it streams the uploaded video as made, up to 4K 60fps, at one price per slot for any quality; and it automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. See StreamNeo or its plans. Start your free day with StreamNeo.
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.




