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 DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
DocumentaryTube
24/7 streaming

How to Set Up a 24/7 YouTube Stream with MediaMTX and FFmpeg

Learn the two-stage setup for looping a prerecorded file from FFmpeg through MediaMTX to YouTube Live, plus the settings and separate reliability planning a continuous stream needs.

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

To send a prerecorded video to YouTube Live through MediaMTX, run FFmpeg to loop and publish the file to a MediaMTX path, then configure MediaMTX to forward that path to the RTMPS URL and stream key shown in your YouTube Live settings. These are separate steps: FFmpeg feeds MediaMTX; MediaMTX sends the feed to YouTube.

The commands below make a file play in real time and loop, but they do not by themselves provide a complete unattended 24/7 service. A process supervisor, restart and reconnect handling, and a plan for network or host failure need separate configuration.

How the stream is connected

MediaMTX is a live media server and proxy that can accept a real-time publishing feed and forward it to another destination. The path for this setup is:

Video file → FFmpeg → MediaMTX path → YouTube Live

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.

FFmpeg reads the file and publishes it to a named MediaMTX path. MediaMTX then forwards that path to YouTube. MediaMTX documents RTSP as its recommended method for FFmpeg publishing, and also shows an RTMP alternative. See the MediaMTX introduction and its FFmpeg publishing guide.

Before you start

  • A running MediaMTX server reachable by the machine running FFmpeg.
  • FFmpeg installed on the publishing machine, with permission to read your video file.
  • A YouTube channel with access to YouTube Live and a stream key.
  • A source file with both video and audio tracks. MediaMTX warns that YouTube requires both; a video-only stream can be silently rejected. The stream-copy commands below do not create missing audio.
  • Rights to stream the video and audio. A working technical setup does not establish that you have permission to broadcast the content.

Configure YouTube’s destination

  1. Open the channel’s YouTube Live settings and find the current stream URL and stream key. Use the RTMPS endpoint provided there rather than relying on an address copied from an old example.
  2. In MediaMTX’s configuration, set the path you will publish to and its forwarding destination. MediaMTX documents the forwarding value as a destination URL, followed by #, followed by the stream key. Its example is rtmps://a.rtmp.youtube.com/live2#streamKey; treat that hostname as an example only and verify the current endpoint in your account.
  3. Keep the real stream key private. Do not put it in a public configuration example, screenshot, shell history, or source control. Anyone who obtains it may be able to broadcast to your channel.

MediaMTX says to use rtmps:// for encrypted transport. YouTube also recommends RTMPS, describing it as a secure extension of RTMP. See MediaMTX’s YouTube forwarding instructions and YouTube’s RTMPS guidance. Configuration syntax can vary by MediaMTX version, so follow the current configuration reference for the version you run: MediaMTX configuration.

Publish a looping file from FFmpeg

Recommended: publish to MediaMTX over RTSP

Run this on the machine that can reach MediaMTX. Replace file.mp4 with your input file’s path. If FFmpeg is on a different machine from MediaMTX, replace localhost with the server’s reachable hostname or address.

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.
ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream

The -re option reads the file at its native playback rate; -stream_loop -1 asks FFmpeg to repeat it indefinitely; and -c copy copies the input audio and video streams instead of re-encoding them. The output is published to the MediaMTX path named mystream. This is the real-time looping pattern in the MediaMTX FFmpeg guide.

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

Alternative: publish over RTMP/FLV

If your deployment uses RTMP, the MediaMTX guide also shows:

ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f flv rtmp://localhost:1935/mystream

Choose the method supported by your deployment and the existing infrastructure you need to troubleshoot. The cited guidance does not establish a general performance advantage for either option; MediaMTX recommends RTSP for FFmpeg publishing.

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.

Check YouTube’s video and audio requirements

Stream copy preserves the input streams. It does not make an unsupported codec compatible, add an audio track, or guarantee that YouTube will accept a particular file. Inspect the source before going live and confirm that it contains both tracks.

YouTube’s live encoder guidance lists RTMP/RTMPS as protocols; H.264, H.265/HEVC and AV1 as video codecs; frame rates up to 60 fps; and AAC or MP3 audio. It recommends constant bitrate (CBR), a two-second keyframe interval, and says not to exceed four seconds. For stereo audio, it recommends a 44.1 kHz sample rate and 128 Kbps. Bitrate depends on the chosen resolution and frame rate: consult YouTube’s current table for your intended output instead of applying one bitrate to every stream. See YouTube’s live encoder settings.

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

The sample FFmpeg commands use -c copy, so they do not set or change resolution, frame rate, bitrate, codecs, or keyframe interval. If the file does not meet the needs of your YouTube broadcast, you will need a separately planned transcoding setup rather than assuming stream copy will adapt it.

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

Start the feed and verify it

  1. Start MediaMTX with the forwarding configuration in place.
  2. Run the FFmpeg command and check its output for connection or publishing errors.
  3. Open the corresponding YouTube Live control room and wait for the incoming stream preview or status. Confirm that both video and audio arrive before starting the public broadcast.
  4. After a controlled test, confirm that the video loops as expected and that YouTube receives the feed from MediaMTX.

A successful initial connection is not proof of continuous unattended operation. The loop option repeats the source while the FFmpeg process is running; it does not keep that process alive after a crash or restart it after a disconnection.

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

Plan for continuous operation

“24/7” here describes the intended continuous broadcast, not an uptime guarantee from these commands. The documented FFmpeg and MediaMTX examples do not constitute a complete process supervisor, reconnect strategy, storage policy, or failure-recovery design.

For an unattended deployment, plan and test these separately:

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.
  • Process supervision: decide how FFmpeg and MediaMTX start at boot and what restarts them if they exit. The examples above do not configure a supervisor.
  • Reconnection: determine what happens if YouTube or the network drops the connection, and test recovery rather than assuming the existing process will reconnect correctly.
  • Host and network outages: consider how a power loss, server failure, or internet interruption affects the feed and how you will detect and recover from it.
  • Source-file handling: keep the file accessible for the full run and account for available storage and any changes to the media.
  • Monitoring: decide how you will notice a missing feed, rejected stream, or loss of audio and video.

Do not describe the minimal loop command as an automatic-recovery or uptime solution: those behaviors require additional configuration and validation in your own environment.

Troubleshoot common failures

  • FFmpeg cannot connect to MediaMTX: verify that MediaMTX is running, the publishing protocol and port match your setup, the server address is reachable from FFmpeg, and the path is correct.
  • MediaMTX receives the feed but YouTube does not: confirm that the forwarding path is configured, the RTMPS address is current, and the stream key is correct. Check MediaMTX and YouTube status messages for the specific failure.
  • YouTube receives video but rejects or lacks audio: inspect the source file’s tracks. YouTube requires both audio and video; -c copy cannot supply a missing track.
  • The stream stops when FFmpeg exits: -stream_loop -1 loops only while FFmpeg is running. Configure and test process supervision and recovery separately.
  • The picture or sound is not accepted or plays incorrectly: compare the actual source codecs, resolution, frame rate, keyframe interval, and audio setup with YouTube’s current encoder requirements. The copy command does not convert them.
  • The stream key may have been exposed: treat it as compromised and replace it using the controls in your YouTube Live settings.

Or let it run in the cloud

If your goal is to keep a prerecorded video looping on YouTube without maintaining your own FFmpeg and MediaMTX host, StreamNeo is a cloud service for YouTube streams. Upload a recording or build a playlist, add your YouTube stream key once, and go live.

  • Nothing has to stay on at home: the stream runs from the cloud while your computer is off.
  • Videos stream as uploaded, up to 4K 60fps, at one flat price per slot rather than quality tiers.
  • StreamNeo automatically recovers if YouTube drops the stream.
  • The first day is free with no card, one free day per account.
  • Monthly: $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 the Screening Room

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.