Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon 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 NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › FFmpeg

How to Run a YouTube 24/7 Stream on an Ubuntu Azure VM with FFmpeg

By Freedom251 Team · · 7 min read

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

You can run a prerecorded YouTube Live stream from an Ubuntu virtual machine on Azure by installing FFmpeg, sending a real-time output to the RTMPS address and stream key shown in YouTube Live Control Room, and supervising FFmpeg with systemd. First test the stream in the foreground, then add looping and process recovery. A VM and automatic restarts do not guarantee uninterrupted streaming: network, host, input-file, and YouTube ingest problems still need monitoring.

What you need before starting

  • An Azure account and an Ubuntu Linux VM with enough CPU capacity for your chosen output and encoding method.
  • Media you have permission to stream, stored where the VM can read it.
  • A YouTube channel eligible to use Live streaming, plus a stream configured in YouTube Live Control Room.
  • An FFmpeg build that supports the codecs you need and can connect to the RTMPS endpoint issued for your stream.

Exact VM size, region, cost, network capacity, encoding settings, and account eligibility vary. Choose them for your deployment rather than relying on a universal preset. This workflow pushes an outbound stream to YouTube; it does not require opening a public inbound streaming port on the VM.

As an Amazon Associate I earn from qualifying purchases.

1. Create an Ubuntu VM in Azure

Use Microsoft’s Linux VM quickstart to create a virtual machine in the Azure portal. Select an Ubuntu image and a region that suit your needs. Size the VM according to whether FFmpeg will encode on the CPU, and the resolution, frame rate, and codec you intend to send. The workflow does not establish a recommended Azure SKU or current VM price; check the Azure portal and current pricing for your region and configuration.

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

Make sure the VM has outbound network access to YouTube’s ingest endpoint. You do not need to expose an inbound port merely to push video from FFmpeg to YouTube. Once the VM is available, connect to it using your chosen secure administration method.

2. Install FFmpeg and check its capabilities

Install FFmpeg from a trusted package source appropriate for your Ubuntu version. Then inspect the installed version and available encoders and protocols before building the stream command:

ffmpeg -version
ffmpeg -protocols
ffmpeg -encoders

FFmpeg documents RTMP-family protocols, but RTMPS support can depend on how the package was built and whether its dependencies are present. The FFmpeg protocol documentation describes RTMPS and gives a file-to-server streaming example using real-time input, an input file, FLV output, and an RTMP URL. Do not assume that an rtmps:// destination will work until this particular installation has connected successfully.

3. Prepare and test your media

Check files and permissions

Put the source file somewhere the FFmpeg process can read it. Check that it decodes and contains the audio and video streams you expect; for example, inspect it with ffprobe if that tool is installed. Choose source media you have the rights to stream. This guide does not determine whether a particular use is legally permitted or whether content meets YouTube’s policies.

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

Choose encoding settings for the source

There is no universal bitrate, resolution, frame-rate, or encoder preset established for every Azure VM and source file. Set output parameters for your intended quality and the machine’s capacity, and consult YouTube’s current encoder guidance in Live Control Room. If encoding on the VM, confirm that the selected FFmpeg video and audio encoders appear in its encoder list. Avoid copying a preset without checking its CPU demands and the resulting stream health.

4. Get the current YouTube RTMPS destination

  1. Open YouTube Studio and go to Live Control Room. Create or schedule the live stream you intend to use.
  2. Reveal the stream settings and copy the RTMPS server URL and stream key issued for that stream.
  3. Use the current values displayed there. The URL and key are stream-specific configuration, not values to guess or reuse from an example.

YouTube describes RTMPS as “a secure extension to the popular RTMP streaming video protocol.” See YouTube Help: Encrypt your stream using RTMPS for its current instructions. The YouTube API also represents RTMPS ingestion addresses and stream names as fields in stream configuration; see the LiveStreams resource. Depending on the encoder, the stream name/key may be appended to the server URL or entered separately. Follow the format expected by your FFmpeg command and the exact values YouTube currently provides.

Treat the stream key as a credential. Do not put a real key in a public example, source control, screenshots, world-readable files, or logs. If it is exposed, rotate it in Live Control Room and update the service configuration.

5. Run a short foreground test

Before enabling an infinite loop or creating a service, run FFmpeg interactively and confirm that YouTube receives the stream. The following illustrates the command shape only; it is not a tested, universal encoding recipe. Replace the input path and destination with your own values, and supply the current URL/key in the form supported by your FFmpeg build:

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.
ffmpeg -re -i /path/to/video.mp4 -c:v libx264 -c:a aac -f flv "$INGEST_URL"

Do not paste a live key into a command that will be saved in shell history. Prefer a suitably protected configuration or environment mechanism, with file permissions restricted to the service account. Check FFmpeg’s output for connection, input, encoding, and muxing errors. In YouTube Studio, confirm that the stream appears and inspect its stream-health indicator before proceeding.

6. Loop a file or rotate a playlist

Loop one file

After the finite test works, a common single-file loop command is:

ffmpeg -re -stream_loop -1 -i /path/to/video.mp4 -c:v libx264 -c:a aac -f flv "$INGEST_URL"

-re reads the file at its native rate rather than sending it as fast as possible, while -stream_loop -1 requests indefinite input looping. Confirm those options and the chosen codecs are supported by the installed version, and adapt output settings to your source and target. A command that loops successfully locally can still fail to connect to YouTube or produce a healthy ingest.

Use several files

If you need to rotate multiple recordings, use an FFmpeg playlist-based workflow rather than repeatedly editing a single-file command. Playlist formats and options have version-specific details, so validate the syntax against the installed FFmpeg documentation and test transitions in a short session before leaving it unattended. Confirm that each file is readable, has compatible streams, and is authorized for broadcast.

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

7. Supervise FFmpeg with systemd

A systemd service can start FFmpeg at boot and restart it after a process failure. Run it as a dedicated unprivileged Linux user, grant that account read access only to the required media and protected configuration, and avoid embedding the stream key in a broadly readable unit file. Configure the service to start after network availability as appropriate for your system, and set restart behavior such as Restart=on-failure. The exact unit depends on how you securely provide the destination and on your chosen command; test it under the service account, not only in your login shell.

Best Value
DARGO Mini Server – Plug & Play Home Host with No Monthly Fees. 16GB RAM, 1TB SSD
  • TRUE PLUG-AND-PLAY HOME SERVER: Forget complex VPS setups or command lines. Simply connect power and Ethernet to start hosting immediately with zero technical skills required. This managed, all-in-one appliance is the easiest way to run blogs (compatible with WordPress), private applications, and bots directly from home using your own domain.
  • NO MONTHLY SUBSCRIPTION FEES: Stop renting server space. Enjoy a one-time hardware purchase model with absolutely no recurring hosting fees for typical usage. The system includes a generous monthly traffic allowance that covers the needs of almost all personal and small business websites, allowing the device to pay for itself quickly.
  • INSTANT ONE-CLICK APP LIBRARY: Instantly deploy over 50 curated open-source applications without hassle. The diverse ecosystem includes essential tools, compatible with WordPress, Ghost, Nextcloud (for private cloud storage), Joomla, and OpenClaw. Perfect for content management, e-commerce, private email, and business tools.
  • INCLUDES FREE SSL & ENTERPRISE SECURITY: Get professional performance and safety without the extra costs. Seamlessly integrate your existing custom domain or utilize the included free subdomain. Your sites are automatically secured with free SSL certificates, built-in DDoS protection, and global CDN acceleration.
  • TOTAL DATA PRIVACY & OWNERSHIP: Keep your digital assets secure on your own local hardware, not on third-party "big tech" servers. Designed for privacy-conscious individuals, creators, and small businesses seeking platform independence. Includes an intuitive web management portal for complete peace of mind.

After saving or changing a unit, reload systemd’s configuration, start the service, and check its state and logs:

sudo systemctl daemon-reload
sudo systemctl enable --now youtube-stream.service
sudo systemctl status youtube-stream.service
sudo journalctl -u youtube-stream.service -f

Use your actual unit name if it differs. Review the journal for FFmpeg errors and confirm the service is making progress. A restart policy addresses some process exits; it does not diagnose every failed connection, stalled input, VM outage, or remote ingest problem.

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

8. Monitor both FFmpeg and YouTube

A running systemd unit is not proof that viewers are receiving a healthy stream. Watch FFmpeg’s journal and check YouTube’s Live Control Room stream-health status and configuration issues. The YouTube LiveStreams API documentation describes active/inactive statuses, health values including good, ok, bad, and noData, and configuration issues. Use Studio as the operational view for your stream, and investigate any health warning there rather than relying on process status alone.

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

Test recovery deliberately before calling the setup unattended: verify what happens after an FFmpeg exit, an unavailable input file, and a temporary network interruption. Systemd can relaunch a process after an exit, but a persistent network or ingest fault may cause repeated failures or leave the stream unhealthy. No uptime guarantee follows from process supervision.

RTMP, RTMPS, and connection troubleshooting

Situation What to check Next step
Connection fails using an RTMPS URL The installed FFmpeg build may lack the required RTMPS support; a URL alone does not establish compatibility. Inspect the FFmpeg build/protocols and test the exact current endpoint from Live Control Room. Check the installed package’s build capabilities.
SSL or TLS error Confirm that the server URL and protocol match the values YouTube issued for this stream. YouTube Help says to use the RTMPS URL from Live Control Room and, if an SSL error persists, try port 443. Follow the current guidance at YouTube’s RTMPS help page.
YouTube does not show an incoming stream Check for a mistyped or stale URL/key, an incorrect combined-versus-separate key format, or an outbound connectivity issue. Copy the current stream settings again from Live Control Room, verify the FFmpeg destination format, and examine the FFmpeg journal.
FFmpeg runs but stream health is bad or noData Process activity and YouTube ingest health are separate signals; the source may be invalid or the outgoing configuration may have an issue. Inspect FFmpeg logs, the source’s audio/video streams, and YouTube’s health/configuration details in Studio.
Service repeatedly restarts The process may be exiting because of an input, codec, permission, or connection error. Use journalctl to identify the error before changing the restart policy. Repeated restarts will not repair a persistent underlying fault.

Or let it run in the cloud

If you want a prerecorded YouTube stream without operating an Ubuntu VM and FFmpeg service, StreamNeo runs uploaded videos from the cloud: upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay powered on at home. It streams your upload as made, up to 4K 60fps, at one price per slot; it can automatically recover if YouTube drops the stream. The first day is free with no card. Monthly billing is $9.99 per month. This is for YouTube streams from uploaded videos, not camera broadcasting. Start your free 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.

FFmpegMicrosoft AzureRTMPSsystemdUbuntuYouTube Live

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.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.