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
VGSources
24/7 streaming

How to Run a 24/7 Children’s YouTube Stream with Docker and FFmpeg

A practical Docker and FFmpeg setup for looping video to YouTube Live, with RTMPS settings, restart limits, child-directed channel considerations, and recovery checks.

By VGSources Team 10 min read

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.

You can keep a pre-recorded, child-directed YouTube Live stream running around the clock by looping a media file through FFmpeg in a Docker container and publishing it to YouTube over RTMPS. Docker can restart an exited container, and FFmpeg can retry some temporary output failures, but neither detects every frozen video, silent audio track, rejected stream, or broken source. Treat this as a service to monitor and recover—not guaranteed uptime.

What you need before you start

  • A YouTube channel that is verified and has had no live-stream restrictions in the previous 90 days.
  • A host that can run Docker and sustain the video encoding workload. If you transcode to H.264, make sure the host can encode your chosen resolution and frame rate continuously.
  • A video you have the rights to stream, including its game footage, music, sound effects, and any other included material.
  • A reliable internet connection with enough upload capacity for the stream, plus headroom for other traffic and any backup stream.
  • Access to YouTube Studio’s Live Control Room so you can create or select a stream, retrieve its server URL and stream key, inspect the preview, and monitor stream health.

This example loops one video file. A playlist can use the same general publishing process, but the playback and transition behavior depends on how you assemble and feed that playlist to FFmpeg.

Choose the stream settings

Resolution, frame rate, and codec

Choose a profile your source video and upload connection can sustain. YouTube’s encoder guidance supports H.264, H.265/HEVC, and AV1, with frame rates up to 60 fps. This example transcodes to H.264 because it is a widely supported baseline; it is not automatically the best choice for every host. H.265 or AV1 may suit a particular workflow if your encoder hardware and end-to-end setup support them.

For 1080p30 H.264, YouTube lists 5 Mbps as the minimum and 14 Mbps as the recommended video bitrate. These are not universal bitrate settings: use YouTube’s current bitrate table for your actual codec, resolution, and frame rate, and account for audio in the total. Lower the output profile if your real upload capacity cannot sustain it.

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.

Keyframes, rate control, and audio

  • Use RTMPS, YouTube’s recommended secure version of RTMP.
  • Use constant bitrate (CBR) encoding. In the example below, matching the target and maximum video rates helps keep the output near the configured bitrate.
  • Set a two-second keyframe interval; YouTube recommends two seconds and says not to exceed four seconds. For 30 fps, a two-second GOP is 60 frames.
  • Use a supported audio codec such as AAC or MP3. The example uses AAC at 128 kbps.

Check upload capacity

YouTube advises leaving 20% upload-bandwidth headroom and counting both primary and backup streams in the calculation. For a 14 Mbps video stream plus 128 kbps audio, the encoded total is about 14.13 Mbps before transport overhead. With 20% headroom, that one stream needs roughly 17.7 Mbps of available upload capacity; a simultaneous backup stream needs additional capacity. Check upload performance rather than relying on a download-speed result, and retest under the network conditions you expect during operation.

Get YouTube’s publishing details

  1. In YouTube Studio, open the Live Control Room and create or select the live stream you intend to use.
  2. Copy the server URL and stream key shown for the event. Use the RTMPS server URL YouTube provides; do not substitute a guessed endpoint.
  3. Keep the stream key private. It is the credential that lets an encoder send video to your channel. Do not put it in a public repository, screenshot, support post, or shared command history. If it is exposed, reset it in Live Control Room and update the encoder configuration.
  4. Set the audience accurately, including whether the content is made for kids. YouTube disables or restricts features for streams designated made for kids, including live chat and live chat donations, comments, the notification bell, and personalized advertising. Other features, including cards/end screens and Super Chat or Super Stickers, are also limited; contextual ads may still appear.

Build a Docker container for FFmpeg

The following small image installs FFmpeg in a Debian-based container. It is a starting point, not a tested image for every host or media file; confirm that your installed FFmpeg build supports the codecs and options you use. Pin and update the base image and packages according to your own maintenance policy.

FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg 
    && rm -rf /var/lib/apt/lists/*
WORKDIR /work
ENTRYPOINT ["ffmpeg"]

Save this as Dockerfile in a working directory. Put the source video in a media subdirectory and save it as video.mp4. Build the image:

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.
docker build -t youtube-loop-ffmpeg .

Configure the loop and RTMPS output

Create a local file named stream_key containing only the stream key from YouTube. Restrict access to it, keep it out of source control, and do not include it in logs or screenshots. The Compose example mounts that file as a secret so the key is not written into the command or Compose environment. Docker secret handling and file permissions depend on how Docker Compose is run on your host; verify the mounted file is readable by the container.

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

Create compose.yaml beside the Dockerfile and media folder. Replace PASTE_YOUTUBE_RTMPS_SERVER_URL with the exact RTMPS server URL from Live Control Room. The command appends the secret key to that server URL, as expected by the typical YouTube encoder workflow; if YouTube gives you a differently formatted ingest URL, follow the displayed format instead.

services:
  stream:
    build: .
    container_name: youtube-loop
    restart: unless-stopped
    volumes:
      - ./media:/media:ro
    secrets:
      - stream_key
    command:
      - /bin/sh
      - -c
      - >
        KEY=$$(cat /run/secrets/stream_key);
        exec ffmpeg
        -hide_banner
        -stream_loop -1 -re -i /media/video.mp4
        -map 0:v:0 -map 0:a:0?
        -c:v libx264 -preset veryfast
        -b:v 14M -maxrate 14M -bufsize 28M
        -g 60 -keyint_min 60 -sc_threshold 0
        -c:a aac -b:a 128k
        -f fifo -fifo_format flv
        -attempt_recovery 1 -recovery_wait_time 1
        "PASTE_YOUTUBE_RTMPS_SERVER_URL/$$KEY"

secrets:
  stream_key:
    file: ./stream_key

The example assumes a 1080p30 H.264 target with a two-second GOP, AAC audio, and a source file with video and audio. Change the bitrate and keyframe values for the profile you selected. If your source has no audio, remove the audio mapping and encoding options and test the resulting output. The FFmpeg FIFO muxer options shown are intended to attempt recovery after temporary output failures; confirm that your installed build accepts them.

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.

-stream_loop -1 repeats the input indefinitely, while -re reads it at real-time speed rather than sending it as fast as possible. Because this example encodes with libx264, observe CPU load and output health after launch. A source file that cannot be read, has an unexpected stream layout, or cannot be encoded at the chosen profile needs a corrected input or lower-cost settings.

Start the stream and verify the whole path

  1. Start the container with docker compose up -d --build.
  2. Check that it is running with docker compose ps, then inspect recent output with docker compose logs --tail=100 -f stream. Look for input, codec, authentication, and connection errors.
  3. Open the event in YouTube Studio’s Live Control Room and wait for the encoder preview. Check that the picture, audio, resolution, and stream-health indicators are as expected before you make the event public or go live.
  4. Verify playback on the event’s watch page and on a mobile device. If you record locally as well, check that the archive file grows and that a sample can be played back.
  5. Keep both the host and Live Control Room under observation after launch. Alert on container exit, stalled or frozen media, silent audio, loss of ingest, and unexpected changes in stream health; a running container alone is not proof that viewers are receiving a progressing stream.

Understand restarts, recovery, and event length

Docker restart policies handle exits, not stream health

This Compose file uses unless-stopped: Docker restarts an exited container and generally brings it back after a daemon restart, except when an operator has manually stopped it. Use always instead if you want Docker to restart it even after a manual stop when the daemon restarts. Docker’s restart-policy monitoring activates only after successful startup, defined in its documentation as running for at least 10 seconds.

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

A restart policy responds to a container or process stopping. It is not a health check. It cannot tell that FFmpeg is producing frozen frames, the audio has gone silent, the input is invalid, the stream key has expired, or YouTube has rejected the feed.

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 recovery is best-effort

The FIFO muxer’s -attempt_recovery 1 and -recovery_wait_time 1 options can attempt to recover output after a temporary network failure while FFmpeg continues processing at real-time rate. They do not promise gapless output or recovery from every network, credential, host, input, or YouTube-side failure. Reconnection options for network inputs address input-side reconnection; they are not a substitute for recovery of the RTMPS output to YouTube.

Plan segments and archives separately from continuous transmission

YouTube says streams under 12 hours are automatically archived. That does not establish that one uninterrupted, indefinitely open 24/7 event will produce a complete replay. For archive management and easier incident recovery, plan intentional shorter event segments, test the transition and restart procedure, and verify archive behavior in Studio before deployment. Decide how you will handle a stopped event, a replacement event, and any incomplete archive rather than relying on a single endless process.

Make it suitable for a child-directed channel

  • Select the made-for-kids audience setting based on the content and applicable YouTube requirements, not on which features you want enabled. Chat and some other interaction or monetization features may not be available.
  • Use only gameplay, music, images, and other material you have permission to stream. A game’s availability or a video’s presence on YouTube does not itself establish permission to rebroadcast it.
  • Do not assume that a 24/7 schedule or looping format makes a channel eligible for monetization. YouTube feature restrictions for made-for-kids content apply, and the platform’s monetization and reused-content decisions are separate from whether FFmpeg can transmit the video.
  • Assign a person to monitor stream health and respond to reports, takedowns, or unexpected content. This technical guide does not establish legal obligations for a particular operator or jurisdiction.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test recovery before relying on the stream

YouTube recommends testing the full setup well before a planned event, inspecting the preview before going live, testing backup failover by stopping the primary encoder or disconnecting its network, and monitoring audio and video continuously. Apply that advice to a 24/7 installation with a written runbook:

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.
  1. Test the complete path from media file through Docker and FFmpeg to YouTube, including the intended resolution, frame rate, audio, and RTMPS key.
  2. Simulate a container exit and confirm that your selected Docker policy restarts it as intended.
  3. Test the loss of the primary network or encoder and verify that your backup procedure works. YouTube recommends a tested backup encoder; a restart policy alone is not a backup encoder.
  4. Document how to inspect logs, verify YouTube ingest, replace a compromised key, restart or replace an event, and escalate a failure that does not recover.
  5. Keep monitoring for actual video and audio progress. A process status or successful reconnect message is not enough to prove the stream is healthy.

A UPS battery backup may help bridge a brief power interruption, and an Ethernet cable may be useful where a fixed wired connection suits the installation. These are practical options, not requirements or guarantees against longer outages.

Troubleshooting common failures

Symptom Likely area to check What to do
Container exits shortly after starting Input path, file permissions, unsupported media, FFmpeg option or codec error Read docker compose logs stream; confirm the media is mounted at /media/video.mp4, inspect the file’s streams, and test the command against a short sample before restarting the service.
Container runs, but YouTube shows no incoming video RTMPS server URL, stream key, event selection, or YouTube ingest state Compare the configured endpoint with the exact values in Live Control Room, check for a reset or mistyped key, inspect FFmpeg output, and confirm the selected event is the one being monitored.
Repeated disconnects or buffering Upload capacity, network stability, or the selected bitrate Measure upload under operating conditions, leave YouTube’s recommended 20% headroom, count any backup stream, and reduce resolution or bitrate if the available upload cannot sustain the total.
Container is running but the picture freezes or audio disappears Source playback, encoder progress, host resource pressure, or a stalled output Check logs and host load, inspect the source and YouTube preview, and add monitoring that detects stalled media rather than relying on Docker’s process state.
Stream returns after a reconnect but has a gap Temporary network interruption or event/encoder recovery behavior Check FFmpeg and Live Control Room status, follow the documented restart or event-replacement procedure, and accept that retries do not guarantee gapless transmission.
Archive is missing or incomplete Event duration, segmentation, or archive processing Review event and archive status in Studio. Plan segments under YouTube’s stated automatic-archive duration and verify the current behavior for your workflow.

Or let it run in the cloud

If you do not want a Docker host and home connection to be part of the 24/7 operating plan, 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. Nothing has to stay powered on at home. Each slot streams the uploaded quality up to 4K 60fps at one flat price per slot, without quality tiers; it can automatically recover if YouTube drops the stream. The first day is free with no card. Monthly billing is $9.99 per month. Each slot includes 10 GB storage, pooled across active slots, 24/7 looping and playlists, and StreamNeo team support. StreamNeo is for YouTube streams from uploaded videos, not camera broadcasts. Start the 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 Patch Notes

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.