Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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
Mountain View desk5 min

How to Install FFmpeg on an Ubuntu Google Cloud VM for YouTube Streaming

Install FFmpeg on an existing Ubuntu Google Cloud VM, verify the command, and connect it to YouTube Live's codec, bitrate, keyframe, and RTMPS guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On an existing Ubuntu Compute Engine VM, connect over SSH, run sudo apt update and sudo apt install -y ffmpeg, then confirm the installation with ffmpeg -version. That installs FFmpeg; it does not by itself configure a YouTube stream. For direct streaming, you still need a valid YouTube stream key and an FFmpeg command using compatible video, audio, bitrate, and keyframe settings.

Install FFmpeg on the Ubuntu VM

These steps assume you already have an Ubuntu virtual machine on Google Cloud Compute Engine and can connect to it using SSH. Run the commands in the VM’s shell, not in Cloud Shell: Cloud Shell is a separate environment and is not the persistent VM.

As an Amazon Associate I earn from qualifying purchases.

  1. Connect to the VM over SSH. Use the SSH option in the Google Cloud console or your existing gcloud workflow. Check that the shell prompt belongs to the Ubuntu VM before installing packages.
  2. Refresh the package index: sudo apt update
  3. Install FFmpeg: sudo apt install -y ffmpeg
  4. Verify the executable: ffmpeg -version

Google Cloud’s Live Stream API setup guide also recommends installing FFmpeg with sudo apt install ffmpeg for its encoder workflow: Google Cloud’s Live Stream API setup guidance. The -y option in the command above simply accepts apt’s confirmation prompt.

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

Check the version and build on your VM

The version and enabled features depend on the Ubuntu release and package repositories available to that VM. Check the output of ffmpeg -version rather than assuming a particular version or codec is present. FFmpeg notes that its online documentation tracks the newest revision, so it may not exactly match an older distribution package; consult documentation installed with your local package when needed: FFmpeg documentation.

Know which Google Cloud workflow you are using

The Google Cloud page that supplies the apt installation command is for the Google Cloud Live Stream API. That API workflow has its own project setup, API enablement, authentication, IAM, and Cloud Storage requirements. Installing FFmpeg does not complete those steps.

Sending a stream directly from FFmpeg to YouTube is a separate workflow. You do not need to enable the Google Cloud Live Stream API just to install FFmpeg or send a compatible stream to YouTube. For direct YouTube delivery, use YouTube’s current encoder guidance and the stream URL and key provided by YouTube Studio.

Prepare YouTube Live before building a command

  1. Set up the live stream in YouTube Studio. Obtain the current server URL and stream key from YouTube’s live-stream setup. Do not publish the key or paste a real key into a shared command, script, or support message; it is a credential that lets someone send video to your stream.
  2. Choose an output mode supported by your source and FFmpeg build. YouTube’s encoder guidance lists H.264, H.265/HEVC, and AV1 video, and AAC or MP3 audio for the documented workflows. What you can encode depends on the FFmpeg build installed on the VM.
  3. Choose resolution, frame rate, and bitrate together. YouTube’s recommended H.264 settings include 14 Mbps for 1080p at 30 fps and 8 Mbps for 720p at 30 fps. These are recommendations for those specific modes, not universal bitrates; consult YouTube’s full, current settings table for other codecs, resolutions, and frame rates.
  4. Set constant bitrate and keyframes. YouTube lists CBR and recommends a two-second keyframe interval, with an interval no longer than four seconds.
  5. Prefer RTMPS when compatible. YouTube lists RTMP and RTMPS and recommends RTMPS, which encrypts the stream in transit to Google’s servers.
  6. Check upstream capacity and test. Run a speed test on the VM’s actual upload path and leave headroom rather than choosing an encoder bitrate at the connection’s limit. Send representative moving video and audio before relying on the stream, then monitor YouTube’s stream health. See YouTube’s encoder settings, bitrate, and resolution guidance.

Build the FFmpeg command for your media

There is no single safe, complete command for every input: the input type, desired output mode, installed encoders, and YouTube server URL all matter. Start with the source file and the settings selected above. For a file-based input, the command has this general shape:

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

ffmpeg -re -i "input.mp4" -c:v libx264 -b:v 8M -maxrate 8M -bufsize 16M -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -b:a 128k -ar 44100 -f flv "rtmps://YOUR_YOUTUBE_INGEST_URL/YOUR_STREAM_KEY"

This is an illustrative H.264, 720p-at-30-fps-style starting point, not a guaranteed fit for every source or current ingest URL. The video bitrate shown corresponds to YouTube’s recommendation for H.264 at 720p/30 fps; the example’s other encoder values are command choices, not a claim that YouTube requires those exact audio settings or buffers. Adjust the output resolution explicitly if the input does not already match your target, and confirm the installed FFmpeg build has the encoder you select. Replace the URL and key with the current values from YouTube Studio. Keep the key private; avoid saving it in shell history or in a script with broad access.

For a different target mode, change the frame rate, keyframe interval, resolution, and bitrate as a set. A two-second keyframe interval corresponds to a GOP of 60 frames at 30 fps or 120 frames at 60 fps. Use YouTube’s current table for the target codec and mode, and ensure the VM can encode at that rate without falling behind.

Common installation and streaming problems

  • ffmpeg: command not found: Confirm the package installation completed in the VM, not a different shell. Run sudo apt update and sudo apt install -y ffmpeg again, then open a fresh shell and retry ffmpeg -version.
  • Apt cannot locate the package or cannot reach repositories: Check that the VM has working access to its configured Ubuntu package repositories and that sudo apt update completes successfully. Package availability can vary by Ubuntu release and configured repositories.
  • FFmpeg rejects an encoder name: Inspect ffmpeg -encoders and ffmpeg -version. The available encoders depend on the installed package build; select one that is actually present rather than assuming every codec option is enabled.
  • YouTube does not accept the stream: Recheck the current server URL and stream key in YouTube Studio, the chosen protocol, and the codec settings. Treat the key as a credential and regenerate it in YouTube if it may have been exposed.
  • Stream health reports unstable delivery: Compare the chosen bitrate with measured upstream capacity, lower the target mode or bitrate if necessary, and test again. YouTube recommends monitoring stream health rather than relying only on the encoder’s local status.
  • The stream connects but playback is wrong or absent: Test with a short, representative source that includes both motion and audio. Check that the selected input, audio stream, output resolution, and frame rate match your intent.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or let it run in the cloud

If the goal is a 24/7 YouTube channel playing uploaded videos, you can use StreamNeo instead of maintaining an FFmpeg process on the VM. Upload a recording or build a playlist, add your YouTube stream key, and go live; StreamNeo loops the uploaded video from its cloud service, so your computer and home connection do not have to stay on. It does not stream from a camera.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Nothing has to stay powered on at home.
  • One flat price per slot for any uploaded quality up to 4K 60fps, without re-encoding or quality tiers.
  • Automatic recovery if YouTube drops the stream.
  • The first day is free with no card; one free day is available per account.
  • Monthly: $9.99 per month.

See StreamNeo for details, 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 *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.