DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
FFmpeg

How to Keep a 24/7 Cartoon Stream Running on Ubuntu with systemd and FFmpeg

Loop a single authorized video to a live destination with FFmpeg, run it under systemd, and understand what local retries can—and cannot—recover.

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

You can keep one authorized cartoon video looping to a live destination from Ubuntu by having FFmpeg read the file in real time and publish it, then using systemd to restart FFmpeg if the process fails. These are separate jobs: looping does not publish, and systemd cannot guarantee an uninterrupted stream. The examples below are patterns, not a tested or destination-specific setup; confirm your installed FFmpeg options and the platform’s current ingest requirements before going live.

Before you start

This guide covers a single local video file streamed continuously from an Ubuntu machine. The output examples use RTMP as a pattern; your destination may require a different endpoint, codecs, resolution, frame rate, or bitrate. No particular settings are guaranteed to work with every platform.

  • Use media you are authorized to rebroadcast. Owning a file or being able to stream it does not establish permission for continuous public rebroadcast. Check the rights for the specific cartoon, use, and territory.
  • Keep the source available. Put the video somewhere stable, such as /srv/cartoon.mp4, and ensure the account that runs FFmpeg can read it.
  • Check your installed build and media. Ubuntu release and FFmpeg build vary. Use ffmpeg -version to identify the build and ffprobe /srv/cartoon.mp4 to inspect available streams and formats before choosing maps or encoding options.
  • Get the destination’s current ingest details. Obtain its exact RTMP endpoint and stream key, and check the official requirements for its accepted container, video and audio codecs, bitrate, dimensions, frame rate, and keyframe interval.

FFmpeg’s protocol documentation includes a file-to-RTMP example using real-time input pacing. Its complete documentation describes additional muxing and recovery options. These references explain FFmpeg behavior; they do not establish what a particular destination accepts.

Loop and publish a single video

For a single file, -stream_loop -1 requests indefinite looping. -re paces file input in real time rather than letting FFmpeg process it as fast as possible. Input options belong before the associated -i. A schematic command is:

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.
ffmpeg -re -stream_loop -1 -i /srv/cartoon.mp4 
  -map 0:v:0 -map 0:a? 
  -c:v libx264 -c:a aac 
  -f flv "$RTMP_URL/$STREAM_KEY"

Set RTMP_URL and STREAM_KEY to the exact values supplied by the destination. The optional audio map, H.264 and AAC encoders, and FLV output are examples, not universal ingest settings; a source without audio, an unavailable encoder, or a destination with different requirements may need different choices. This example specifies no bitrate, resolution, frame rate, or keyframe interval. Do not guess those values: use the destination’s current instructions and the source’s properties.

FFmpeg documents the loop and pacing approach and an RTMP example in its protocol documentation; the complete documentation covers the wider option set. A September 20, 2022 FFmpeg-user post records one user’s attempt with Ubuntu 22 and FFmpeg 4.4; it is an example of a question, not a validated recipe.

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.

Protect the stream key

A stream key is a credential. Do not put a real key in a world-readable service file, a command that will remain in shell history, or logs. Use a root-readable secrets file or another suitable secret-handling method, restrict its permissions, and ensure the service account can access only what it needs. The example above shows variable names, not a safe way to store or expose actual credentials.

Run FFmpeg under systemd

Use a service to supervise the FFmpeg process instead of relying on an interactive terminal session. A typical service uses Restart=on-failure and a nonzero RestartSec= delay. Ubuntu’s Noble systemd.service manual recommends Restart=on-failure for long-running services; restart attempts are still subject to systemd start-rate limiting.

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.

There is no safe universal unit file for every installation: the service account, secret file, media path, command wrapper, dependencies, and delay depend on your machine and setup. In particular, systemd does not run ExecStart through a shell by default, so shell variable expansion and quoting from the interactive example cannot simply be copied into it. If you use a wrapper to construct the FFmpeg command, keep it readable only by the appropriate account, avoid printing credentials, and test the exact command as the service user.

  1. Create a dedicated service account or choose an existing restricted account. Grant it read access to the media and necessary secrets, plus only the permissions required to run FFmpeg.
  2. Create the command or wrapper with the exact endpoint settings and protected credential handling for your system. Confirm it works as the service account before making it a boot-time service.
  3. Create a systemd unit whose ExecStart directly starts FFmpeg or that wrapper, and set the intended service user, working directory, restart policy, and restart delay. Add dependencies appropriate to your filesystem and network; their correct values depend on how the machine is configured.
  4. Use the verification tools available in your installed systemd version to validate the unit, then reload systemd and start the service. Check the result with systemctl status and inspect its logs with journalctl -u your-service-name.
  5. Verify the live output at the destination itself. An active systemd unit or running FFmpeg process does not prove viewers are receiving valid audio and video.

What can recover, and what cannot

FFmpeg and systemd address different failure points. FFmpeg’s protocol reconnect options apply to supported input protocols and conditions; do not assume they repair a broken RTMP output connection. FFmpeg’s complete documentation shows a separate FIFO muxer recovery pattern, including -attempt_recovery 1 -recovery_wait_time 1. These options may help with temporary output failures while FFmpeg continues processing, but they do not guarantee that a destination accepts a resumed session.

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
Failure or mechanism What it may address Limit to plan for
Input or media read problem Input-protocol reconnect options may apply where the input protocol and failure are supported. They are not a general fix for output disconnects, missing files, or every source failure.
Temporary output failure FFmpeg’s FIFO muxer has a documented output-recovery pattern. Recovery depends on the failure and destination; it does not promise a seamless or accepted publishing session.
FFmpeg exits systemd can start the process again under a failure restart policy. A new FFmpeg process typically means a new publishing session and a possible viewer-visible gap. Start-rate limits can stop repeated attempts.
Host, power, or destination outage Neither a process-level retry nor systemd supervision alone makes a dead host run or restores a destination that is unavailable. Plan for gaps, inspect the cause, and confirm output health after recovery.

Use the FFmpeg complete documentation for the FIFO muxer’s options and the Ubuntu Noble systemd manual for service restart behavior. A stop requested through systemd does not trigger automatic restart.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Monitor the stream and troubleshoot failures

Check the service logs, FFmpeg’s error output, destination-side stream health, and the machine’s disk, network, and CPU use. These checks help distinguish a process that is alive from a stream that is actually playable.

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.
Symptom Likely area to check Next step
Unit fails immediately Unit syntax, executable path, permissions, working directory, or FFmpeg arguments. Inspect systemctl status and journalctl -u your-service-name; validate the unit and run the command as its configured user.
FFmpeg cannot open the file Incorrect path, permissions, or an unavailable mount. Check that the configured service account can read the file and that the storage is mounted before the service starts.
Destination rejects the stream Wrong endpoint or key, or a mismatch in muxer, codecs, or other ingest requirements. Recheck the destination’s current ingest details and use the exact endpoint and key; consult FFmpeg’s error output.
Process is active but the destination shows no valid stream Output connection, destination-side ingest, or invalid audio/video mapping or encoding. Check the platform’s stream status and playback, then inspect FFmpeg logs and the media streams with ffprobe.
Repeated restarts stop systemd start-rate limiting or a persistent underlying error. Read the unit logs and correct the recurring failure before resetting or changing restart behavior.
Stream drops when the computer or network goes down The local host or connection is unavailable. systemd cannot supervise a powered-off machine or restore a failed home connection; use a host and network appropriate to the required availability.

One file is not a schedule

-stream_loop -1 is for repeatedly reading one input file. A playlist, updated schedule, or seamless transition between files requires a different setup; the documentation cited here does not establish an authoritative current playlist recipe or guarantee seamless transitions. Validate any multi-file workflow against your installed FFmpeg version and actual media before relying on it continuously.

Or let it run in the cloud

If you want to avoid keeping an Ubuntu computer and home connection running, StreamNeo keeps 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 uploaded content from the cloud; it does not go live from a camera.

  • Nothing has to stay powered on at home; StreamNeo runs in the cloud and can automatically recover if YouTube drops the stream.
  • Each slot streams the uploaded file as made, up to 4K 60fps, at one flat price per slot with no re-encode or quality tiers.
  • The first day is free, with no card required. The monthly option is $9.99 per month.

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 Patch Notes

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.