Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
Mountain View desk7 min

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

Use systemd to supervise foreground FFmpeg on a Hetzner Linux server, restart failed processes, and verify the incoming YouTube stream independently.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run FFmpeg in the foreground as a systemd service, then configure systemd to restart it when the process fails. On a Hetzner Linux server, that can bring the encoder back after a crash or reboot—but it does not prove YouTube is receiving a healthy stream. Verify the incoming feed separately in YouTube Live Control Room.

This guide shows the service setup and checks without prescribing an unverified FFmpeg command, Hetzner server size, or firewall rule. You must supply your own FFmpeg input and encoding options and the ingest details YouTube gives your channel.

As an Amazon Associate I earn from qualifying purchases.

What systemd can—and cannot—keep running

systemd supervises a process. If FFmpeg exits unsuccessfully, a policy such as Restart=on-failure can start it again after a delay. Running FFmpeg in the foreground lets systemd track its main process; do not daemonize it behind the service manager. systemd also applies start-rate limits, so repeated failures may eventually stop automatic restart attempts. See the systemd service documentation.

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

A process marked active is not necessarily sending valid video. FFmpeg can remain alive while its input, encoding, or connection to YouTube is stalled or rejected. Check the service journal and YouTube’s stream status as separate signals.

#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

Before creating the service

Prepare a dedicated account and readable files

  1. Create or choose a dedicated unprivileged Linux account for the stream. Give it read access to the media and configuration it needs, and avoid running FFmpeg as root.
  2. Choose a working directory and confirm the account can read the input file and any configuration it requires.
  3. Find the installed FFmpeg executable’s absolute path on the server. The example below uses /usr/bin/ffmpeg only as an illustrative path; replace it if the installed binary is elsewhere.

Get the YouTube ingest details

In YouTube Live Control Room, use the ingestion address and stream key assigned to the stream. YouTube’s LiveStreams resource distinguishes primary and backup ingestion addresses and supports RTMP and RTMPS ingest types: YouTube LiveStreams API. A backup address does not mean a single-output FFmpeg service is sending to both destinations.

Where your encoder and assigned ingest endpoint support it, prefer RTMPS. Google documents RTMPS as RTMP over TLS and specifies port 443 and the ingestion server hostname for TLS SNI: Delivering Live YouTube Content via RTMPS. The guide states, “The connection must be made to port 443 on the ingestion server.” Use the actual hostname and address YouTube provides; do not substitute a guessed endpoint.

Decide how to handle the stream key

Treat the stream key like a password. Do not put a real key in a publicly readable unit file, a screenshot, or shell history. systemd warns that environment variables are not suitable for secrets because they can be exposed through D-Bus and inherited by child processes; consult the systemd execution documentation for credential options supported by the systemd version installed on your server.

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

Choose a secret-delivery method that your installed systemd version and FFmpeg launch method can actually use, and restrict access to the secret file or credential. Check how the launch method passes the key onward: placing a key in an FFmpeg argument may expose it to users able to inspect process details, even if the unit file itself is protected. Do not assume that moving a secret into a credential file automatically prevents exposure in the final FFmpeg invocation.

Create a foreground systemd unit

Save a unit such as /etc/systemd/system/ffmpeg-youtube.service. This is a structural outline, not a tested end-to-end FFmpeg command. Replace the explanatory placeholders with the actual input, encoding options, and YouTube ingest destination for your setup. The angle-bracket text is not valid FFmpeg syntax. Arrange secure stream-key delivery for your chosen launch method; do not paste a real key into this example.

[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
  • Type=simple suits a foreground process: systemd tracks the process it starts.
  • User=stream and WorkingDirectory=/srv/stream are examples. Use the account and directory you prepared, and make sure the account can access required files.
  • ExecStart must use the correct absolute FFmpeg path and your real input and output configuration. This guide does not validate particular FFmpeg flags or a complete command line.
  • Restart=on-failure asks systemd to restart after failure; RestartSec=5 adds a delay before a restart attempt. Repeated attempts remain subject to systemd’s start-rate limits.

Load, enable, and start the service

  1. After saving the unit, ask systemd to reload unit definitions: sudo systemctl daemon-reload.
  2. Enable the service for startup at boot and start it now: sudo systemctl enable --now ffmpeg-youtube.service.
  3. Check the service state: sudo systemctl status ffmpeg-youtube.service. This reports systemd’s view of the service, not YouTube’s video health.
  4. Read recent service output, including FFmpeg stderr when it is sent to the journal: sudo journalctl -u ffmpeg-youtube.service -n 100 --no-pager. Follow new entries while diagnosing with sudo journalctl -u ffmpeg-youtube.service -f.
  5. Open YouTube Live Control Room and verify that YouTube detects the incoming stream and reports its health. Keep this check open through a restart or configuration change.

RTMP or RTMPS?

Choice Connection characteristics What to verify
RTMP YouTube’s LiveStreams resource includes RTMP ingest addresses. The cited material does not establish encryption for RTMP. Use the actual address assigned by YouTube and confirm that your encoder can connect to it.
RTMPS RTMP over TLS. Google’s guide specifies port 443 and requires TLS SNI to use the ingestion server hostname. Use the provided RTMPS endpoint; check the scheme, endpoint hostname, port, and SNI if TLS setup fails.

See Google’s RTMPS ingestion guide and the LiveStreams resource for endpoint details. This one-output service outline does not implement simultaneous delivery to a backup ingest address.

Diagnose failures by separating process health from stream health

FFmpeg exits or systemd reports a failed unit

  • Read the unit’s recent journal entries and identify FFmpeg’s first relevant error, rather than treating later restart messages as the root cause.
  • Check the executable and input paths, file permissions, working directory, and whether the service account can read the media and configuration.
  • Check that the ingest address and secret-delivery method are configured correctly without copying the key into a public log or support post.

Restart=on-failure can respond to a process failure; it does not correct a bad path, invalid input, or rejected output settings.

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

systemd says active, but YouTube shows no incoming video

Use YouTube Live Control Room and its ingest status or health information. The LiveStreams resource exposes stream states such as active, inactive, error, and ready, along with health information. Investigate the input, encoding, and connection to the ingest endpoint; a live FFmpeg process alone is not confirmation of a valid feed. See YouTube LiveStreams API.

RTMPS reports a TLS or connection timeout error

Confirm the assigned endpoint uses the RTMPS scheme, that the endpoint is the one YouTube supplied, that the connection uses port 443, and that TLS SNI identifies the ingestion hostname. Google documents these requirements in its RTMPS guide. This guide does not establish Hetzner-specific firewall rules; check the current provider and server configuration for your own instance rather than guessing a rule.

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

YouTube reports a stream health warning

Use the issue category in YouTube’s health report to narrow the cause. Health messages can flag bitrate, codec, frame rate, GOP length, or insufficient video. Change the encoding or input configuration based on the reported problem, then confirm the new incoming feed in YouTube. See YouTube health status messages.

Restarts stop after repeated failures

Check the service and manager logs for start-rate-limit messages and examine the underlying FFmpeg error before trying again. Fix the cause first; avoid configuring a tight, unlimited restart loop. If the unit is rate-limited, use systemd’s documented unit and manager behavior to determine whether and when a reset is appropriate: systemd service documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What this setup does not establish

The service definition is independent of a particular Hetzner server size, price, or firewall rule. Choose infrastructure based on your actual workload and verify networking in the current provider documentation and configuration. No particular FFmpeg command or encoding flags are validated here; supply options appropriate to your input and check YouTube’s reported health rather than assuming a generic command will fit.

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

Restart supervision handles process exits, not every application-level stall or an unhealthy incoming feed. Monitor both systemd and YouTube, and investigate the failure mode each reports.

Or let it run in the cloud

If your goal is a looping, pre-recorded YouTube stream rather than running and maintaining your own FFmpeg service, StreamNeo keeps uploaded videos live from the cloud. Upload a recording or build a playlist, add your YouTube stream key, and go live; it loops uploaded videos, not a camera feed. Your computer and home connection do not have to stay on, and automatic recovery can restart the stream if YouTube drops it.

Every slot supports the uploaded quality up to 4K 60fps at one flat price per slot, without re-encoding or quality tiers. The first day is free with no card, one free day per account. Monthly billing is $9.99 per month. India-based customers can pay by UPI; cards are available worldwide. See StreamNeo pricing for the available billing lengths and details.

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.

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
  1. Upload a recording or create a playlist.
  2. Add your YouTube stream key once.
  3. Go live; StreamNeo loops the video from its cloud service.

Start your free StreamNeo day.

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 Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair 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.