Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep FFmpeg in the foreground under a systemd service, then set Restart=on-failure and a measured RestartSec delay. This lets systemd relaunch FFmpeg after qualifying failures and start it at boot. It does not, by itself, prove that YouTube has accepted the feed or that viewers can see it; verify stream health in YouTube Live Control Room.

1. Create a systemd service for FFmpeg

Use this as a starting template, not a drop-in configuration. Replace the example account, FFmpeg path, input, codecs, and output with values that match the Linux host and your stream. Keep FFmpeg in the foreground so systemd can supervise its process.

[Unit]
Description=Church FFmpeg YouTube stream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=stream
ExecStart=/usr/bin/ffmpeg -i INPUT -c:v libx264 -c:a aac -f flv 'OUTPUT_WITH_STREAM_KEY'
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

The stream user and /usr/bin/ffmpeg path are examples. Check the executable path on your system, and use the actual source and output syntax required by your FFmpeg build and YouTube ingest setup. The sample codecs are not a requirement for every source or workflow.

Save, enable, and start it

  1. Save the unit as /etc/systemd/system/church-stream.service.
  2. Tell systemd to load the new or changed unit: sudo systemctl daemon-reload.
  3. Enable it at boot and start it now: sudo systemctl enable --now church-stream.service.
  4. Check the current service state: systemctl status church-stream.service.
  5. Follow its logs while it runs: journalctl -u church-stream.service -f.

Systemd directives and start-rate behavior can vary by installed release. Consult the manual for the systemd version on the host if a directive behaves differently or repeated failures stop producing restart attempts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • 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

Protect the stream key

The YouTube stream key is a credential: it identifies where the encoder sends its feed and lets YouTube accept it. Anyone who obtains it may be able to send a feed to that stream. Avoid sharing it in public examples or exposing it in logs, and restrict access to wherever it is stored. YouTube says a compromised key can be reset in Live Control Room: YouTube Help: Set up your encoder.

2. Understand what systemd will restart

With Restart=on-failure, systemd restarts the service after qualifying failures, including a nonzero exit, certain signals, a timeout, or a configured watchdog failure. A clean FFmpeg exit is different: it does not meet the ordinary failure condition for this policy. The systemd service manual documents the restart modes and their behavior: systemd.service.

Rank #2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
  • 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
  • RestartSec=5 in the template spaces restart attempts by five seconds; choose a delay appropriate to the cause and your recovery needs.
  • Repeated failures are subject to systemd start-rate limiting. A persistent bad key, missing input, rejected ingest, or broken network will not be fixed by retrying indefinitely.
  • An intentional systemctl stop church-stream.service suppresses automatic restart. Use systemctl start church-stream.service when you want to run it again.

For other policies, the manual lists no (the default), on-success, on-failure, on-abnormal, on-abort, on-watchdog, and always. Choose based on how FFmpeg exits and whether a clean exit should mean “done” or “restart.”

3. Separate process recovery from connection recovery

There are two different failure layers. Systemd acts when the supervised FFmpeg process exits in a way covered by its restart policy. FFmpeg may also reconnect through protocol-specific options while it remains running. The FFmpeg protocol documentation describes options such as reconnect, reconnect_at_eof, reconnect_on_network_error, reconnect_on_http_error, reconnect_streamed, and retry limits for HTTP(S) behavior: FFmpeg protocols documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit

Those HTTP(S) controls are not universal fixes for an RTMP or RTMPS output. First identify whether the failure is at the input (for example, a camera feed), in the FFmpeg process, or at the output connection. Apply reconnect options only when the installed FFmpeg version documents them for that protocol and direction.

4. Match FFmpeg output to YouTube’s live guidance

A service can be active while sending an unusable feed. YouTube’s current encoder guidance, accessed in 2026, lists RTMP and RTMPS as streaming protocols, supports H.264, H.265, and AV1 codecs, and gives a recommended two-second keyframe frequency that should not exceed four seconds. Its bitrate guidance varies by codec, resolution, and frame rate; use the row that matches your actual output rather than treating one bitrate as universal. YouTube recommends RTMPS: Choose live encoder settings, bitrates, and resolutions.

Rank #4
SANOOV Raspberry Pi 5 4GB Kit, 4GB RAM Single Board Computer with Active Cooler and ABS Case, Complete Raspberry Pi 5 Starter Kit for IoT Robotics Retro Gaming
  • All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
  • Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
  • Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
  • Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
  • Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online
Example YouTube H.264 setting Minimum bitrate Recommended bitrate
720p at 30 fps 3 Mbps 8 Mbps
1080p at 30 fps 5 Mbps 14 Mbps

These figures are YouTube’s current encoder-table guidance accessed in 2026, not guarantees for every source or network. YouTube’s networking guidance recommends 20% upload headroom and warns that connectivity disruption can break a stream: YouTube live encoder network guidance. Reserve capacity for other devices and traffic on the same connection.

5. Test both the service and the broadcast

  1. Start the service and inspect systemctl status church-stream.service for its state and recent output.
  2. Follow journalctl -u church-stream.service -f to see whether FFmpeg is still running, exits, or reports input/output errors.
  3. Before a service, test with audio and video movement similar to the intended stream. YouTube says, “Make sure to test before you start your live stream.”
  4. In YouTube Live Control Room, check stream health and review any messages. Confirm the expected picture and sound rather than relying on the systemd status alone.

A controlled failure test can confirm whether this unit is restarted as configured, but perform it before the real event and verify the result in both the service logs and Live Control Room. A running unit only establishes that systemd sees its process as running; it is not proof of a healthy broadcast.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
  • 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
  • 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
  • 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
  • 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Troubleshoot common failure patterns

Symptom Likely area to check Next step
The service fails immediately Unit syntax, executable path, user permissions, or FFmpeg arguments Read systemctl status church-stream.service and the journal. Check that the configured FFmpeg path exists and that the service user can access the input and required files.
FFmpeg exits, then keeps retrying A persistent input, key, ingest, or network problem Inspect the FFmpeg error in the journal and correct the underlying issue; restarts alone will not repair it.
The unit is running, but YouTube reports no healthy feed Output connection, ingest settings, or stream configuration Check the output protocol and key, FFmpeg output errors, and Live Control Room stream-health messages.
The service stopped after an intentional stop Expected systemd behavior Run sudo systemctl start church-stream.service when ready to resume.
Restart attempts cease after repeated failures Systemd start-rate limiting Inspect the service state and logs, fix the cause, and consult the installed systemd manual for the host’s rate-limit behavior.
Input disconnects but FFmpeg remains alive Input protocol recovery rather than process supervision Check whether the input protocol and installed FFmpeg version support an applicable reconnect option. Do not assume an HTTP reconnect option repairs an RTMP(S) output.

Or let it run in the cloud

If you do not want a church computer or home connection to keep FFmpeg running, StreamNeo keeps an uploaded video or playlist live on YouTube from the cloud. Upload the recording, add your YouTube stream key, and go live. Nothing has to stay on at home; each slot streams the upload as made, up to 4K 60fps, at one price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly: $9.99 per month. Start your free StreamNeo day.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
CanaKit Raspberry Pi 5 16GB Starter Kit PRO - Turbine Black (128GB Edition) (16GB RAM)
Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$419.99
Bestseller No. 3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
CanaKit Raspberry Pi 5 Essentials Starter Kit
$189.99

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.