Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › church streaming

How to Set Up systemd to Restart a Church FFmpeg YouTube Stream

By Freedom251 Team · · 5 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

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

To restart a church’s FFmpeg YouTube stream after an encoder failure, run FFmpeg in the foreground under a systemd service with Restart=on-failure and a short RestartSec delay. Enable the service at boot, then verify both the process and YouTube’s stream health: systemd can relaunch FFmpeg, but it cannot by itself confirm that YouTube is receiving a healthy feed.

What this setup does—and what it cannot do

systemd supervises the FFmpeg process. With Restart=on-failure, it can start FFmpeg again after an unsuccessful exit, qualifying signal, timeout, or watchdog failure. A restart does not fix a persistent problem such as an invalid stream key, missing camera feed, rejected ingest, or broken network. Nor does an active systemd service prove that viewers can see the broadcast.

As an Amazon Associate I earn from qualifying purchases.

There are two recovery layers: FFmpeg may reconnect to a supported transport without exiting, while systemd can relaunch FFmpeg after the process exits. Which layer helps depends on what failed and the protocol and direction involved.

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

Create a systemd unit for FFmpeg

The following is a starting template, not a tested configuration. Replace the example account, input, output, and options with values that match your Linux host and stream. Keep FFmpeg in the foreground so systemd can supervise its process.

#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
[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
  • User=stream is an example. Use an account with access to the input and any required files, but avoid running the stream with broader privileges than needed.
  • /usr/bin/ffmpeg is an example executable path; check where FFmpeg is installed on your host.
  • INPUT and OUTPUT_WITH_STREAM_KEY are placeholders. Use the actual input and YouTube ingest destination and key for your setup.
  • The codecs and output options are examples, not universal requirements. Match them to the source and YouTube’s current guidance for the resolution, frame rate, codec, and ingest protocol you select.

Protect the YouTube stream key

A stream key identifies where the encoder sends its feed and lets YouTube accept it. Treat it as a credential: do not post it in public examples or expose it in logs, and restrict access to wherever it is stored. If it is compromised, YouTube says you can reset it in Live Control Room. See YouTube’s stream-key guidance.

Save, enable, and inspect the service

  1. Create /etc/systemd/system/church-stream.service with the unit above, edited for your host and stream.
  2. Tell systemd to reload unit files: sudo systemctl daemon-reload.
  3. Enable the service at boot and start it now: sudo systemctl enable --now church-stream.service.
  4. Check the service state: systemctl status church-stream.service.
  5. Follow its logs while it runs: journalctl -u church-stream.service -f.

To stop it intentionally, run sudo systemctl stop church-stream.service. An explicit stop suppresses automatic restart. Consult the installed systemd.service manual for directives and start-rate behavior supported by your systemd version.

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

Choose restart behavior that matches the failure

Restart=on-failure is a practical default for an encoder that should return after an error. systemd’s documented choices also include no, on-success, on-abnormal, on-abort, on-watchdog, and always; no is the default. With on-failure, a clean FFmpeg exit is treated differently from a crash or other qualifying failure.

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

RestartSec=5 in the example spaces restart attempts by five seconds. Repeated failures are also subject to systemd start-rate limiting, so a persistent fault may eventually prevent further starts until the service is reset or the underlying problem is fixed. A rapid restart loop is not a recovery plan for a bad key, absent input, or unavailable network. Check the manual for your installed systemd release because available directives and limits can vary.

Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit

Do not confuse FFmpeg reconnects with service restarts

FFmpeg documents options such as reconnect, reconnect_at_eof, reconnect_on_network_error, reconnect_on_http_error, reconnect_streamed, and retry limits for HTTP(S) protocol behavior. Those options are not universal controls for every protocol or for RTMP/RTMPS output. Check the documentation for your installed FFmpeg build and the specific protocol, direction, and failure before adding reconnect flags. FFmpeg protocol documentation describes the relevant protocol options.

First identify the failing part: the camera or file input, the FFmpeg process, or the connection to YouTube. If FFmpeg remains running during a supported transport interruption, a protocol-level reconnect may be relevant. If FFmpeg exits, systemd can apply its restart policy. Neither mechanism can make an invalid key or unavailable source work.

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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Match the encoder settings and verify YouTube ingest

YouTube’s live encoder guidance, accessed in 2026, lists RTMP/RTMPS protocols and H.264, H.265, and AV1 codecs, supports frame rates up to 60 fps, recommends constant bitrate (CBR), and recommends a two-second keyframe frequency that should not exceed four seconds. Use the current YouTube table row for your codec, resolution, and frame rate rather than treating one bitrate as right for every stream.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 are values from YouTube’s current encoder guidance accessed in 2026; the page does not show a publication year. YouTube’s networking guidance recommends 20% upload headroom and warns that a connectivity disruption can break a stream. The actual source quality and available uplink should inform your settings. See YouTube’s encoder settings, bitrates, and resolutions and YouTube’s networking guidance.

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.

Before a service, test with audio and video activity similar to the intended stream. YouTube advises: “Make sure to test before you start your live stream.” Watch stream health and messages in Live Control Room; a running unit alone is not confirmation that YouTube is receiving or presenting the broadcast correctly.

Troubleshoot common restart problems

Symptom What to check Next step
The service will not start systemctl status and journalctl -u church-stream.service for an invalid unit, executable path, permission issue, or FFmpeg error. Correct the unit or access problem, then run sudo systemctl daemon-reload and start the service again.
FFmpeg restarts repeatedly Journal output for an unavailable input, rejected key, or network problem; check whether systemd start-rate limiting has taken effect. Fix the persistent cause before trying again. Repeated relaunches cannot correct an invalid source or credentials.
systemd says the service is active, but YouTube has no healthy feed FFmpeg output and YouTube Live Control Room stream health and messages. Confirm FFmpeg is sending data, the input is present, the key and ingest destination are correct, and the network can sustain the chosen settings.
A network interruption does not recover Whether FFmpeg exited or stayed running, and whether the affected protocol and direction support the reconnect option being considered. Use a documented FFmpeg protocol option only when it applies; let systemd handle qualifying process exits.
The service stays stopped after an operator stopped it Whether systemctl stop was used intentionally. Start it again explicitly with sudo systemctl start church-stream.service; an intentional stop does not trigger automatic restart.

Or let it run in the cloud

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

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
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.

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

church streamingFFmpegLinuxsystemdYouTube Live

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.