DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
DocumentaryTube
Docker

How to Use Docker to Run a Prerecorded YouTube Live Stream on a VPS

Use Docker and FFmpeg on a VPS to send prerecorded video to YouTube Live. Learn the encoder workflow, RTMPS settings, container setup, key protection, and common fixes.

By DocumentaryTube Team 8 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 use Docker and FFmpeg on a VPS to send a prerecorded video to YouTube Live. YouTube supplies the ingest server URL and stream key; FFmpeg reads your file and sends the encoder feed, while Docker packages the process. The steps below show a self-managed approach, with an important caveat: the exact FFmpeg command depends on your file and installed build, so validate it with your media before relying on it for a scheduled broadcast.

What you need before you start

  • A YouTube channel with live streaming enabled. YouTube says first-time enablement can take up to 24 hours.
  • A VPS with Docker and the Docker Compose plugin installed, plus enough sustained outbound bandwidth for your chosen stream bitrate.
  • A prerecorded video file accessible to the container.
  • The stream server URL and stream key from YouTube Studio. Treat the key like a password: anyone who has it may be able to broadcast to your stream.

YouTube’s encoder workflow is to create or schedule a stream in Live Control Room, configure the encoder with the server URL and key, start the encoder, and monitor the preview. See YouTube’s encoder setup instructions.

Prepare the YouTube stream

  1. Open YouTube Studio and go to Live Control Room.
  2. Create a stream or schedule a broadcast, then copy the server URL and stream key shown for that stream.
  3. Keep the values private. Do not put the key in a public Dockerfile, repository, screenshot, container image, or shared log. A runtime environment variable is convenient for a small deployment, but it may still be visible to users with access to inspect the container or VPS. Use your hosting platform’s secret manager if available.
  4. For a scheduled broadcast, start the encoder and wait for the preview to arrive before selecting Go live in Live Control Room.

Choose the video and output settings

First decide whether to pass through compatible encoded tracks or transcode them. Stream-copying avoids the CPU cost of re-encoding, but only works when the source tracks and stream parameters are suitable. Transcoding gives you control over output codec, resolution, frame rate, and bitrate, but requires more CPU and can fail to keep up if the VPS is undersized.

YouTube’s current encoder guidance

YouTube’s encoder settings guidance accessed in 2026 lists H.264, H.265/HEVC, and AV1 video for RTMP/RTMPS ingest, up to 60 fps; constant bitrate (CBR); and a recommended two-second keyframe interval, never above four seconds. Supported audio formats include AAC and MP3. For stereo audio, YouTube’s advanced recommendations include 44.1 kHz and 128 kbps; Rec. 709 is its SDR color recommendation. These are platform recommendations, not proof that a particular file or FFmpeg build is configured correctly. See YouTube’s encoder settings, bitrates, and resolutions.

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.
Output H.264 bitrate: minimum / recommended AV1 or H.265 bitrate: minimum / recommended
1080p, 60 fps 6 / 17 Mbps 4 / 12 Mbps
1080p, 30 fps 3 / 10 Mbps 3 / 8 Mbps
720p, 60 fps 3 / 6 Mbps 3 / 6 Mbps
720p, 30 fps 1 / 4 Mbps 1 / 3 Mbps

These are YouTube’s published minimum and recommended video bitrates, accessed in 2026; they are not VPS bandwidth guarantees. Plan for sustained egress above the selected video bitrate, allowing for audio and protocol overhead and network variation.

Build a container and mount the media

The following is an implementation pattern, not a universally tested Docker recipe. It uses a Debian base image and installs FFmpeg during the build; package versions and available encoders vary. Validate the build and command against your file and current FFmpeg version before scheduling a broadcast.

In a deployment directory, create a Dockerfile:

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

Create a compose.yaml alongside it. Replace the server URL value with the exact ingest URL from YouTube Studio. Set YOUTUBE_STREAM_KEY in the VPS runtime environment rather than committing it in this file.

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.
services:
  encoder:
    build: .
    restart: unless-stopped
    environment:
      YOUTUBE_SERVER_URL: "SET_FROM_YOUTUBE_STUDIO"
      YOUTUBE_STREAM_KEY: "${YOUTUBE_STREAM_KEY}"
    volumes:
      - ./media:/media:ro
    command:
      - -re
      - -stream_loop
      - "-1"
      - -i
      - /media/program.mp4
      - -c:v
      - libx264
      - -preset
      - veryfast
      - -b:v
      - 6000k
      - -maxrate
      - 6000k
      - -bufsize
      - 12000k
      - -r
      - "30"
      - -g
      - "60"
      - -c:a
      - aac
      - -b:a
      - 128k
      - -ar
      - "44100"
      - -f
      - flv
      - "${YOUTUBE_SERVER_URL}/${YOUTUBE_STREAM_KEY}"

This example asks FFmpeg to read the file in real time, loop it, encode H.264 at 6 Mbps and 30 fps with a two-second GOP, encode AAC audio, and send an FLV-formatted feed to the configured destination. It assumes the file has usable audio and that the installed FFmpeg build includes the libx264 encoder. Adjust or replace these settings to match the media, YouTube’s current guidance, and your actual ingest URL format. If the Studio server URL already contains a path separator at the end, avoid adding a duplicate slash when forming the destination.

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

For compatible existing H.264/AAC material, stream-copying with -c:v copy -c:a copy may reduce CPU use, but do not assume the source meets YouTube’s settings or that stream-copying is suitable for every file. Inspect the input with FFmpeg’s probing tools and test the resulting preview. If there is no audio track, remove or revise the audio mapping and encoding options deliberately rather than sending an unintended silent stream.

Protect the key and start the container

  1. Put the video at ./media/program.mp4 or change the mounted path and input filename in Compose. The media mount is read-only so the container cannot modify the source file.
  2. Set the runtime variables in the VPS session or secret manager. For a basic shell session, export them without saving the values in a tracked file: export YOUTUBE_SERVER_URL='the-exact-server-url-from-studio' and export YOUTUBE_STREAM_KEY='your-private-key'. Shell history and process/container inspection can expose secrets, so use a proper secret facility where possible and limit VPS access.
  3. Build and start with docker compose up -d --build.
  4. Review output with docker compose logs -f encoder. Confirm that FFmpeg opens the input and connects without repeated errors.
  5. In Live Control Room, wait for the preview and check stream health, picture, and audio. For a scheduled stream, select Go live only after the preview is present.

Do not publish logs that include the full output URL if it contains the stream key. Avoid placing the key in shell commands that may be recorded or copied into support tickets.

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.

RTMPS, network access, and protocol choice

For an ordinary VPS-to-YouTube encoder connection, RTMPS is the sensible default: YouTube recommends it, and it encrypts the RTMP stream. Google’s documentation describes RTMPS as an RTMP video stream tunneled through SSL. RTMPS needs a valid endpoint, port 443, and correct hostname handling for SNI; a URL that looks similar but is not the valid Studio endpoint can fail TLS authentication. See YouTube’s RTMPS ingestion guidance.

Protocol Encryption and listed video codecs Practical note
RTMP Unencrypted; H.264 Not the preferred choice where encrypted ingest is available.
RTMPS Encrypted; H.264 Practical baseline for typical low-latency encoder ingest.
HLS Encrypted; H.264 and HEVC Segment-based delivery generally has more latency than RTMP/RTMPS.
DASH Encrypted; H.264 and VP9 Segment-based delivery generally has more latency than RTMP/RTMPS.

YouTube documents these ingest protocol distinctions in its protocol comparison. If your codec or delivery requirements call for HLS or DASH, account for the added workflow complexity and latency rather than treating them as drop-in RTMPS settings.

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.

Looping, restarts, and ending a broadcast

The sample uses FFmpeg’s -stream_loop -1 to repeat one file indefinitely. Remove that option for a single pass. A playlist or changing program needs a deliberate input and scheduling design; a single-file loop is not a playlist manager.

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

Docker’s restart: unless-stopped can restart a stopped process, but it does not decide what should happen when a file ends, whether a scheduled broadcast should begin, or whether YouTube should be taken live again. Make those policies explicit and test them. To end intentionally, stop the encoder/container and use the relevant Live Control Room controls. YouTube says streams shorter than 12 hours are automatically archived when ended; this archive behavior is separate from Docker’s restart policy.

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

Monitoring and troubleshooting

  • No preview or connection timeout: check that the stream key and server URL belong to the intended stream, that the endpoint and protocol are correct, and that outbound traffic is allowed. For RTMPS, verify port 443 and the hostname/SNI details.
  • TLS or certificate error: confirm that the endpoint is an RTMPS endpoint, uses port 443, and preserves the expected server hostname for SNI. The RTMPS guide documents these connection requirements.
  • Container exits immediately: inspect docker compose logs encoder for a missing media path, unreadable file, invalid destination, unsupported encoder, or malformed options. Confirm the mounted filename exists inside /media.
  • Video appears but health is poor: check YouTube’s stream health for low bitrate or frame-rate mismatch. Ensure the VPS has sustained network capacity for the configured output and that the frame rate/keyframe settings are intentional.
  • Picture but no sound: inspect whether the input has an audio stream and whether FFmpeg maps and encodes it in a supported format. YouTube’s health guidance flags a missing audio stream as an issue.
  • Stream stops when the file ends: decide whether the broadcast should be one pass or loop continuously. Docker restart behavior is not a substitute for choosing a media-loop or scheduling policy.

YouTube’s LiveStreams API reference documents health status issues including low bitrate, frame-rate mismatch, and missing audio. Use those indicators alongside container logs and the actual Live Control Room preview.

VPS sizing and cost

There is no universal CPU or RAM specification for this setup. A stream-copy workload, a 1080p transcode, and a higher-resolution transcode have different compute demands; source format, encoder preset, target bitrate, and required continuity also matter. Choose a VPS only after deciding whether you will transcode and measuring the actual workload on representative media. Ensure its sustained outbound capacity comfortably exceeds the selected video bitrate plus audio and overhead. YouTube’s bitrate table is a planning reference, not a provider sizing rule.

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.

Budget for the VPS itself and any storage or bandwidth charges imposed by your provider. No single VPS price or minimum plan can be stated responsibly without a provider, region, configuration, and workload.

Or let it run in the cloud

If maintaining a VPS, Docker, FFmpeg, and restart behavior is more work than you want, StreamNeo is a cloud service for keeping a YouTube channel live from uploaded videos. Upload your recording or build a playlist, add your YouTube stream key once, and go live. Nothing needs to stay on at home; it streams the uploaded quality up to 4K 60fps at one price per slot, automatically recovers if YouTube drops the stream, and includes a first day free with no card. Monthly is $9.99 per month. 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 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.