To keep prerecorded music streaming to YouTube Live around the clock from Ubuntu, run FFmpeg in the foreground and let a systemd service start it at boot and restart it after failures. YouTube Studio provides the stream’s ingest URL and private stream key; systemd can supervise the process, but it cannot guarantee that YouTube is receiving a healthy stream. This guide sets up the service, checks the stream at both ends, and explains the rights and failure cases that automation cannot solve.
How the setup works—and what it does not guarantee
Your Ubuntu machine reads a prerecorded media file and sends it to YouTube Live using FFmpeg. systemd starts FFmpeg during boot and can retry it after an unexpected exit. Keep FFmpeg in the foreground: systemd then tracks the encoder process directly instead of a detached child.
This is process supervision, not end-to-end stream monitoring. A service can show as running while YouTube ingest is unhealthy, the audio is silent, or the stream is interrupted for a platform-side reason. Confirm the result in YouTube Live Control Room and on a viewer device.
The Ubuntu machine must remain powered and connected to the internet. This approach can use an existing computer or a rented Linux host, but the available evidence does not establish hardware sizing, host prices, or uptime guarantees for either choice.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#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.
Check YouTube eligibility and prepare the stream
Enable live streaming and create an encoder stream
-
In YouTube Studio, enable live streaming for your channel and complete any verification requirements. YouTube says the channel must be verified and must not have had live-streaming restrictions in the previous 90 days. First-time enablement can take up to 24 hours. See YouTube’s live-streaming setup guidance.
-
Create or schedule a live stream in YouTube Studio for encoder software. Copy the ingest URL and stream key from the stream settings. Treat the key like a password: anyone with it may be able to send video to your stream. YouTube’s encoder setup guidance explains how the encoder connects.
-
Use the ingest URL and key together in FFmpeg’s output destination. YouTube supports RTMP and RTMPS; use the protocol and URL shown for your stream rather than assuming every channel or setup has the same destination.
Confirm that you have rights to the music
Use audio and any accompanying video that you have the necessary rights to stream worldwide on YouTube. The platform scans live streams for third-party content and may replace the picture, interrupt the stream, or terminate it. Even licensed material may be interrupted unless the relevant rights holder allowlists your channel. YouTube’s livestream terms put the responsibility on the creator to have necessary rights, including music licensing rights.
Free tools Windows power users keep installed
One-click scans. No signup required.
Do not assume that a track is safe to stream because it is available online, included in a game, or licensed for some other use. Check that your permission covers the live broadcast and the relevant territory and rights.
Choose media settings that YouTube and your host can handle
YouTube’s current encoder guidance lists H.264, H.265, or AV1 video; AAC or MP3 audio; constant bitrate (CBR); and a recommended two-second keyframe interval that should not exceed four seconds. For 1080p30 H.264, YouTube lists 5 Mbps as the minimum and 14 Mbps as the recommended video bitrate. These are platform recommendations, not a guarantee that your machine can encode or upload at that rate. Consult YouTube’s live encoder settings for other resolutions and formats.
If your file already has compatible video and audio streams, FFmpeg can copy them without re-encoding. That avoids an unnecessary encoding step, but it does not make an incompatible file compatible. Inspect and test your actual media before leaving it unattended. If you encode instead, choose settings supported by YouTube and your CPU, and test the resulting stream.
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.
YouTube recommends leaving about 20% upload-bandwidth headroom above the stream bitrate. This is platform guidance, not a measured guarantee. Check sustained upload capacity—not just a brief speed-test peak—and test with representative audio and motion. YouTube’s encoder guidance and stream health guidance cover bitrate and monitoring.
Install FFmpeg and create a dedicated service account
On the Ubuntu release you run, install FFmpeg from the Ubuntu package source appropriate to that release, then confirm the executable path. The unit example below assumes `/usr/bin/ffmpeg`; adjust it if your installation differs. Package availability and exact installation commands can vary by Ubuntu release.
Create a dedicated unprivileged account named `stream` and a working directory such as `/srv/youtube-music`. Put the media file there and make sure that account can read it. Avoid running a continuously exposed encoder as root.
Test the media manually before enabling the service. For a compatible file named `loop.mp4`, a basic local read check is:
/usr/bin/ffmpeg -i /srv/youtube-music/loop.mp4
Review the detected streams and resolve file, codec, or permission errors first. FFmpeg’s documentation defines `-stream_loop -1` as looping an input indefinitely. If systemd later restarts FFmpeg, playback may begin again from the start; looping alone does not implement resume-from-position behavior.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Keep the stream key out of the unit file
Put the stream key in a protected environment file, for example `/etc/youtube-music.env`, owned by root with mode `0600`. Use this single line, replacing the value locally with your actual key:
YOUTUBE_STREAM_KEY=REPLACE_WITH_YOUR_PRIVATE_KEY
Do not publish the real key in a script, repository, support post, or article. Reset it in YouTube Studio if you believe it has been exposed. An environment file limits casual exposure, but environment variables can still be visible to privileged users or processes on the host; restrict host access as well.
Rank #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.
Systemd does not perform shell expansion in `ExecStart=` as a shell would. Do not put `${YOUTUBE_STREAM_KEY}` directly into the FFmpeg command and assume it will be substituted. One practical approach is a small executable wrapper that reads the environment variable and uses `exec` to replace itself with FFmpeg. Keep that wrapper root-owned and not writable by the service account. Avoid printing the key in logs or command output.
For example, create `/usr/local/bin/youtube-music-start` with the following contents, adjusting the ingest URL if YouTube Studio gives you a different one:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#!/bin/sh
set -eu
: "${YOUTUBE_STREAM_KEY:?YOUTUBE_STREAM_KEY is not set}"
exec /usr/bin/ffmpeg -re -stream_loop -1
-i /srv/youtube-music/loop.mp4
-c:v copy -c:a copy
-f flv "rtmp://a.rtmp.youtube.com/live2/${YOUTUBE_STREAM_KEY}"
Set the wrapper to be executable and ensure only an administrator can modify it. The command assumes a media file whose audio and video can be copied into the FLV output; test your file and use the ingest URL provided by YouTube. The `-re` option reads the input at its native rate, which is appropriate for a prerecorded file being sent as a live stream.
Create and enable the systemd service
Create `/etc/systemd/system/youtube-music.service`:
[Unit]
Description=YouTube music stream
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=stream
WorkingDirectory=/srv/youtube-music
EnvironmentFile=/etc/youtube-music.env
ExecStart=/usr/local/bin/youtube-music-start
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
`Restart=on-failure` asks systemd to restart the service when it exits unsuccessfully. `RestartSec=15` waits 15 seconds before a retry. The network-online target is a boot-ordering aid, not proof that the host has working internet access or can reach YouTube.
-
Reload unit definitions after creating or changing the service:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.sudo systemctl daemon-reload -
Enable the service at boot and start it now:
sudo systemctl enable --now youtube-music.service -
Check whether systemd considers the process active:
Rank #4
SaleUGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray- 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
systemctl status youtube-music.service -
Read the service log while it runs:
journalctl -u youtube-music.service -f
Keep FFmpeg attached to the foreground process. Do not add a detaching option or launch it in the background from the wrapper; systemd needs to track the process it is meant to supervise.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Verify the live stream at YouTube and on a viewer device
After starting the service, open the stream in YouTube Live Control Room. Wait for the preview and inspect the stream health panel; then check that the public or unlisted playback has audible sound on a separate viewer device. Test with representative audio and motion before relying on the setup. A successful `systemctl status` check proves only that the service process is running, not that viewers can hear or see the stream.
Continue monitoring both the systemd journal and YouTube’s stream health. YouTube may drop or interrupt an ingest even while the host and FFmpeg remain available. The platform recommends testing and monitoring rather than treating encoder output as proof of a healthy broadcast.
Troubleshoot failures by checking both layers
Service is failed or keeps restarting
-
Check `systemctl status youtube-music.service` and `journalctl -u youtube-music.service` for the first FFmpeg error, not only the latest restart.
-
Confirm that the wrapper exists and is executable, the media path is correct, and the `stream` account can read both the file and any required configuration.
-
Validate FFmpeg’s input and output options with the actual file. A looping option cannot repair a corrupt file or unsupported output combination.
-
Check the environment file’s root ownership, restrictive permissions, and key variable name. Do not paste the secret key into a public log or support request.
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.Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display- 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.
Service is active but YouTube shows no signal or poor health
-
Compare the configured ingest URL and key with the current stream settings in YouTube Studio. If a key was reset or rotated, update the protected environment file and restart the service.
-
Check internet connectivity and sustained upload capacity. Leave roughly 20% headroom beyond the stream bitrate as YouTube recommends.
-
Review the stream health panel for bitrate, connection, or media warnings; then check playback on a viewer device for silent or missing audio.
-
Verify that the file’s codecs and container work with the chosen output. Stream-copy settings that work for one file may not work for another.
DriversOutdated Drivers Are Slowing You DownPerformancePC Slower Than It Used to Be?DriversCrashes, No Sound, or Screen Glitches?Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Retries stop or the stream is interrupted despite a running service
systemd subjects restart attempts to unit start-rate limiting. An overly short restart loop can exhaust the limit and leave the service failed; a reasonable delay such as the example’s 15 seconds reduces rapid retries but does not guarantee recovery. Inspect the journal and systemd status, correct the underlying failure, and then start the unit again if needed. Restarting cannot fix sustained network outages, invalid media, expired credentials, copyright interruptions, or a YouTube-side ingest problem. YouTube may also interrupt or end streams after detecting third-party content.
Or let it run in the cloud
If maintaining an Ubuntu host and systemd unit is not the part you want to manage, StreamNeo keeps an uploaded video or playlist looping to YouTube Live from the cloud. Upload the recording, add your YouTube stream key, and go live. Nothing has to stay on at home; it supports any quality up to 4K 60fps as uploaded at one flat 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. It streams to YouTube, not from a camera. 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.




