October 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 PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DocumentaryTube
24/7 streaming

How to Run a 24/7 YouTube Stream on Linux with FFmpeg

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

You can loop a prerecorded video to YouTube Live with FFmpeg, but uninterrupted streaming depends on more than the command: the Linux host, network, source file, stream key, and YouTube event must all remain healthy. Use an always-on machine, configure YouTube’s current ingest settings, supervise FFmpeg with your system’s service manager, and test recovery before relying on the stream.

What you need before streaming

  • A Linux machine that can stay powered, connected, and able to read the video file. A laptop that sleeps or an FFmpeg process attached only to an interactive terminal is not a dependable unattended host.
  • A YouTube live stream created or scheduled in YouTube Live Control Room, with its stream URL and stream key.
  • FFmpeg built with the input, codecs, and muxers your workflow requires. Check the installed build and test the command on that machine; options and available features vary by build.
  • Enough sustained upload capacity for the configured bitrate, with room for network variation and other traffic.

This guide covers streaming a prerecorded file. A live camera or generated feed has different input requirements.

Create the YouTube stream and protect its key

  1. In YouTube Live Control Room, create or schedule the broadcast and open its encoder or stream settings.
  2. Copy the stream URL and stream key into your FFmpeg configuration. The key authorizes an encoder to send the feed, so treat it like a password: do not publish it, commit it to a repository, or expose it in shell history or logs.
  3. If the key is exposed, reset it in Live Control Room and update the encoder configuration. See YouTube’s stream settings guidance and encoder setup instructions.
  4. Keep the Live Control Room preview open during setup so you can verify the incoming picture and sound before making the broadcast public.

Choose a YouTube-compatible output

YouTube recommends RTMPS, the encrypted form of RTMP. Its encoder guidance lists H.264, H.265/HEVC, and AV1 video for RTMP/RTMPS, frame rates up to 60 fps, AAC or MP3 audio, constant bitrate (CBR), and a two-second keyframe interval; the keyframe interval must not exceed four seconds. Use the current YouTube encoder settings and bitrate tables to choose a bitrate that matches your codec, resolution, and frame rate.

H.264 profile in YouTube’s table Minimum bitrate Recommended bitrate
720p at 30 fps 3 Mbps 8 Mbps
1080p at 30 fps 5 Mbps 14 Mbps

These are YouTube’s encoder recommendations, not a promise that a particular Linux host or internet connection can sustain them. Start with a profile your upload connection can reliably support. If transcoding, align the output codec, bitrate, keyframe interval, pixel format, and audio settings with YouTube’s current guidance. Do not assume that stream-copying a file is compatible: its codecs, keyframe cadence, audio format, and container behavior must suit the ingest profile.

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.
#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.

Build and test the FFmpeg loop

The general approach is to read the input at real-time speed, repeat it, and send an FLV-muxed stream to YouTube’s RTMP(S) endpoint. One possible command shape is:

ffmpeg -re -stream_loop -1 -i /path/to/video.mp4 
  -c:v libx264 -b:v 8M -maxrate 8M -bufsize 16M 
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 
  -pix_fmt yuv420p -c:a aac -b:a 128k -ar 44100 
  -f flv "rtmps://YOUR-INGEST-URL/YOUR-STREAM-KEY"

This is an illustrative H.264, 720p30-oriented starting shape, not a tested universal command or a substitute for checking your source and FFmpeg build. The 8 Mbps video bitrate corresponds to YouTube’s listed recommended H.264 bitrate for 720p30; choose the correct profile and bitrate for your actual output. The example’s 60-frame GOP at 30 fps targets a two-second keyframe interval. Replace the endpoint and key with the values from Live Control Room, and do not share a command containing a real key.

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.

If your input is not 720p30, or you choose another codec, adjust frame rate, GOP, bitrate, and encoding settings accordingly. If you want to preserve the file’s existing streams, investigate stream-copy compatibility rather than blindly substituting copy options; an incompatible stream may be rejected or behave poorly at ingest. Consult the FFmpeg documentation for the installed version’s input looping and output options.

Verify the feed before leaving it unattended

  1. Start the command while watching FFmpeg output and YouTube’s Live Control Room preview.
  2. Check picture, motion, and audio; make sure the stream-health indicators do not show a problem.
  3. Test with content that has audio and motion similar to the intended broadcast, as YouTube recommends in its streaming tips.
  4. Only rely on the setup after confirming the broadcast arrives as expected and that you know how to stop the process and update its configuration safely.

Keep FFmpeg running after logout and reboot

A service manager is more suitable than leaving a command in a terminal. On systems that use systemd, configure a service for the target machine, set it to start at boot, and choose a restart policy appropriate to the failure modes you need to recover from. Service-unit details differ by distribution and local setup; validate the unit on your Linux host and test it after a reboot. The StreamNeo systemd guide discusses this approach, but adapt and verify any example against your machine.

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.

Keep credentials out of broadly readable unit files and logs where possible. Restrict access to the service configuration, and check what your process manager records when the command fails. After enabling the service, confirm its status and inspect its logs using the tools appropriate to your distribution.

Recover from a dropped RTMP connection

FFmpeg’s FIFO muxer can attempt recovery from temporary output failures. The FFmpeg documentation gives this pattern, with recovery attempts one second apart:

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
ffmpeg -re -stream_loop -1 -i /path/to/video.mp4 
  -map 0:v? -map 0:a? 
  -c:v libx264 -c:a aac 
  -f fifo -fifo_format flv 
  -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 
  "rtmp://YOUR-INGEST-URL/YOUR-STREAM-KEY"

This shows the documented FIFO output pattern, not a complete production command: set encoding options and the endpoint for your actual stream, test against the installed FFmpeg version, and check whether recovery succeeds. See the FFmpeg FIFO muxer documentation. A service manager can separately restart a process that exits, but neither mechanism guarantees that streaming stays healthy indefinitely.

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

Plan upload capacity and YouTube archives

Measure sustained upload speed rather than inferring it from download speed. YouTube recommends 20% bandwidth headroom and says to account for both primary and backup stream bitrate in its network streaming guidance. Keep the configured stream within capacity that remains available during normal sharing and congestion.

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.
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.

YouTube’s encoder setup page says streams under 12 hours are automatically archived. It does not establish that an uninterrupted stream at or beyond 12 hours will receive a complete archive. If a replay matters, plan a separate recording or segment the broadcast, then verify the current platform behavior rather than assuming a multi-day stream produces one complete replay.

Troubleshoot common failures

Symptom Likely layer What to check
YouTube shows no incoming video Endpoint, key, network, or FFmpeg output Confirm the stream URL and key match the current Live Control Room event, check FFmpeg’s error output, and verify the host can reach the ingest endpoint.
FFmpeg exits and does not return Process supervision Inspect service logs and exit status. Check the input path, permissions, available disk, command options, and service restart policy.
The output drops during a temporary connection failure Network output Review FFmpeg logs and test the FIFO recovery pattern. If the process exits, use process supervision as a separate recovery layer.
Connection does not recover Host, network, credentials, or YouTube event Check for sustained network loss, a stopped host, revoked or reset key, source-file failure, or an ended/interrupted YouTube event; FIFO cannot repair these conditions by itself.
Picture or audio is rejected or poor Encoding or source compatibility Match codec, bitrate, frame rate, keyframe interval, pixel format, and audio settings to YouTube’s current encoder guidance; confirm the source itself plays correctly.
Stream is unstable despite a valid command Upload capacity Measure sustained upload, reduce the target bitrate or resolution if necessary, and preserve YouTube’s recommended headroom.

Use both FFmpeg or service logs and YouTube stream-health messages to isolate the layer that failed. Process supervision cannot revive a dead host, repair a failed source or exhausted disk, restore a sustained network outage, or resolve a platform-side interruption.

Or let it run in the cloud

If you do not want to maintain an always-on Linux host and its recovery setup, StreamNeo keeps an uploaded video or playlist looping to YouTube from the cloud. Upload your recording, add your YouTube stream key once, and go live. Your computer and home connection do not have to stay on; StreamNeo automatically recovers if YouTube drops the stream. Each slot streams the uploaded quality 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. Monthly is $9.99 per month.

Start your free first day with StreamNeo.

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.

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

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.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.