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 DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
DocumentaryTube
continuous streaming

How to Run a Continuous YouTube Stream with systemd on Ubuntu

Use FFmpeg as a foreground systemd service to stream prerecorded video to YouTube from Ubuntu, with practical checks for encoding, RTMPS, service recovery and YouTube’s archive lifecycle.

By DocumentaryTube Team 7 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To keep a prerecorded video streaming to YouTube from an Ubuntu host, run FFmpeg as the foreground process of a systemd service, configure the service to start at boot and restart after unexpected exits, and monitor both systemd and YouTube Live Control Room. This can recover from some local process failures; it cannot fix a bad stream key, missing media, an internet outage, or a YouTube broadcast that has ended. YouTube also says streams under 12 hours are automatically archived, so a genuinely continuous channel requires attention to YouTube’s broadcast lifecycle as well as the encoder.

What you need before setting up the service

  • An Ubuntu host that can remain powered on, with reliable outbound internet and enough upload capacity for the chosen stream quality.
  • FFmpeg installed from a trusted package source appropriate to your Ubuntu release. Confirm that your build can read the media and supports the required encoders and network protocol.
  • A prerecorded video file accessible to the account that will run the service. Test that FFmpeg can read it before configuring systemd.
  • A YouTube stream created or scheduled in YouTube Studio, with its server URL and stream key available from Live Control Room.

This setup is for prerecorded media sent to YouTube by FFmpeg. It is not a camera-ingest or live-production setup. The Ubuntu machine, its network connection, and the YouTube-side broadcast are separate parts of the chain; each needs its own checks.

Create the YouTube stream and protect its key

  1. In YouTube Studio, create or schedule a live stream and open Live Control Room.
  2. Copy the server URL and stream key shown for that stream into your encoder configuration. YouTube’s setup guidance says to enter both values into the encoder (Create a YouTube live stream with an encoder).
  3. Prefer the RTMPS server URL provided in Live Control Room. YouTube describes RTMPS as a secure extension of RTMP that carries the connection over TLS/SSL (Encrypt your stream using RTMPS). Do not assume that a URL displayed by default is RTMPS; verify the actual URL.
  4. Keep the stream key private: do not commit it to a public repository, include it in screenshots, or expose it through broadly readable logs. If it is compromised, reset it in Live Control Room and update the encoder configuration (YouTube encoder setup guidance).

For an SSL error or connection failure, first check that the URL and protocol match and that the FFmpeg build supports RTMPS. YouTube’s RTMPS guidance also discusses port 443; use it where the encoder URL or configuration allows. The exact URL shown in Live Control Room takes precedence over assumptions about a default endpoint.

Choose settings that fit the source and connection

Use the source’s actual resolution and frame rate where practical, and choose a bitrate your host can sustain consistently. YouTube’s current encoder guidance supports RTMP/RTMPS, H.264, H.265 (HEVC) or AV1 video, up to 60 fps, constant bitrate (CBR), and AAC or MP3 audio. It recommends a two-second keyframe interval and says not to exceed four seconds. Check YouTube’s current settings table for the exact codec, resolution and frame-rate combination you intend to use (YouTube live encoder settings).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.
Example output YouTube-recommended video bitrate
1080p at 30 fps, H.264 14 Mbps
1080p at 30 fps, AV1 or H.265 10 Mbps
720p at 30 fps, H.264 8 Mbps
720p at 30 fps, AV1 or H.265 6 Mbps

These are YouTube recommendations, not a promise that a particular machine or connection can maintain them. YouTube recommends testing upload capacity and selecting a quality that is reliable for the connection. For audio, YouTube recommends 44.1 kHz and 128 Kbps for stereo, and 48 kHz and 384 Kbps for 5.1 audio; 5.1 over RTMP/RTMPS is supported only with AAC, according to its encoder guidance.

Test FFmpeg interactively before making it a service

First run a test using the intended file, output settings, server URL and stream key. Confirm the installed FFmpeg version can read the file and that the resulting audio and video are suitable. YouTube recommends testing with audio and movement representative of the planned broadcast, then monitoring stream health in Live Control Room.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

For a local file that should repeat, FFmpeg options such as -stream_loop -1 can be used to loop the input, and -re can pace file input in real time. These are FFmpeg command choices, not YouTube requirements. Validate the options against the FFmpeg version installed on your Ubuntu host and the specific media. A looping input does not by itself manage YouTube’s broadcast lifecycle.

Do not put a real stream key in a public command example or a shell history you share. Keep the final configuration accessible only to the service account and administrators who need it; choose a storage method and file permissions appropriate to the Ubuntu and systemd versions on the host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Run FFmpeg under systemd and start it at boot

Create a system-level service unit that runs FFmpeg as its main foreground process. Configure it to start on boot, send output to the journal, and use a restart policy and delay suited to the workload. Keeping FFmpeg in the foreground lets systemd track the encoder process rather than a wrapper that backgrounds it. Exact unit directives and their semantics can vary with the systemd version shipped by an Ubuntu release, so check that version’s documentation before applying a unit file.

After saving the unit, reload systemd’s unit definitions, enable the service for boot, and start it. Then inspect the service state and journal using systemctl status and journalctl for the unit. Use the actual unit name in those commands. The journal can show why FFmpeg exited or failed to start; it cannot show by itself whether YouTube is receiving a healthy broadcast.

Rank #4
Sale
UGREEN 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

Choose restart behavior deliberately. A process restart may help after an unexpected local exit, but repeated restarts can create a failure loop if the input path is wrong, the key is invalid, or the network is unavailable. A restart policy does not repair those underlying problems, and a clean exit, an administrator stop, or YouTube ending the broadcast must be handled according to the service configuration and platform workflow.

Verify the stream at both ends

  1. Check systemd: confirm the unit is loaded and active with systemctl status. If it is inactive or repeatedly restarting, read the corresponding journal entries.
  2. Check FFmpeg and the source: look for input-read errors, unsupported formats or encoders, and output failures. Confirm the media contains the intended audio and video and that output settings match YouTube guidance.
  3. Check transport: verify the exact RTMPS server URL, key, protocol support, and network access. For SSL or timeout issues, revisit the URL/protocol and port 443 guidance.
  4. Check YouTube: open Live Control Room and confirm the incoming preview and stream health. An active local service does not prove that YouTube has a usable broadcast.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Plan for YouTube’s 12-hour archive behavior

YouTube says streams under 12 hours are automatically archived (YouTube encoder stream guidance). Do not assume that keeping FFmpeg alive, or restarting it, creates an indefinitely open YouTube event. Plan how the YouTube-side stream will be created, monitored and continued around that lifecycle. The cited guidance establishes the archive behavior; it does not establish that restarting the encoder alone is a solution for continuous platform-side broadcasting.

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.

Troubleshoot by failure layer

Symptom Likely area What to check or do
Unit fails immediately or keeps restarting Service or process Read the unit’s journal output; confirm the executable, configuration access and media path. Correct the underlying failure before relying on another restart.
FFmpeg cannot open or decode the file Input or build Check file permissions and path, and confirm the installed FFmpeg build supports the media’s demuxer and codecs.
YouTube does not receive the stream Credentials or transport Verify the stream key and the exact server URL from Live Control Room. Prefer its RTMPS URL and confirm RTMPS support and network access.
SSL error or connection timeout Transport Check protocol and server URL together; consult YouTube’s RTMPS guidance about port 443 where the encoder configuration permits it.
Video or audio is unstable or unhealthy Encoding or upload Compare codec, frame rate, bitrate, keyframe interval and audio format with YouTube’s current settings. Test upload capacity and reduce output quality if the connection cannot sustain the chosen rate.
systemd says active but no healthy preview appears YouTube broadcast Check Live Control Room separately. Local process state alone does not confirm YouTube ingest or broadcast health.
Key may have been exposed Credential security Reset the stream key in Live Control Room and replace it in the protected service configuration.
Stream stops around an archive or event end YouTube lifecycle Check the YouTube-side stream state and plan the next event or continuation. A local FFmpeg restart does not itself reopen an ended broadcast.

Or let it run in the cloud

If the goal is a prerecorded YouTube channel that stays live without an Ubuntu host to maintain, StreamNeo is the first alternative to consider: it loops uploaded video in the cloud, with any uploaded quality up to 4K 60fps at one flat price per slot, and the first day is free. The setup is three steps:

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

Nothing has to stay on at home. StreamNeo streams the uploaded video as supplied, without re-encoding or quality tiers; it can automatically recover if YouTube drops the stream. The first day is free with no card, one free day per account. Monthly billing is $9.99 per month. UPI and cards are available in India, and card checkout is available worldwide. StreamNeo is for uploaded video streaming to YouTube, not going live from a camera. See StreamNeo plans, or start the free 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 Screening Room

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
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.