Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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
DocumentaryTube
FFmpeg

How to Loop MP4 Videos to YouTube Live from an Ubuntu Server

Use FFmpeg’s infinite input loop on Ubuntu to send an MP4 to YouTube Live, with practical encoding, reliability, and troubleshooting guidance.

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

To loop an MP4 on YouTube Live from Ubuntu, run FFmpeg with -re and -stream_loop -1, then publish to the RTMPS server URL and stream key shown in YouTube Studio. The server must stay online and sustain the selected upload bitrate for as long as the stream runs.

Before you start

  • An Ubuntu server that can remain online, with enough sustained upload capacity for the stream.
  • An MP4 file you have the rights to rebroadcast, including its audio.
  • FFmpeg installed, and an encoder such as libx264 available if you need to transcode.
  • A YouTube channel with live streaming enabled. YouTube says first-time enablement may take up to 24 hours. YouTube Help: Get started with live streaming

Enable YouTube Live and get the ingest details

  1. Open YouTube Studio and go to the Live Control Room.
  2. Create or select a stream, then open its stream settings.
  3. Copy the server URL and stream key shown there. Use that exact URL; do not assume a permanent endpoint.
  4. Keep the key private. Do not put it in a public script, screenshot, or log. Anyone with the key may be able to broadcast to your stream.

YouTube recommends testing the setup before going live and checking stream health in Live Control Room. Its current encoder guidance also recommends a speed test and a bitrate your connection can sustain. YouTube Help: Choose live encoder settings, bitrates, and resolutions

Inspect the MP4 and choose copy or re-encoding

Do not assume every MP4 has the same codecs or includes audio. Inspect the file before selecting output options:

ffprobe -hide_banner -i /path/to/video.mp4

Stream copy sends the existing encoded packets without decoding and encoding them. It avoids another generation of encoding loss and reduces CPU use, but can fail if the codecs or container details are incompatible with the output. FFmpeg documents stream copy and its limitations in its documentation.

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.
  • Use copy only when the input streams and output muxing work together and YouTube accepts the resulting codecs.
  • Transcode if the input codec is unsupported, the audio is absent or incompatible, or the copy attempt produces errors.
  • If there is no audio stream, remove audio output options from a copy command; if transcoding, do not map an audio stream that does not exist.

Set the loop and YouTube output

FFmpeg’s -stream_loop is an input option: place it before -i. A value of -1 requests infinite looping; -re makes FFmpeg read the file at its native frame rate instead of sending it as fast as possible. FFmpeg documentation

This example transcodes video to H.264 and audio to AAC. Replace the file path and ingest URL/key locally. It is an adaptable command shape, not a universal recipe:

ffmpeg -re -stream_loop -1 -i /path/to/video.mp4 
  -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k 
  -g 60 -keyint_min 60 -sc_threshold 0 
  -c:a aac -b:a 128k -ar 44100 
  -f flv 'rtmps://YOUR_YOUTUBE_INGEST_URL/YOUR_STREAM_KEY'

Use the exact RTMPS server URL displayed in Studio and replace the placeholder with your stream key. Avoid saving a real key in a world-readable script. The example’s 60-frame GOP is two seconds only at 30 fps; adjust it to the video’s frame rate. The bitrate must suit the resolution, frame rate, and available upload. Re-encoding also requires an FFmpeg build with the selected encoder.

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.

Match the current YouTube encoder guidance

YouTube’s current RTMP/RTMPS guidance lists H.264, H.265/HEVC, and AV1 video; AAC or MP3 audio; CBR video bitrate; frame rates up to 60 fps; and a recommended two-second keyframe interval, not exceeding four seconds. It recommends stereo audio at 44.1 kHz and 128 Kbps. These are YouTube ingestion recommendations, not a guarantee of the quality viewers will see. YouTube encoder settings

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
H.264 example Minimum video bitrate Recommended video bitrate
1080p at 30 fps 5 Mbps 14 Mbps
720p at 30 fps 3 Mbps 8 Mbps

These figures are YouTube Help’s published recommendations; the page does not state a publication year and was accessed in 2026. Choose a bitrate the server can sustain consistently, and test it rather than treating the recommended rate as a connection guarantee.

For RTMP/RTMPS, YouTube recommends RTMPS because it encrypts the connection to its servers. HLS is not a drop-in URL replacement for this FFmpeg command: it uses a different HTTPS-based workflow, segmented delivery requirements, and higher latency. YouTube describes HLS for HDR or codecs not supported by RTMP. RTMP/RTMPS guidance · YouTube HLS guidance

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.

Start the stream and verify it

  1. Run the command in a terminal on the Ubuntu server.
  2. Wait for the incoming preview in YouTube Studio’s Live Control Room.
  3. Check that the video moves and that audio is present and intelligible, if expected.
  4. Review Studio’s stream-health messages while the stream runs. Stop and correct any encoder or connection problem before relying on a long broadcast.

Keep the Ubuntu process running

The command runs only while its process and host remain available. For a continuous channel, keep the server powered and connected, use a process manager such as systemd to start the job after reboot and restart it after an exit, and restrict access to any configuration containing the key. A process manager can recover from process exits; it cannot fix a failed network connection, invalid key, or unsupported media. Monitor FFmpeg logs, CPU usage during transcoding, network interruptions, and YouTube stream health.

A rented Ubuntu VPS is one way to host the process if you do not maintain a physical server. The suitable provider, region, plan, and price depend on your workload and were not established here; compare sustained bandwidth, transfer limits, and service terms before choosing one.

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

Common problems and fixes

  • No preview appears: Check that the stream is enabled, the server URL and key were copied correctly, and FFmpeg is still running. Re-copy the current values from Studio if needed; keep the replacement key private.
  • FFmpeg exits or reports muxing/codec errors: Inspect the input with ffprobe. Try stream copy only if the input streams are compatible; otherwise transcode to a YouTube-supported format.
  • Video reaches YouTube but audio is missing: Confirm that the MP4 has an audio stream. Remove audio mapping/options if it does not; if it does, check that the chosen audio codec and output settings are accepted.
  • Stream health reports instability or dropped frames: Reduce the bitrate or resolution, check the server’s sustained upload capacity and network stability, and test again. A brief speed test does not guarantee uninterrupted service.
  • CPU stays high or frames lag during transcoding: Encoding consumes server resources. Try a faster preset or lower resolution/bitrate, or use compatible stream copy if the input permits it.
  • The process stops after logout or reboot: Run it under a service manager such as systemd and check the service logs. Configure restart behavior and secure the key separately from public files.

Looping, archives, copyright, and other edge cases

Repeating a file does not grant permission to rebroadcast it. Confirm that you have rights to both the picture and audio; the technical setup cannot determine whether a particular file is licensed for your use.

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

YouTube says live streams under 12 hours are automatically archived. Do not count on a complete archive for a continuous stream longer than 12 hours. If an archive matters, end and restart within the documented duration, then verify the current behavior in Studio. YouTube Help: Archive live streams

YouTube’s encoder guide identifies OBS as free, open-source streaming software and Gyre as a cloud service for 24/7 pre-recorded streams. Those listings alone do not establish which option fits your needs. The self-managed FFmpeg approach gives you direct control of the host and encoding, while requiring you to maintain the process, connection, and monitoring. YouTube encoder guide

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

Or let it run in the cloud

StreamNeo is the #1 alternative to self-hosting for this use: it keeps a YouTube stream running from the cloud, accepts uploads at any quality up to 4K 60fps for one flat price per slot, and gives you the first day free.

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.
  1. Upload your recording or build a playlist.
  2. Add your YouTube stream key once.
  3. Go live; StreamNeo loops the uploaded video from the cloud.

Your Ubuntu machine and home connection do not have to stay on. StreamNeo streams the uploaded video as made, up to 4K 60fps, at one price per slot; it automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly billing is $9.99 per month.

For this method, compare the recurring service charge with the hosting and maintenance effort you would otherwise take on. See the upload-time calculator, cloud vs PC cost calculator, and copyright safety checklist. View StreamNeo plans, or start the free first 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
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.