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

To keep a prerecorded music stream running around the clock, run FFmpeg in the foreground on an always-on Ubuntu machine and let systemd start it at boot and restart it after failures. YouTube Studio supplies the ingest URL and stream key; FFmpeg sends the media to YouTube Live. This setup can recover from some process exits, but it cannot guarantee a healthy connection or bypass YouTube’s copyright checks.

How the setup works

YouTube Studio creates the live stream and provides its ingest URL and stream key. FFmpeg reads and loops a media file, then sends it to YouTube. A systemd service starts FFmpeg when Ubuntu boots and can restart it after an unexpected exit. Keep FFmpeg in the foreground so systemd can track its actual process.

You need an Ubuntu computer or server that stays powered on, a stable internet connection, FFmpeg, and a video or audio source you have the rights to stream. This guide uses a prerecorded video file with audio; if you have audio-only material, create or choose a compatible video container and visual rather than assuming YouTube will accept an audio-only input.

Prepare YouTube Live and your media

Enable live streaming and create the stream

  1. In YouTube Studio, enable live streaming for your channel and complete any requested verification. YouTube says a channel must be verified and have no live-streaming restrictions in the previous 90 days. First-time enablement can take up to 24 hours. See YouTube’s live-streaming setup guidance.
  2. Create or schedule a live stream in YouTube Studio using an encoder workflow. Copy the ingest URL and stream key privately; the key is a credential, not a public identifier. YouTube documents RTMP and RTMPS ingest in its encoder stream settings.
  3. Use the ingest URL and key format YouTube provides for your stream. Do not assume every account or stream uses the same URL or key.

Check rights and the input file

Use music, artwork, and any video for which you have the necessary rights to stream worldwide on YouTube. YouTube scans live streams for third-party material and may replace the picture, interrupt, or terminate a stream. Licensed material can still be interrupted unless the rights holder allowlists the channel. YouTube’s Livestream terms make the creator responsible for the necessary rights, including music licensing rights.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
KAMRUI Essenx E2 Mini PC, AMD Ryzen 5 3500U(4 Cores, 8 Threads, Up to 3.7GHz), 16GB DDR4(Expandable) 256GB M.2 SSD Micro PC, HDMI+DP Dual 4K@60Hz Display Home/Business/Office Mini Desktop Computers
  • 【Ryzen 5 3500U Processor】KAMRUI Essenx E2 Mini PC is equipped with AMD Ryzen 5 3500U (4-cores/8-threads, up to 3.7GHz) with integrated Radeon Vega 8 Graphics(1200MHz, 8 Core). The 3500U CPU operates at a base frequency of 2.1 GHz and a Boost frequency of 3.7 GHz. This DDR supports upgradable up to 32GB, SSD supports up to 2TB.(NOT INCLUED), KAMRUI E2 3500U Mini PC is ideal for light office work and home entertainment. KAMRUI E2 3500U is more than 35% more powerful and smoother in operation than the Intel N150, 33% faster than Intel N95, 28% performance boost over Intel i3-10110U, and 42% stronger processing power than AMD Ryzen 3 3200U.
  • 【16GB DDR4 & 256GB SSD】The KAMRUI E2 mini computers is equipped with 16GB DDR4(Expandable up to 32GB) for faster multitasking and smooth application switching. 256GB M.2 SSD ensures fast startup times,fast file transfers and plenty of storage space,eliminating slow loading times and ensuring fast responsiveness.Storage space can RAM supports up to 32 GB, SSD supports up to 2TB (Not included)make file storage easier.
  • 【4K Dual Display & USB 3.2 Type-A Port】KAMRUI E2 3500U mini desktop pc is equipped with an HDMI 2.0+DP 1.4 interfaces for faster transmission, Support Dual 4K@60Hz Display, E2 mini desktop computers is ideal for visual home entertainment, home office, conference rooms, etc. USB3.2 Gen1 Type-A Port×2 with a transfer speed of up to 5Gbps (10 times faster than USB 2.0) for efficient data transfer. The RJ45 1000M Gigabit Ethernet Port ensures a stable network connection.
  • 【WiFi+Bluetooth stable connection】The Kamrui E2 micro pc have reliable and stable wireless connection, open websites in seconds, watch movies without buffering and download files smoothly, connect your monitor from WiFi or Ethernet, use a wireless keyboard and mouse through bluetooth, which will be powerful workstation for you.
  • 【Versatile Ports】This KAMRUI E2 Small pc is equipped with HDMI 2.0×1(4K@60Hz)、DP1.4×1(4K@60Hz)、Gigabit Ethernet Port (RJ45, 10/100/1000Mbps) ×1、USB3.2 Gen1 Type-A Port×2(5Gbps)、USB2.0 Type-A Port×2、3.5mm Audio Jack ×1、DC In ×1、Power Button ×1

Before building the service, confirm that FFmpeg can read the chosen file and that its video and audio streams are suitable for the intended broadcast. The example below copies the input’s existing codecs without re-encoding; it is appropriate only when the file’s codecs and stream parameters are accepted by YouTube and the input can be played reliably. If not, choose compatible encoding options and test them before relying on an all-day service.

Install FFmpeg and create a service account

Install FFmpeg using the package source for your Ubuntu release. The exact package availability can vary by release and configured repositories; verify the installed binary with ffmpeg -version. Create a dedicated, unprivileged account and a directory for the media, for example:

sudo useradd --system --create-home --home-dir /srv/youtube-music --shell /usr/sbin/nologin stream
sudo install -d -o stream -g stream /srv/youtube-music

Put your test media at /srv/youtube-music/loop.mp4, owned by the service account or otherwise readable by it. The account should have no broader permissions than the job needs.

Rank #2
Sale
GMKtec M5 Ultra Gaming Mini PC Ryzen 7 7730U 16GB RAM 256GB SSD Computer
  • Office Gaming Mini PC - UPGRADED GMKtec Nucbox M5 Ultra Series is equipped with the powerful AMD Ryzen 7 7730U processor, 8 Cores/16 Threads, Base 2.00GHz (Power Saving Quiet Mode) with Turbo Boost up to 4.50GHz (Performance Mode) in BIOS settings, Based on the ZEN 3+ architecture, this small but powerful mini pc delivers satisfying results in productivity, office work, and gaming. 35% Performance increase over AMD Ryzen 5 7430U/ Ryzen 7 5700U, 5600U, 5560U, 5500U.
  • 16GB DDR4 RAM & 256GB PCIe SSD - Installed with DDR4 16GB RAM (1x16GB), the Nucbox M5 Ultra mini pc support expansion to 64GB RAM. Featured with 256GB M.2 2280 PCIe 3.0 SSD, support dual slot expansion to 4TB SSD. (Upgrades not included)
  • DUAL NIC LAN 2.5G RJ45 - Fast Network Speeds: Enjoy up to 2500Mbps data transmission speed without worrying about lagging. Ideal for working, gaming, and surfing the internet. Great for Untangle, Pfsense or as a server office PC.
  • Mini Desktop Computer with 4K Triple Screen Display - Nucbox M5 Ultra integrates AMD Radeon Graphics 8 Cores 2000 MHz GPU to deliver powerful graphics processing power to easily handle the demands of complex design software, 4K@60Hz UHD video editing, and playback. It can connect to 3 display screens simultaneously.
  • Fast Internet WiFi 6E + BT5.2 Connection - GMKtec Mini PC with WiFi-6E Wireless, have 2.5G/5G/6G triple band, more faster and lower latency. Bluetooth 5.2 allowing you more quickly to connect other wireless devices (headset, mouse, keyboard, etc.) Interface features 2*USB3.2 ports, 2*USB2.0 ports, 1*HDMI 2.0 port(4K@60Hz), 1*USB-C port(PD/DP/DATA), 1*DP Port, 1*Audio 3.5mm (HP&MIC), 1*DC Power Port.

Store the stream key safely

Use a protected environment file instead of putting the key in a shared script or publishing it in a unit file. Create /etc/youtube-music.env as root and set its contents to:

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

Then restrict access to the file:

sudo chown root:root /etc/youtube-music.env
sudo chmod 600 /etc/youtube-music.env

Do not paste a real key into a public log or support post. If it is exposed, reset it in YouTube Studio and update the local configuration.

Create the FFmpeg wrapper and systemd unit

Use a wrapper so the key reaches FFmpeg safely

Systemd does not run ExecStart= through a shell, so shell-style variable expansion in the command line is not a safe way to interpolate the key. Create an executable wrapper that reads the environment variable and replaces itself with FFmpeg:

Rank #3
BOSGAME E5 11 Pro Mini PC, AMD Ryzen 5300U 4C/ 8T, Business Home Office PC
  • 【AMD Ryzen 3 5300U CPU: Outperforms N150 & 3500U】 BOSGAME E5 mini PC is powered by the TSMC 7nm FinFET architecture AMD Ryzen 3 5300U processor (4 Cores, 8 Threads, up to 3.8GHz boost, 6MB total cache). Compared to low-end Intel N150 or 3500U chips which only have 4 single threads and throttle under load, the 5300U delivers over 30% faster multi-core speed. Run 30+ browser tabs, large Excel sheets, and Zoom meetings simultaneously without system lag.
  • 【8GB DDR4 RAM & 256GB NVMe SSD Storage】 Installed with high-speed 8GB DDR4 dual-channel memory and a fast 256GB M.2 2280 SSD, eliminating slow boot times and application loading delays. To accommodate growing data requirements, the upgradeable hardware design features dual SODIMM slots that allow you to expand memory up to 64GB RAM, ensuring smooth operation during heavy multitasking.
  • 【High-Capacity Dual M.2 SSD Storage Expansion】 Never worry about running out of space for your business files. In addition to the pre-installed 256GB system drive, the motherboard houses an extra empty internal M.2 2280 NVMe PCIe 3.0 slot. This allows you to easily add a second solid-state drive for up to an additional 2TB of storage capacity (upgrades not included) without needing to remove or reinstall the original operating system.
  • 【Radeon 6-Core Graphics & Triple 4K Displays】 Integrated with official AMD Radeon Graphics (6 Graphics Cores, 1500 MHz frequency) for casual gaming, photo editing, and crisp 4K media decoding. Featuring 1x HDMI 2.0 port, 1x DisplayPort, and 1x Full-Function Type-C port, the E5 outputs true 4K@60Hz resolution to three monitors at once. This multi-screen setup eliminates constant window-switching for traders, programmers, and office workers.
  • 【Dual 2.5GbE LAN Ports for Advanced Networking】 Experience fast wired network transmission speeds up to 2500Mbps without lagging or buffering. The integration of dual 2.5 Gigabit Ethernet ports (powered by Realtek RTL8125 controller) makes this compact computer an exceptional hardware choice for tech enthusiasts. Easily configure it into software routers, hardware firewalls (pfSense, OpnSense), home NAS servers, or local homelabs.
sudo tee /usr/local/bin/youtube-music-start >/dev/null <<'EOF'
#!/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}"
EOF
sudo chmod 755 /usr/local/bin/youtube-music-start

This example assumes the standard RTMP ingest base URL shown; prefer the exact ingest details supplied for the stream in YouTube Studio. The key is passed as part of FFmpeg’s destination argument, so limit access to the machine and avoid exposing process details to other users where practical. If your security requirements do not allow the key to appear in process arguments, use an ingest method and credential handling approach appropriate to your environment.

Define 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 retries after an abnormal exit, and RestartSec=15 waits before the next attempt. Restart attempts remain subject to systemd’s unit start-rate limiting; repeated rapid failures can leave the unit failed instead of retrying indefinitely. These are practical starting values, not a universal reliability guarantee. See the Ubuntu Noble systemd.service manual.

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.

Enable the service and verify the broadcast

  1. Reload systemd’s unit files and enable the service at boot while starting it now:
    sudo systemctl daemon-reload
    sudo systemctl enable --now youtube-music.service
  2. Check the service state:
    systemctl status youtube-music.service
  3. Follow its logs while it connects and begins playback:
    journalctl -u youtube-music.service -f
  4. In YouTube Studio’s Live Control Room, check the preview and stream health. Confirm that viewers can hear the audio from a separate device, and keep monitoring after the first successful connection.

A service marked active only tells you that its process is running; it does not prove that YouTube is receiving a healthy stream. YouTube recommends testing with representative audio and motion, monitoring health, and keeping about 20% upload-bandwidth headroom beyond the stream bitrate. Its encoder guidance lists RTMP/RTMPS; 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 promise that a given host can encode or upload reliably. See the YouTube encoder settings and stream health guidance.

Rank #4
Sale
GMKtec G3S Mini PC Intel N95 Processor (Up to 3.4GHz) 8GB RAM 256GB M.2 SSD
  • 12th Intel Alder Lake N95 Processor – The GMKtec G3 S Mini PC is powered by the 12th Gen Intel N95 processor with 4 cores, 4 threads, 6MB cache and a burst frequency up to 3.4GHz. Compared with N100/N5105/N5100/N5095, the N95 delivers up to 36% overall performance improvement. Perfect for routine tasks, office work, and home entertainment, this compact mini desktop is more convenient than traditional bulky PCs.
  • 8GB RAM & 256GB SSD Storage – Pre-installed with 8GB DDR4 memory and a fast 256GB M.2 2242 SSD, the G3 S mini desktop offers quicker startup, smoother multitasking, and faster file transfers. Enjoy seamless performance whether you’re working on multiple applications, browsing, or streaming content.
  • Rich Interfaces & Connectivity – The G3 S mini computer comes equipped with USB 3.2 (up to 10Gbps), dual HDMI 2.0 (4K@60Hz), and a 3.5mm audio jack. With support for WiFi 5, Bluetooth 5.0, and Gigabit Ethernet (RJ45 1000MbE), it connects easily with monitors, projectors, printers, office equipment, and other peripherals, making it versatile for both home and business use.
  • Dual 4K Display Support – Featuring upgraded Intel UHD Graphics (up to 1000MHz), the G3 S supports 4K video playback and AV1 decoding for a smooth viewing experience. With dual HDMI outputs, you can connect two 4K@60Hz displays simultaneously, enabling efficient multitasking for work and entertainment.
  • GMKtec WARRANTY - GMKtec offers a 1-year limited GMKtec's warranty for each mini PC, starting from the date of the purchase. All defects due to design and workmanship are covered. With a professional after sales team always ready to attend to your needs, you can simply relax and enjoy your mini PC.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What looping and automatic restart do—and do not do

FFmpeg’s -stream_loop -1 loops the input indefinitely. It does not make a failed process, disconnected network, invalid file, or rejected YouTube ingest healthy. If FFmpeg restarts, playback may begin at the start of the input rather than resuming from the point where it stopped. The FFmpeg documentation describes input looping options; systemd’s restart controls are documented in the Ubuntu Noble service manual.

Troubleshoot common failures

  • The unit fails immediately: Run systemctl status youtube-music.service and journalctl -u youtube-music.service -n 100 --no-pager. Check the wrapper path, file permissions, FFmpeg path, environment file syntax, and that the service account can read the media.
  • The log says the key is missing or authentication fails: Confirm the variable name is exactly YOUTUBE_STREAM_KEY, the environment file is readable by systemd, and the key belongs to the intended YouTube stream. If the key may have been exposed, reset it in Studio.
  • FFmpeg runs but YouTube shows no healthy input: Check the exact ingest URL and key, outgoing network access, and YouTube’s Live Control Room health panel. Verify the source codecs and output settings against YouTube’s encoder guidance.
  • Audio or video is missing, unsupported, or unstable: Test the file locally with FFmpeg, inspect its streams, and use compatible output encoding instead of blindly copying codecs. Re-test using representative media before enabling the unattended service.
  • The service keeps restarting or stops retrying: Inspect the journal for the original error rather than increasing restart frequency. Repeated failures can hit systemd start-rate limits; fix the underlying media, credential, or connectivity problem, then reset the failed unit with sudo systemctl reset-failed youtube-music.service before starting it again.
  • The stream drops despite an active unit: Check host connectivity, available upload capacity, and YouTube ingest health. A restart policy only reacts to the tracked process; it cannot repair a sustained outage or guarantee that YouTube remains connected.
  • YouTube interrupts or terminates the live stream: Review the rights for every audio and visual element. A process restart cannot resolve a copyright claim or replace the required permissions.

Or let it run in the cloud

If maintaining an Ubuntu host and FFmpeg service is not the part you want to manage, StreamNeo keeps an uploaded-video YouTube stream running from the cloud:

  1. Upload your recording or build a playlist.
  2. Add your YouTube stream key once.
  3. Go live; StreamNeo loops the uploaded material from the cloud.

Your computer and home connection do not have to stay on. Every slot supports the uploaded quality up to 4K 60fps at one flat price per slot, and StreamNeo automatically recovers if YouTube drops the stream. The first day is free with no card. The monthly option is $9.99 per month. StreamNeo streams to YouTube and plays uploaded videos; it does not broadcast a live camera feed. Start your free day with StreamNeo.

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

Cost and operational trade-offs

With the systemd approach, the recurring costs depend on the Ubuntu machine or server, electricity if it is on-site, and internet service. You remain responsible for operating system updates, storage, process monitoring, network reliability, and recovery from host failure. No universal hardware sizing or VPS price follows from the stream settings alone; verify that your chosen machine can sustain the selected media and upload rate.

A managed cloud workflow shifts responsibility for keeping the local computer and connection online, but it is a different operating model: you upload prerecorded videos and supply the YouTube key rather than maintaining your own FFmpeg service. Compare based on who maintains the host, how source media is stored, what happens after a failure, and whether the workflow fits your rights and broadcast needs.

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.