You can keep a YouTube radio stream running from Linux by having systemd supervise a foreground encoder such as FFmpeg. The service can restart the encoder after a failure, but it cannot create the YouTube broadcast or confirm that listeners are receiving healthy audio and video. You still need a valid stream key and ingest URL, a suitable media loop, and a check of the preview in YouTube Live Control Room.
What systemd can—and cannot—do
A systemd service starts and supervises a process on your Linux host. With a suitable restart policy, it can relaunch FFmpeg after an unexpected exit. It does not verify the audio, ensure a YouTube broadcast is public, or recover a stream that is stalled while the encoder process remains alive. For that, check the received stream in YouTube Live Control Room and consider monitoring it independently.
This setup is for an encoder-based stream, not a camera broadcast. A VPS can keep the host online when your desktop is off, but you remain responsible for the host, media files, network capacity, monitoring, and any provider limits or data-transfer charges.
Prepare YouTube and the Linux host
Enable live streaming and create a stream
- On the YouTube account that will broadcast, enable live streaming. YouTube says first-time enablement may take up to 24 hours.
- In YouTube Live Control Room, create or schedule the stream and open its stream settings.
- Copy the ingest URL and the matching stream key. Prefer the RTMPS endpoint when your encoder supports it; YouTube advises obtaining the RTMPS URL rather than assuming the ordinary RTMP address shown by default. RTMPS is RTMP carried over TLS/SSL. See YouTube’s encoder setup instructions and RTMPS guidance.
Prepare media and FFmpeg
Install FFmpeg using the method appropriate for your Linux distribution, and choose an input whose codecs, frame rate, and duration suit the broadcast. The example below loops a local video file; it is not a universal command. Test your exact FFmpeg invocation interactively before putting it under systemd. Use absolute paths, keep FFmpeg in the foreground, and avoid an unneeded shell pipeline so systemd can track the encoder process and its exit status.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
For a radio-style channel, decide whether you want a static visual, a rotating set of visuals, or audio-only output accepted by your broadcast setup. A file loop is only one way to provide continuous media; the input and encoding or copy options must match the actual files and YouTube’s ingest requirements. Do not assume that a command using stream copy works with every input or output container.
Protect the stream key before creating the unit
A YouTube stream key is a connection credential. Do not publish it in a script repository, screenshot, public command example, or diagnostic log. Avoid placing the complete destination URL on a command line where it may be visible in process listings. If a key has been exposed, replace it in YouTube Live Control Room and update the service configuration.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Store the secret in a root-controlled configuration or use a systemd credential facility only after confirming that the installed systemd version supports the directives you intend to use. Restrict access to the configuration to the service account or group as needed. The exact secure mechanism depends on the distribution and systemd version; validate it locally rather than assuming a directive works everywhere.
Create a service that keeps FFmpeg in the foreground
Create a dedicated service account and working directory
Use a dedicated unprivileged account, here named ytstream, and a stable media directory such as /srv/yt-radio. Ensure that account can read the media and its protected configuration, but does not receive broader permissions than it needs. The following unit is a teaching skeleton, not a paste-ready configuration: its illustrative FFmpeg line uses placeholders and must be adapted and tested.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
[Unit]
Description=YouTube radio stream
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=ytstream
Group=ytstream
WorkingDirectory=/srv/yt-radio
EnvironmentFile=/etc/yt-radio/stream.env
ExecStart=/usr/bin/ffmpeg -re -stream_loop -1 -i /srv/yt-radio/radio.mp4 -c:v copy -c:a aac -f flv $YOUTUBE_OUTPUT
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Type=simple tells systemd to treat the started process as the service. User and Group run it without root privileges. WorkingDirectory sets its working directory; absolute paths in the command reduce ambiguity. Wants and After ask for network-online ordering, but do not guarantee that the network or YouTube is reachable. EnvironmentFile points to a protected environment file. RestartSec=5 waits five seconds before an eligible restart.
Systemd does not interpret ExecStart= as a shell command. In particular, it does not provide shell-style concatenation such as ${YOUTUBE_RTMPS_URL}/${YOUTUBE_STREAM_KEY}. In the skeleton, $YOUTUBE_OUTPUT is intended as one complete argument, subject to systemd’s environment expansion rules. A safer implementation may use a carefully quoted wrapper script to read a protected secret and construct the destination without printing it. Verify the precise behavior on your system and make sure logs do not expose the key.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Adapt the input path, loop behavior, codecs, and muxer to the media you will send. -re reads file input at its native rate, while -stream_loop -1 requests an indefinite loop; neither makes an incompatible file compatible. The sample copies video and encodes audio as AAC, so it is appropriate only if that combination suits your source and output. Confirm the FFmpeg executable path with your installation, then validate the unit with systemd-analyze verify /etc/systemd/system/yt-radio.service.
Choose a restart policy deliberately
Restart=on-failure is generally appropriate when FFmpeg should restart after an unexpected nonzero exit, signal, or configured timeout. Restart=always also restarts after a clean process exit. A deliberate systemctl stop does not trigger a restart. The upstream systemd.service manual documents the service restart behavior; check the manual for the version installed on your host.
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 →Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Load, start, and verify the service
- Save the unit as
/etc/systemd/system/yt-radio.serviceand create its protected configuration using the secret-handling method you verified. - Run
systemd-analyze verify /etc/systemd/system/yt-radio.serviceand resolve reported unit-file problems. - Reload systemd’s unit definitions:
sudo systemctl daemon-reload. - Enable the unit for startup and start it now:
sudo systemctl enable --now yt-radio.service. - Check process state with
sudo systemctl status yt-radio.serviceand follow its logs withsudo journalctl -u yt-radio.service -f. These show service and process information, not proof that YouTube is receiving healthy media. - Open the stream in Live Control Room, confirm that the preview has the expected picture and sound, and click Go live if YouTube requires it for this stream.
A locally active service is not the same thing as a successfully received or public broadcast. YouTube’s encoder workflow includes checking the stream in Live Control Room.
Make it resilient, not merely automatic
Test failure and reboot recovery
Before relying on the service, simulate an FFmpeg failure and confirm that the process returns, reconnects to YouTube, and resumes audio and video. Reboot the host and repeat the checks. These are tests you need to perform on your own system; enabling a unit does not prove either behavior. If the stream matters, arrange an out-of-band alert or check the received output as well as systemd’s active state: a process can remain alive while its output is stalled.
Plan for a continuous channel’s archive behavior
YouTube states that streams under 12 hours are automatically archived. Do not assume a single uninterrupted 24/7 stream will produce an automatic archive, or infer an undocumented rollover procedure from that under-12-hour rule. Plan recording and archive needs separately, and confirm the current behavior in YouTube’s documentation and Live Control Room.
Troubleshoot common failures
- RTMPS SSL error: Confirm that you copied the RTMPS endpoint, not an RTMP address, and that the FFmpeg build supports RTMPS. YouTube’s RTMPS help page suggests trying port 443 where relevant.
- Connection timeout: Check the endpoint, outbound network access, and encoder support for RTMPS. A configured network-online target does not establish reachability to YouTube.
- Service is active but YouTube shows no stream: Inspect the first relevant FFmpeg log error, confirm the input file is readable, verify the ingest URL and stream key, and check the Live Control Room preview. A running process alone cannot validate the broadcast.
- Repeated restart loop: Find the first encoder failure in
journalctlbefore increasingRestartSec. Check paths, permissions, secret configuration, codecs, and the output endpoint. A restart policy reacts to process termination and configured conditions; it cannot fix a persistent configuration error. - Unit fails to parse or destination is wrong: Review systemd’s environment expansion rules and avoid shell-style URL concatenation in
ExecStart=. Validate the unit, use one complete destination argument or a carefully reviewed wrapper, and ensure diagnostics never print the key. - No automatic archive appears: The documented automatic archive behavior is for streams under 12 hours. Do not rely on it for a longer continuous run.
Or let it run in the cloud
If maintaining a Linux host, FFmpeg unit, secrets, and stream monitoring is more work than you want, StreamNeo is a cloud service for keeping a YouTube channel live from uploaded videos. Upload a recording or build a playlist, add your YouTube stream key once, and go live; it loops the media in the cloud, so no computer or home connection has to stay on. It is for uploaded video playback, not a live camera feed, and streams to YouTube only.
Recommended Free Tools
- Nothing needs to stay powered on at home.
- Uploaded media streams as made, up to 4K 60fps, at one flat price per slot with no re-encode or quality tiers.
- It automatically recovers if YouTube drops the stream.
- The first day is free, with no card required; one free day is available per account.
Monthly: $9.99 per month. See StreamNeo plans and pricing, then 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.




