October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DocumentaryTube
Admit one · Blog

How to Run FFmpeg 24/7 on Ubuntu Hetzner Cloud for YouTube Live in India

A practical guide to sending a prerecorded video from Ubuntu on Hetzner Cloud to YouTube Live with FFmpeg, systemd supervision, and real-world ingest checks.
Opened Runtime9 min Written byDocumentaryTube Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can run a prerecorded video to YouTube Live from an Ubuntu server on Hetzner Cloud by copying the stream’s RTMPS URL and key from YouTube Studio, sending a paced FFmpeg file input to that endpoint, and supervising FFmpeg with systemd. The server can keep sending after you disconnect from SSH, but only testing can establish whether its CPU and outbound route sustain your chosen stream reliably. For viewers in India, do not assume a particular Hetzner location is best: the server-to-YouTube ingest path and viewers’ playback paths are separate.

What this setup does—and what it does not do

This guide sends a video file stored on a Linux server to YouTube Live. It is suitable for a documentary or other prerecorded program intended to play as a live stream. It does not turn a cloud VM into a camera, build a multi-video playlist with transitions, or guarantee uninterrupted YouTube availability. The Ubuntu server must remain powered on and reachable; systemd can restart a failed FFmpeg process, but cannot fix an unavailable input, an invalid key, or a YouTube ingest outage.

Use a normal public outbound connection for a simple YouTube push. Hetzner Cloud Networks are for private networking between resources; they are not a prerequisite for sending a stream to YouTube. Hetzner documents native cloud-init auto-configuration for Cloud Networks on Ubuntu 22.04 or later, without additional software for that feature, but this is separate from FFmpeg and does not establish that a VM has adequate streaming capacity. Hetzner Cloud Networks documentation.

1. Create a YouTube encoder stream and protect its key

  1. In YouTube Studio, select Create > Go Live, then create or schedule an encoder stream in Live Control Room.
  2. Open the stream’s settings and copy the server URL and stream key. Use the RTMPS URL revealed by YouTube’s lock control; do not substitute a URL guessed from an example. YouTube recommends RTMPS, its encrypted RTMP option. YouTube encoder settings and YouTube Live Control Room guidance.
  3. Treat the key like a password. Do not expose it in screenshots, shell history, public logs, or source control. If it is compromised, a channel owner or manager can reset it using YouTube’s documented flow. Reset a stream key.

Stream key handling varies by deployment. The example below expects the complete destination to be provided in an environment variable rather than typed literally into the command. A protected systemd environment file is one practical option; restrict its permissions and never publish it. Review service files and logs before sharing them, since configuration can contain credentials.

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.

2. Install FFmpeg and confirm the encoder

On the selected Ubuntu release, install FFmpeg from the release’s package repositories or another trusted source appropriate to your system. Confirm the installed build and whether it includes the H.264 encoder used below:

sudo apt update
sudo apt install ffmpeg
ffmpeg -version
ffmpeg -hide_banner -encoders | grep libx264

Package availability and encoder support depend on the Ubuntu release and how FFmpeg was built. If libx264 is absent, choose a build that supports it or revise the command for an encoder your installation actually provides. Do not assume that every build exposes identical codecs or options.

3. Choose resolution, frame rate, and bitrate

YouTube currently lists RTMP/RTMPS ingest and H.264, H.265/HEVC, and AV1 video codecs. For a conventional CPU-based FFmpeg workflow, H.264 is a straightforward choice when the build includes libx264. YouTube recommends constant bitrate (CBR) and a two-second keyframe interval, with a maximum interval of four seconds. Its H.264 guidance lists 10 Mbps for 1080p30 and 6 Mbps for 720p30; the corresponding listed minimums are 5 Mbps and 3 Mbps. These are YouTube’s published recommendations, not a guarantee that a particular VM or network path can sustain them. YouTube encoder settings.

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.
Output target YouTube H.264 recommended bitrate YouTube H.264 minimum
1080p30 10 Mbps 5 Mbps
720p30 6 Mbps 3 Mbps

The example command uses 4.5 Mbps video, 30 fps, and a 60-frame keyframe interval, which corresponds to two seconds at 30 fps. It is an illustration, not a universal preset or a claim that a particular source or Hetzner server was tested. Match the frame rate and output dimensions to the source and the capacity you measure. If the server cannot encode reliably or the outbound path fluctuates, lower the output target rather than running at the edge of capacity.

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

For a stable live stream, outbound capacity matters. YouTube recommends leaving 20% upload headroom and testing the stream; a fast download result does not prove that the server can sustain upload at the required bitrate. Allow room for audio and transport overhead as well as fluctuations. YouTube streaming tips.

4. Send a video file with FFmpeg

FFmpeg documents -re for reading a file at real-time rate and shows a file-to-RTMP pattern using the FLV muxer. Adapt that pattern to the RTMPS URL copied from YouTube and verify that the installed FFmpeg build supports the protocol and URL syntax you use. FFmpeg protocol documentation.

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.

Set a protected environment variable named YOUTUBE_DESTINATION to the complete destination expected by your current YouTube URL workflow, including the stream key. Do not put a real key in the sample or paste it into a shared terminal. The following command is an example for a 30 fps file and H.264-capable build:

ffmpeg -re -stream_loop -1 -i /srv/stream/source.mp4 
  -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k 
  -g 60 -keyint_min 60 -sc_threshold 0 -pix_fmt yuv420p 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "$YOUTUBE_DESTINATION"
  • -re paces the file at its normal playback rate instead of sending it as fast as possible.
  • -stream_loop -1 asks FFmpeg to repeat the input indefinitely. It does not make a loop seamless: picture or sound can jump at the file boundary.
  • -b:v, -maxrate, and -bufsize set the example video rate-control values. Adjust them for the output you have chosen and verify the result in YouTube’s stream preview and health information.
  • -g 60 and -keyint_min 60 set a 60-frame interval in this example. At 30 fps, that is two seconds; if the source or output frame rate differs, recalculate the interval.
  • -f flv selects the muxer used in FFmpeg’s documented RTMP example. Confirm compatibility with the RTMPS endpoint and installed build before relying on it.

Check the media before launch, including its streams and duration, with ffprobe /srv/stream/source.mp4. If the input has no audio, incompatible pixel format, variable frame rate, or a different frame rate than expected, revise the command rather than assuming the illustrative settings fit. A cloud VM has no attached camera by default, so this file-input command does not cover live capture devices. A playlist with multiple videos, transitions, or scheduled segments needs a separate design.

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.

5. Keep FFmpeg running after SSH disconnects

Use systemd to start the process at boot and restart it if it exits. This is an operational pattern, not a tested service recipe: confirm paths, environment file permissions, Ubuntu behavior, and FFmpeg options on your own instance.

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
  1. Create a root-readable environment file such as /etc/ffmpeg-youtube.env containing the destination variable. Restrict access, for example with sudo chmod 600 /etc/ffmpeg-youtube.env, and ensure it is owned by root. Avoid printing its contents into logs or support messages.
  2. Create /etc/systemd/system/youtube-stream.service with this template, replacing paths and values for your deployment:
    [Unit]
    Description=FFmpeg YouTube file stream
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    Type=simple
    EnvironmentFile=/etc/ffmpeg-youtube.env
    ExecStart=/usr/bin/ffmpeg -re -stream_loop -1 -i /srv/stream/source.mp4 -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k -g 60 -keyint_min 60 -sc_threshold 0 -pix_fmt yuv420p -c:a aac -b:a 128k -ar 44100 -f flv ${YOUTUBE_DESTINATION}
    Restart=always
    RestartSec=10
    
    [Install]
    WantedBy=multi-user.target
  3. Ask systemd to load and start the service, then inspect its status:
    sudo systemctl daemon-reload
    sudo systemctl enable --now youtube-stream.service
    sudo systemctl status youtube-stream.service
  4. Read recent output and follow new log entries while diagnosing:
    sudo journalctl -u youtube-stream.service -n 100 --no-pager
    sudo journalctl -u youtube-stream.service -f
  5. Stop the stream cleanly when needed:
    sudo systemctl stop youtube-stream.service

Systemd restart behavior can recover from a process exit, but repeated failures will still repeat. A restart policy cannot restore a missing file, repair a bad key, guarantee a healthy YouTube ingest, or verify that the broadcast is actually reaching viewers. Use the service logs and YouTube Live Control Room together.

6. Test the stream and its recovery before leaving it unattended

  1. Start with a short test. Check that YouTube Live Control Room shows a preview and healthy ingest, and that the expected picture and audio are present. YouTube advises testing before an event and monitoring stream health. YouTube streaming tips.
  2. Measure sustained outbound throughput from the server under realistic conditions, not just download speed. Confirm that the stream bitrate has the recommended headroom and that the VM has CPU capacity left while encoding.
  3. Run an extended test that includes a file loop boundary. Look for audio gaps, visible jumps, dropped frames, or service restarts.
  4. Deliberately test recovery: stop the FFmpeg process and confirm systemd restarts it; then test a server reboot and confirm the unit starts as expected. Verify the stream again in Live Control Room rather than treating a running service as proof of a healthy broadcast.
  5. Repeat relevant checks after changing resolution, frame rate, codec, VM type, source file, or network route.

YouTube says streams under 12 hours are automatically archived. This does not mean a nonstop stream will remain one uninterrupted archive or that every longer stream is archived; plan recording and archive needs separately. YouTube Live Control Room guidance.

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

Which Hetzner location is best for viewers in India?

No location can be named as best for Indian viewers without measurements of both the server’s route to YouTube ingest and the playback experience from the intended audience locations. Those are distinct paths: FFmpeg sends data from Hetzner to YouTube, and YouTube then serves the live video to viewers. A server geographically closer to India is not automatically the best ingest point or guarantee of better viewer playback. Test the ingest from the actual VM and observe playback from the locations that matter to your audience.

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.

The available Hetzner Cloud Networks guidance concerns private network configuration, not region-specific latency, YouTube route quality, server pricing, or stream uptime. Choose an instance based on measured outbound stability and adequate CPU for the chosen encoder and frame size; do not infer suitability from a region label alone.

Troubleshooting common failures

Symptom Likely check What to do
YouTube never receives the stream Destination URL, key, protocol support, network access Copy the RTMPS URL and key again from the stream’s settings, verify the installed FFmpeg build supports the protocol, and inspect FFmpeg logs for connection errors. If SSL connection errors occur, YouTube notes port 443 as a troubleshooting option; use only a destination and port supported by the current ingest workflow. YouTube encoder settings.
Stream appears but is unstable or unhealthy Outbound bitrate, fluctuations, CPU load Check upload capacity and CPU while streaming, preserve headroom, and reduce resolution or bitrate if the path or encoder cannot sustain the target.
FFmpeg exits repeatedly Source path, permissions, encoder availability, service environment Inspect systemctl status and journalctl; confirm the media file exists and is readable, the executable path is correct, the destination variable is available to the service, and the build includes the selected encoder.
Audio or video jumps at intervals Input boundaries or mismatched frame-rate assumptions Check whether the jump coincides with the file loop; seamless looping is not guaranteed. Revisit source format and the keyframe calculation, and use edited media or a separate playlist workflow if clean transitions are required.
Service is active but no useful live picture is available Service state is not the same as healthy YouTube ingest Check the Live Control Room preview and health indicators, then correlate them with FFmpeg logs and outbound measurements.

Or let it run in the cloud

If you do not want to maintain an Ubuntu VM and FFmpeg service, StreamNeo is a cloud service from Yorker Media that keeps a YouTube channel live from uploaded videos. Upload a recording or build a playlist, add your YouTube stream key once, and go live. The stream continues from the cloud, so no computer or home connection has to stay on. Each slot includes one always-on stream, 10 GB storage per slot pooled across active slots, looping and playlists, automatic recovery if YouTube drops the stream, and StreamNeo team support. Uploaded quality is preserved up to 4K 60fps at one flat price per slot; there are no quality tiers. The first day is free with no card, once per account. The monthly option is $9.99 per month. Read more at StreamNeo, or start the free first 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

  1. How to Send a YouTube Live Stream to a Premiere—and What “Premiere Playlist” Can’t DoAdmit one · BlogHow to Send a YouTube Live Stream to a Premiere-and What “Premiere Playlist” Can't DoOpened04 OCT 2026Runtime6 min
  2. How to Run a YouTube Live Playlist from a Raspberry PiAdmit one · BlogHow to Run a YouTube Live Playlist from a Raspberry PiOpened04 OCT 2026Runtime4 min
  3. How to Make a 24/7 Indian Music YouTube Stream Restart After a Server RebootAdmit one · BlogHow to Make a 24/7 Indian Music YouTube Stream Restart After a Server RebootOpened04 OCT 2026Runtime6 min
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.