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
FFmpeg

How to Loop MP4 Videos with MediaMTX for a YouTube Live Stream

FFmpeg can loop an MP4 into a MediaMTX path, but YouTube needs its own stream URL and key. Follow the setup, compatibility checks, and monitoring steps.

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

To repeat an MP4 indefinitely, FFmpeg can publish it to a MediaMTX path with -stream_loop -1. That documented command sends the video to MediaMTX running locally; it is not YouTube’s ingest address. YouTube is a separate step: get the stream URL and key from Live Control Room, then configure an encoder or relay to send a compatible feed to YouTube.

What MediaMTX, FFmpeg, and YouTube each do

FFmpeg reads and repeats the MP4. MediaMTX receives the resulting stream at a configured path. YouTube receives a feed at the stream URL and key shown in Live Control Room. These are separate endpoints and roles: the MediaMTX example destination rtmp://localhost:1935/mystream points to a MediaMTX server on the same machine, not to YouTube.

The official MediaMTX FFmpeg page documents publishing to MediaMTX, while YouTube’s encoder instructions describe sending a feed to YouTube. Those pages do not provide a single official end-to-end MediaMTX-to-YouTube relay command. The steps below therefore cover the documented loop and YouTube setup separately, without presenting an unverified relay command as official configuration.

Loop an MP4 into MediaMTX with FFmpeg

  1. Install and start MediaMTX. Follow the MediaMTX basic usage guide for your operating system and confirm the server is running. The example below assumes MediaMTX is reachable on the same computer at its default RTMP port.
  2. Make the MP4 available to FFmpeg. Open a terminal in the file’s folder, or use the full path in place of file.mp4.
  3. Run the documented publishing command:
    ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f flv rtmp://localhost:1935/mystream
  • -stream_loop -1 asks FFmpeg to repeat the input indefinitely.
  • -re reads the file at real-time pace rather than sending it as fast as possible.
  • -c copy copies the existing audio and video streams instead of re-encoding them.
  • -f flv selects the container used for this RTMP publishing example.
  • rtmp://localhost:1935/mystream is the local MediaMTX RTMP destination, with mystream as the path. It is not YouTube’s server address.

MediaMTX also documents publishing with RTSP, and describes RTSP as its recommended FFmpeg method. Choose a protocol that your MediaMTX setup and the next component in your workflow can both use; see Publish with FFmpeg for the documented protocol examples. MediaMTX’s RTMP clients page covers RTMP publishing and reading paths.

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.

Configure YouTube Live as a separate destination

  1. In YouTube Studio, open Live Control Room and create or select the stream. YouTube’s encoder setup instructions explain how to obtain the stream URL and key.
  2. In the encoder that will send the feed to YouTube, enter the URL and key from Live Control Room. Treat the key as a credential; do not publish or share it.
  3. If you choose encrypted RTMP transport, reveal and use YouTube’s RTMPS address from the lock icon in the stream settings. YouTube recommends RTMPS; see Encrypt your stream using RTMPS.
  4. Start sending the feed and wait for the Live Control Room preview. Check the preview and stream health before selecting Go live.

The MediaMTX command above only publishes to MediaMTX. You still need a configured component that reads or relays the MediaMTX stream and sends it to YouTube’s URL and key. The cited MediaMTX and YouTube pages do not specify that complete bridge configuration, so the exact relay setup depends on the tools and topology you choose.

Match the feed to YouTube’s encoder requirements

YouTube’s published encoder settings vary by codec, resolution, and frame rate. For RTMP or RTMPS, its listed video codecs are H.264, H.265 (HEVC), and AV1; audio can use AAC or MP3. YouTube recommends constant bitrate encoding, up to 60 fps, and a two-second keyframe interval, with intervals no longer than four seconds. Consult the current YouTube encoder settings, bitrates, and resolutions table and choose the bitrate row matching the actual codec, resolution, and frame rate you send. A bitrate detached from those settings is not a reliable target.

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.

The MediaMTX sample uses -c copy, so it does not change codecs, bitrate, resolution, frame rate, or keyframe interval. An MP4 file is a container and does not by itself establish that its tracks meet YouTube’s chosen ingest profile. Inspect the file’s audio and video codecs and validate the resulting preview and stream health. Re-encoding may be needed when the source tracks do not match the intended YouTube settings; the exact conversion depends on the source file and selected profile.

Test the loop and monitor the live stream

  • Test with representative movement and audio before relying on the stream. YouTube recommends checking the preview, stream health, and the audio/video quality during the event; its streaming tips cover these checks.
  • Confirm the MP4 actually loops at the end and that audio remains acceptable across the file boundary.
  • Keep Live Control Room open long enough to notice health warnings or a missing preview before selecting Go live.
  • YouTube says streams shorter than 12 hours are automatically archived when ended. Do not assume an indefinitely long stream will be archived as one continuous video.

Common problems and fixes

Symptom Likely cause What to check
FFmpeg cannot connect to the destination MediaMTX is not running, is not reachable at the configured host and port, or is not accepting RTMP on that path. Confirm MediaMTX is running and that the command’s destination matches its configuration. The localhost example only works when MediaMTX is reachable on the same machine.
YouTube does not show a preview The encoder or relay is not sending to the URL and key from the selected Live Control Room stream, or the relay between MediaMTX and YouTube is not configured. Check the YouTube destination credentials and verify that the component reading MediaMTX is actually sending a feed to YouTube.
Video or audio is rejected or unhealthy The source tracks may not match the codec or ingest settings you selected; stream copying does not fix a mismatch. Inspect the source codecs, compare output settings with YouTube’s current table, and test again. Re-encode only if the source is incompatible with the selected profile.
The stream plays too quickly The real-time input pacing option may be missing. Use the documented command with -re before the input.
The video stops after one playthrough The input repeat option may be missing or set differently. Use -stream_loop -1 to request indefinite repetition.
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

If your goal is simply to keep uploaded videos playing on YouTube, StreamNeo is a cloud alternative: upload a recording or build a playlist, add your YouTube stream key, and go live. It loops the uploaded video from the cloud, so no computer or home connection has to stay on. Every slot streams the upload as made, up to 4K 60fps, at one flat price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month.

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

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