Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
DocumentaryTube
Admit one · Blog

How to Use systemd to Keep an FFmpeg YouTube Stream Running on Hetzner

A practical systemd unit structure and workflow for supervising FFmpeg on a Hetzner Linux server, with YouTube ingest verification and troubleshooting.
Opened Runtime6 min Written byDocumentaryTube Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Run FFmpeg in the foreground under a systemd service, then set Restart=on-failure and a deliberate restart delay. This lets systemd restart FFmpeg after a process failure; it does not prove that YouTube is receiving healthy video. Confirm reception separately in YouTube Live Control Room.

What systemd can—and cannot—recover

systemd supervises the service process. For a long-running FFmpeg job, keep FFmpeg in the foreground so it remains the service’s main process and systemd can observe when it exits. A restart policy such as Restart=on-failure can recover from qualifying process failures, subject to systemd’s start-rate limits. It does not necessarily detect an FFmpeg process that stays alive while input, encoding, or delivery to YouTube has stalled. systemd service documentation.

This guide gives a unit-file structure, not a tested end-to-end FFmpeg command. Replace the illustrative placeholders with your actual input, encoding options, ingest details, and absolute paths; confirm the installed FFmpeg binary path and available options on your server. No particular Hetzner server size, firewall rule, or plan is established here.

Prepare the stream and server account

Create a dedicated service account

Use a dedicated, unprivileged Linux account, such as stream, rather than running the encoder as root. Prepare a working directory and an input or configuration location that this account can read. For example, the unit outline below assumes /srv/stream; create and permission directories to match your own setup.

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

Get the YouTube ingest details

Use the ingestion address and stream key supplied for your YouTube Live stream. YouTube’s LiveStreams resource distinguishes primary and backup ingestion addresses and supports RTMP and RTMPS ingest types. A single-output service should use the chosen address; the presence of a backup address does not mean this service sends to both. YouTube LiveStreams API.

Where your encoder and selected YouTube endpoint support it, prefer RTMPS. YouTube documents RTMPS as RTMP over TLS: the connection must use port 443, and TLS SNI must identify the ingestion server hostname. Use the exact endpoint YouTube provides rather than guessing or modifying its host. YouTube RTMPS guide.

Rank #2
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)

Protect the stream key

Treat the key like a password: anyone who obtains it may be able to send to your broadcast. Do not put a real key in a publicly readable unit file, a screenshot, an article example, or shell history. systemd warns that environment variables are not suitable secret storage because they may be exposed through D-Bus and passed to child processes. Consider a credential mechanism supported by the systemd version installed on your host, and restrict permissions on any file used to deliver the key. systemd execution documentation.

Create a foreground FFmpeg systemd service

Save a service unit such as /etc/systemd/system/ffmpeg-youtube.service. This is a structural example only, not a tested FFmpeg command. The angle-bracket text is explanatory placeholder text; replace it with valid arguments for your input and output. Do not paste the placeholders literally.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Unit]
Description=FFmpeg YouTube live stream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=stream
WorkingDirectory=/srv/stream
ExecStart=/usr/bin/ffmpeg <input-and-encoding-options> <youtube-ingest-url>
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Set the details to match your host

  • ExecStart: use the actual absolute FFmpeg path and a foreground invocation. The placeholder does not specify or validate FFmpeg flags; consult the documentation for the installed FFmpeg build and choose input and encoding settings appropriate for the source and YouTube ingest details.
  • User and WorkingDirectory: use the service account and directory you prepared. Confirm the account can read the input and any required configuration or credential files.
  • Restart=on-failure: asks systemd to restart the service after qualifying failure, rather than treating every intentional clean exit as a failure. The service documentation recommends this policy for long-running services.
  • RestartSec=5: illustrates a five-second pause before a restart attempt. Choose a considered delay for your workload; repeated rapid failures can run into start-rate limits.
  • Network ordering: the example expresses a desire to start after the network is online. It is not a guarantee that YouTube is reachable or that the stream is healthy.

Load, enable, and start the service

  1. Reload unit definitions: run sudo systemctl daemon-reload after creating or changing the unit file.
  2. Enable it for boot: run sudo systemctl enable ffmpeg-youtube.service.
  3. Start it now: run sudo systemctl start ffmpeg-youtube.service.
  4. Inspect service state: run sudo systemctl status ffmpeg-youtube.service. This reports systemd’s view of the process, not YouTube’s reception health.
  5. Read recent logs: run sudo journalctl -u ffmpeg-youtube.service -n 100 --no-pager. FFmpeg’s stderr is commonly where to look for process errors when the service fails.

Verify the incoming stream in YouTube

Open YouTube Live Control Room and check whether YouTube detects the incoming stream and reports its health. A systemd state of active means the process is running from systemd’s perspective; it does not establish that valid video and audio are reaching YouTube. YouTube’s health messages can identify configuration problems such as bitrate, codec, framerate, GOP, or insufficient video. YouTube stream health status messages.

If systemd says the service is active but YouTube reports no incoming data or unhealthy video, troubleshoot the input, encoding, and ingest connection. Restart automation is not a substitute for confirming the stream at the receiver.

Rank #4
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
  • 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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the failure you actually have

FFmpeg exits and systemd restarts it

  • Inspect the unit’s recent journal entries for FFmpeg stderr and the exit reason.
  • Check that the FFmpeg path, working directory, input paths, and file permissions are correct for the service account.
  • Verify the process can read its input and any protected configuration or credential files.

Restart=on-failure handles process failures and certain timeouts; it does not promise recovery from every application-level stall.

FFmpeg stays active but YouTube receives nothing

Check the incoming status and health in Live Control Room or the corresponding LiveStreams resource. Investigate whether the input is producing data, whether encoding is yielding usable audio/video, and whether the service is sending to the correct ingest address. An active process alone is not evidence of a working broadcast. YouTube LiveStreams API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
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

RTMPS reports TLS or connection errors

Confirm that you are using the RTMPS address supplied by YouTube, that the connection targets port 443, and that TLS SNI identifies the ingest hostname. Also confirm that the installed encoder supports the connection method you selected. YouTube’s RTMPS requirements are documented in its RTMPS ingestion guide.

Restart attempts stop after repeated failures

systemd applies start-rate limits, so a service that repeatedly fails may stop being restarted automatically. Check the service status and manager logs for rate-limit messages. Fix the underlying failure before resetting or starting the service again; do not configure a tight, unlimited restart loop. systemd service documentation.

YouTube reports a stream-health warning

Read the specific health issue rather than changing settings at random. YouTube’s categories can point to bitrate, video or audio codec, framerate, GOP length, or insufficient incoming video data. YouTube health status reference.

RTMP or RTMPS?

Choice What it means What to check
RTMP YouTube’s LiveStreams resource includes RTMP ingest addresses. Use the actual address and key provided for the stream, and confirm encoder compatibility.
RTMPS RTMP carried over TLS, with an RTMPS endpoint available where supported. YouTube specifies port 443 and TLS SNI using the ingestion server hostname. Check encoder compatibility and the exact supplied endpoint.

Neither choice removes the need to verify YouTube’s received-stream health. Endpoint availability depends on the ingest details YouTube provides for the stream.

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

Or let it run in the cloud

If your goal is to keep uploaded video playing as a 24/7 YouTube live stream rather than maintain an FFmpeg server, StreamNeo is the cloud alternative. Upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home; it streams your upload as made, up to 4K 60fps, at one price per slot, and it automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. For Indian users, UPI works. This is for uploaded videos, not a live camera feed, and StreamNeo streams to YouTube only. 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 4 4GB Starter PRO Kit - 4GB RAM
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
$159.99
Bestseller No. 4
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
Raspberry SC15184 Pi 4 Model B 2019 Quad Core 64 Bit WiFi Bluetooth (2GB)
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
$92.97
Bestseller No. 5
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

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.

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.

More from the Screening Room

  1. How to Migrate a 24/7 YouTube Stream to a New VPSAdmit one · BlogHow to Migrate a 24/7 YouTube Stream to a New VPSOpened04 OCT 2026Runtime6 min
  2. How to Run a YouTube Playlist on a Headless Linux Server—and Broadcast It LiveAdmit one · BlogHow to Run a YouTube Playlist on a Headless Linux Server-and Broadcast It LiveOpened04 OCT 2026Runtime6 min
  3. How to Make a 24/7 Indian Music YouTube Stream Restart After a Server RebootAdmit one · BlogHow to Make a 24/7 Indian Music YouTube Stream Restart After a Server RebootOpened04 OCT 2026Runtime6 min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.