October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober 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 Set Up a YouTube 24/7 Stream with FFmpeg on Ubuntu

A practical Ubuntu guide to looping video into YouTube Live with FFmpeg, choosing safe encoder settings, checking stream health, and planning recovery.

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

You can loop a video file into YouTube Live from Ubuntu with FFmpeg by enabling live streaming for your channel, getting the ingest URL and stream key from YouTube Studio, then running FFmpeg with real-time input pacing and a loop. That sends the file repeatedly; it does not guarantee uninterrupted broadcasting. You still need enough sustained upload bandwidth, a healthy source file, monitoring, and a plan for encoder or network failures.

Before you start: enable YouTube Live and get your stream details

  1. In YouTube Studio, open the Live Control Room and create or select a stream. YouTube provides the ingest URL and matching stream key there. Follow the current setup flow and confirm the exact RTMPS URL format shown for that stream.
  2. If this is the first time the channel is enabled for live streaming, allow up to 24 hours for activation. The channel must be verified and must not have had a live-stream restriction in the previous 90 days, according to YouTube Help: YouTube live-streaming requirements.
  3. Treat the stream key like a password. Do not publish it in a script repository, screenshot, article, or public log. If it is exposed, reset it in YouTube Studio and update the encoder.

YouTube recommends RTMPS, which encrypts data in transit to Google’s servers. Use the URL supplied in the current Live Control Room rather than assuming a URL format: YouTube encoder settings.

Choose resolution, frame rate, and bitrate

Choose settings that suit both the video and your measured, sustained upload capacity. YouTube’s published H.264 recommendations include the following examples; they are recommendations, not a guarantee of quality for a particular file or connection.

Output format YouTube H.264 bitrate recommendation
480p at 30 fps 5 Mbps
1080p at 30 fps 10 Mbps
1080p at 60 fps 17 Mbps

YouTube also lists AV1/H.265 recommendations of 3 Mbps for 480p30, 10 Mbps for 1080p30, and 12 Mbps for 1080p60. These values apply to the listed formats and codecs; consult the current YouTube encoder settings when choosing a different format.

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.
  • For the documented RTMP/RTMPS settings, YouTube lists H.264 video and AAC or MP3 audio, with constant bitrate (CBR).
  • YouTube recommends a keyframe interval of 2 seconds and says not to exceed 4 seconds. For a 30 fps output, a 2-second GOP is 60 frames; at 60 fps it is 120 frames.
  • YouTube recommends 20% upload headroom. Its guidance says the total stream bitrate cannot exceed the available upload bandwidth, and shared network traffic can reduce what your stream gets. See encoder settings and streaming tips.

Test upload performance under the conditions you expect to stream in, including other household or office traffic. If capacity varies, reduce the bitrate or resolution rather than planning around a brief speed-test peak. Include audio bitrate when accounting for total stream bitrate.

Prepare the video and install or verify FFmpeg

Use a media file with usable video and audio streams, and check that it plays correctly before setting up a long broadcast. The example below assumes a file named video.mp4. The exact Ubuntu release and installed FFmpeg package version are not specified here, so verify FFmpeg availability and option support for your system before relying on a version-specific installation command. The official FFmpeg manual documents the options used below.

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.

Run FFmpeg and loop the file

FFmpeg’s protocol documentation shows real-time input pacing with -re and RTMP output; its main manual documents input looping. This illustrative command combines those mechanisms. It has not been executed or tested, so check input compatibility and RTMPS handling with your FFmpeg build before using it for a continuous broadcast.

ffmpeg -re -stream_loop -1 -i video.mp4 
  -c:v libx264 -preset veryfast 
  -b:v 4500k -maxrate 4500k -bufsize 9000k -g 60 
  -c:a aac -b:a 128k 
  -f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"

Set YOUTUBE_RTMPS_URL to the ingest URL supplied by YouTube and YOUTUBE_STREAM_KEY to its matching key. The illustrative 4,500 kbps video bitrate is not a universal YouTube recommendation: replace it with an appropriate value for your chosen resolution and frame rate, and confirm that video plus audio fits your upload capacity with headroom.

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.

The example’s -g 60 corresponds to a 2-second GOP only when the output is 30 fps. If you choose another frame rate, adjust the GOP so the keyframe interval remains 2 seconds, without exceeding YouTube’s 4-second maximum. The example does not force a specific output resolution or frame rate; its actual output depends on the input and encoder behavior. Choose and verify the output format deliberately if the source does not already match your target.

In this command, -re paces reading in real time, -stream_loop -1 repeats the input indefinitely, and -f flv selects the container used for this RTMP-style output. FFmpeg’s official references are the protocol documentation and main manual. A loop repeats the same file; it does not create a playlist, add a backup source, or repair a broken input.

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

Verify the broadcast in YouTube Studio

  1. Start the FFmpeg command and open the stream’s Live Control Room.
  2. Wait for the preview and check that both picture and audio are present and that YouTube reports healthy stream status.
  3. Test the complete path before relying on it for a scheduled or long-running broadcast. YouTube recommends testing and monitoring stream health: YouTube streaming tips.

Keep the stream key private throughout setup and operation. YouTube explains how to manage or reset it in its stream-key guidance.

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

Keep a long-running stream observable

An indefinitely looping input is not an end-to-end uptime guarantee. The FFmpeg process, Ubuntu machine, network, ingest connection, and YouTube broadcast can each fail. A process supervisor can restart FFmpeg if it exits, but a restart alone will not fix a wrong key, unsupported media, a YouTube restriction, insufficient upload bandwidth, or a continuing network outage.

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.
  • Monitor the process and YouTube’s Live Control Room rather than assuming the loop is still reaching viewers.
  • Arrange a way to detect a stopped encoder or unhealthy stream and investigate the cause before restarting repeatedly.
  • Keep a recovery path for network or source-file problems; restarting cannot correct either underlying issue.
  • Plan stream sessions with YouTube’s archive behavior in mind. YouTube says streams under 12 hours are automatically archived; do not assume one unbroken stream longer than 12 hours will be archived as a single complete video. Check current platform behavior and plan session management accordingly: YouTube live-stream guidance.

The total bitrate you’re streaming cannot exceed the amount of upload bandwidth available. — YouTube Help, Streaming tips.

Common problems and what to check

Symptom Likely cause What to check
No preview or stream does not start Live streaming is not enabled yet, or the ingest URL and key do not match. Check channel eligibility and activation status in YouTube Studio; confirm the current URL/key pair and reset the key if it may have been exposed.
FFmpeg exits or reports an input error The file path is wrong, the file is unsupported, or the media lacks a usable stream. Confirm the file exists and plays; inspect its video and audio streams, and verify the options against your installed FFmpeg build.
Stream health is poor or playback stutters Upload capacity is inadequate or varies under shared network load. Measure sustained upload in representative conditions, allow YouTube’s recommended 20% headroom, and lower bitrate or resolution if needed.
Video arrives but audio is missing The source audio may be absent or incompatible with the chosen encoding path. Check that the input contains usable audio and that AAC or MP3 settings match YouTube’s documented encoder guidance.
Stream stops after a process or connection failure The input loop does not restart an exited encoder or restore a failed network path. Use monitoring and a supervisor for process exits, then diagnose the key, input, network, or YouTube status before attempting recovery.

Or let it run in the cloud

If you do not want an Ubuntu computer and home connection to stay on, StreamNeo is a cloud service for keeping a YouTube channel live from uploaded videos. Upload a recording or build a playlist, add your YouTube stream key once, and go live; StreamNeo loops the video from the cloud. It does not stream from a camera or to platforms other than YouTube.

  • Nothing has to stay on at home.
  • Uploaded video streams as made, up to 4K 60 fps, at one flat price per slot; there are no quality tiers or re-encoding.
  • Automatic recovery if YouTube drops the stream.
  • The first day is free with no card, one free day per account.

Monthly pricing: $9.99 per month. See StreamNeo for service details, then start your 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.

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.

More from the Screening Room

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
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.