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

How to Set Up FFmpeg on a VPS for a Continuous YouTube Stream

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

To run a continuous YouTube stream from a VPS, install FFmpeg, connect it to a YouTube Live broadcast using the RTMPS endpoint and stream key, test the input and output, then run the command under systemd supervision. The commands below use Ubuntu and a looping video file as an example; the right input flags and VPS capacity depend on your media and whether FFmpeg must encode it.

What you need before you start

  • An Ubuntu VPS with a reliable network connection and enough sustained outbound capacity for your chosen stream bitrate. There is no universal CPU or RAM requirement: transcoding and stream-copying have different resource needs, so test the actual source and settings on the VPS you plan to use.
  • A video file or other input that FFmpeg can read. This example loops a file; a live feed or generated input needs different input and reconnect options.
  • A YouTube channel that can create a live broadcast, plus its RTMPS ingestion URL and stream key.
  • Shell access with permission to install packages and configure a system service.

YouTube recommends RTMPS, its secure RTMP option. In Live Control Room, verify that you have selected the RTMPS URL rather than assuming the standard RTMP URL shown by default is secure. YouTube’s RTMPS guidance explains the encryption and endpoint selection.

Install FFmpeg on Ubuntu

Ubuntu is the example here, not a requirement. Package versions vary by Ubuntu release and CPU architecture, so check the package available for your VPS image.

  1. Update APT’s package index and install FFmpeg:

    sudo apt update
    sudo apt install ffmpeg
  2. Confirm it is installed and inspect its build:

    ffmpeg -version
  3. Check that your build includes the encoder you intend to use. The example below uses libx264; if FFmpeg reports that the encoder is unavailable, use a compatible build or choose an encoder supported by your installation.

    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.

Ubuntu documents APT installation and lists FFmpeg in its package catalog: Ubuntu Packages and Ubuntu Server package management.

Create the YouTube broadcast and protect its key

  1. Open YouTube Live Control Room and create or select the broadcast.
  2. Retrieve the broadcast’s ingestion URL and stream key. Select the RTMPS endpoint.
  3. Treat the key like a password. Do not put a real key in a public repository, tutorial, shell transcript, or support ticket. Store it in a protected configuration file or root-readable systemd environment file.

YouTube’s Live Streaming API documents an RTMPS primary ingestion URL: LiveStreams API reference.

Build and test an FFmpeg command

This illustrative command reads and loops a local MP4, transcodes video to H.264 and audio to AAC, and sends the result to YouTube. Replace the file path, RTMPS address, and key with your own values. In this example, <RTMPS_URL>/<STREAM_KEY> stands for the complete RTMPS publishing address with the key in the position YouTube specifies; it is not literal text to paste into a working command.

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 /srv/stream/input.mp4 
  -c:v libx264 -preset veryfast -pix_fmt yuv420p 
  -r 30 -g 60 -b:v 5M -maxrate 5M -bufsize 10M 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "<RTMPS_URL>/<STREAM_KEY>"
  • -re reads the file at its native rate rather than sending it as fast as possible.
  • -stream_loop -1 requests an indefinite loop for a file input. Remove it for a non-looping file or a live source.
  • -c:v libx264 and -c:a aac encode the video and audio. This uses VPS resources; the example is not a universal performance guarantee.
  • -r 30 sets a 30 fps output, while -g 60 sets a 60-frame GOP, equivalent to a two-second keyframe interval at 30 fps.
  • -b:v, -maxrate, and -bufsize set video rate-control values. Adjust these to your resolution, source, and available network capacity.
  • -f flv selects the output container used for this RTMP-family publishing workflow.

If the source already has compatible codecs, bitrate, frame rate, and keyframes, stream-copying may reduce encoding work, but it also means the source must already meet your output needs. Inspect the file’s streams before choosing; FFmpeg’s documentation covers its protocol and format options: FFmpeg Protocols Documentation.

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

Choose bitrate, frame rate, and keyframes

YouTube recommends constant bitrate (CBR) and a two-second keyframe interval, with intervals no longer than four seconds. Its H.264 recommendations include these ranges:

Output YouTube-recommended H.264 video bitrate
720p30 3–8 Mbps
1080p30 5–14 Mbps
720p60 3–8 Mbps
1080p60 6–17 Mbps

These are YouTube’s recommended ranges, not a promise of quality or a VPS capacity estimate. Choose a rate the server can sustain with network headroom, then test representative audio and motion. At 30 fps, -g 60 gives a two-second keyframe interval; for other frame rates, set the GOP accordingly. YouTube also recommends stereo audio at 44.1 kHz and 128 Kbps. See YouTube’s live encoder settings for its current guidance; the source page does not state a publication year (verified 2026).

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.

Run FFmpeg as a systemd service

Running FFmpeg in a shell ties it to that session. A systemd service can launch the process at boot and restart it after certain failures, which is more suitable for an unattended stream. It cannot keep the stream available through every VPS, network, input, account, or YouTube problem.

Store the publishing address outside the unit

Create /etc/youtube-stream.env with the publishing address in an environment variable, for example:

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.
YOUTUBE_RTMPS_URL="your-complete-RTMPS-publishing-address-with-key"

Use the actual address supplied for your broadcast, not the explanatory text above. Restrict the file’s permissions so only root and the service account can read it. A wrapper script with restrictive permissions can be preferable if your command requires complex quoting or environment handling.

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

Create the unit

Create /etc/systemd/system/youtube-stream.service. Change the service user and paths to match your server. This single-line ExecStart is illustrative; check systemd’s environment substitution and escaping behavior for your installed version.

[Unit]
Description=FFmpeg YouTube live stream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=stream
WorkingDirectory=/srv/stream
EnvironmentFile=/etc/youtube-stream.env
ExecStart=/usr/bin/ffmpeg -re -stream_loop -1 -i /srv/stream/input.mp4 -c:v libx264 -preset veryfast -pix_fmt yuv420p -r 30 -g 60 -b:v 5M -maxrate 5M -bufsize 10M -c:a aac -b:a 128k -ar 44100 -f flv ${YOUTUBE_RTMPS_URL}
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable, start, and inspect it

  1. Reload systemd’s unit definitions and enable the service at boot while starting it now:
    sudo systemctl daemon-reload
    sudo systemctl enable --now youtube-stream.service
  2. Check service status:
    sudo systemctl status youtube-stream.service
  3. Follow its logs while checking the YouTube preview:
    sudo journalctl -u youtube-stream.service -f

Restart=on-failure is a process recovery policy, not an uptime guarantee. Ubuntu’s systemd documentation describes restart behavior and start-rate limiting; repeated failures can hit the configured limit rather than restart forever. An intentional systemctl stop does not trigger the restart policy. See the Ubuntu Noble systemd.service manual.

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

Test the stream and check YouTube health

Before relying on the stream, test the actual input, encoder settings, and VPS connection. YouTube recommends testing with audio and movement representative of the intended broadcast and monitoring stream-health messages.

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.
  • Confirm the Control Room preview appears and the broadcast is receiving data.
  • Check that audio is present, the aspect ratio is correct, and motion plays smoothly.
  • Watch FFmpeg logs for input errors, encoder problems, or connection failures.
  • Verify what happens after an FFmpeg process restart; check that the broadcast is still healthy in Live Control Room.
  • Arrange an alert or recurring check for a failed service. A running FFmpeg process alone does not prove that viewers can see a healthy stream.

Troubleshoot common failures

Symptom Likely cause What to check or do
YouTube receives no video Wrong endpoint, malformed publishing address, invalid key, or the broadcast is not ready. Verify the RTMPS URL and key in Live Control Room, confirm the broadcast is selected, and inspect FFmpeg’s connection errors.
FFmpeg exits immediately Missing input file, unsupported codec, invalid option, unavailable encoder, or incorrect permissions. Run the command interactively, check the file path and FFmpeg output, verify the encoder with the installed build, and confirm the service user can read the input.
Video stutters or the connection drops Insufficient sustained VPS egress, network instability, or a bitrate too high for the available route. Check the provider’s egress limits and actual sustained capacity; lower bitrate or output settings and retest with representative media.
Audio is missing or wrong The file has no audio stream, the wrong stream is selected, or conversion settings do not match the input. Inspect the input’s streams and confirm YouTube’s preview and health messages show audio.
The service does not recover after repeated errors systemd start-rate limiting, a persistent input or credential problem, or a failure outside FFmpeg. Read the journal, fix the underlying error, check the unit’s rate-limit behavior, then start the service again. A restart policy cannot repair provider outages, account restrictions, or a missing file.

Cost and operating trade-offs

A VPS keeps the encoder running away from your home computer, but you are responsible for the server plan, outbound data limits, configuration, monitoring, and recovery. The amount of processing depends on whether FFmpeg transcodes or copies the source, so test the proposed setup instead of choosing a VPS size from resolution alone. Also account for the ongoing outbound bitrate and your provider’s egress rules.

Or let it run in the cloud

If your goal is a 24/7 YouTube channel rather than managing a Linux encoder, StreamNeo is a cloud alternative: upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home. It plays uploaded videos to YouTube; it does not stream from a camera.

  • One flat price per slot for any uploaded quality up to 4K 60fps, with no re-encode or quality tiers.
  • Automatic recovery if YouTube drops the stream.
  • The first day is free with no card, one free day per account.
  • Each slot includes one always-on stream, 10 GB storage per slot pooled across active slots, looping and playlists, and StreamNeo team support. The product is the same on every plan; only the billing length changes.

Monthly: $9.99 per month. You can also choose $0.99 per day daily, $2.99 per week weekly, $49.99 for 6 months for six months, or $89.99 a year yearly. Cancel any time. UPI and cards are available in India; card checkout is available worldwide. For five or more slots, contact support.

See StreamNeo or its plans, then start your free first day.

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.

Frequently Asked Questions

Does the VPS need a desktop environment?

No. This setup runs FFmpeg and systemd from the Ubuntu command line; a graphical desktop is not part of the workflow.

Can I use this setup with a live camera input?

The example is for a looping file. A camera or other live input needs input-specific FFmpeg options and its own reconnect behavior.

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.

Read next

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.