On an Ubuntu Compute Engine VM you can install FFmpeg with sudo apt update and sudo apt install -y ffmpeg, then confirm it is available with ffmpeg -version. That installs the encoder; it does not configure a YouTube broadcast. To stream directly to YouTube, use a YouTube stream URL and key with an FFmpeg command, and match the output settings to YouTube’s current encoder guidance.
Install FFmpeg on the Ubuntu VM
These steps assume you already have an Ubuntu VM in Google Cloud Compute Engine and are connected to it over SSH. Run the commands in that VM’s shell—not in Cloud Shell. Cloud Shell is a separate environment and installing FFmpeg there does not install it on your VM.
-
Refresh the package index:
sudo apt update -
Install FFmpeg:
sudo apt install -y ffmpeg -
Check that the executable runs:
ffmpeg -versionThe command prints the installed version and build information. The version and available codec support depend on the Ubuntu release and package sources on that VM, so check the output rather than assuming a particular build.
Google Cloud’s Live Stream API setup guide recommends installing FFmpeg as an encoder tool. Its example belongs to a Live Stream API workflow; installing the package does not enable that API, set up project authentication or IAM, or configure Cloud Storage. Direct FFmpeg-to-YouTube streaming is a separate workflow and does not require the Live Stream API.
#1 Best Overall
Choose YouTube-compatible stream settings
YouTube’s encoder settings guidance lists RTMP and RTMPS ingestion and recommends RTMPS to encrypt the connection to Google. It lists H.264, H.265/HEVC, and AV1 video, and AAC or MP3 audio. Whether your installed FFmpeg build supports a particular encoder must be checked locally; the package name alone does not guarantee a specific codec.
- Use a supported codec and ingestion protocol. Prefer RTMPS where compatible, and select an encoder actually available in your FFmpeg build.
- Set a constant bitrate (CBR) and a two-second keyframe interval. YouTube recommends two seconds and says not to exceed four seconds. At 30 fps, two seconds corresponds to a 60-frame GOP.
- Choose bitrate for the resolution and frame rate. YouTube recommends 14 Mbps for H.264 1080p at 30 fps and 8 Mbps for H.264 720p at 30 fps. These are encoder recommendations for those modes, not a guarantee that a particular VM or network can sustain them.
- Check upstream capacity. YouTube recommends running a speed test and choosing settings in relation to available upload bandwidth. Leave room for network variation rather than treating the full measured upload rate as usable stream capacity.
- Match audio to the source. AAC and MP3 are listed audio choices. Check that the input actually contains the audio stream you intend to send.
Send a test video from FFmpeg to YouTube
First create or select a YouTube live stream and copy its RTMPS ingest URL and stream key from YouTube’s live-stream setup. Treat the key as a password: anyone with it may be able to broadcast to that stream. Do not publish it, include it in a shared script, or put it directly into a command that will be saved in shell history.
Rank #2
The following template assumes a local file named input.mp4 with 1080p, 30 fps video and audio. Replace the filename and mode as appropriate. Enter the complete RTMPS destination supplied for your stream when prompted; the input is hidden and is not part of the command line stored in shell history.
read -rsp 'Paste the complete YouTube RTMPS destination: ' YT_DEST; echo
ffmpeg -re -i input.mp4 -c:v libx264 -preset veryfast -pix_fmt yuv420p -r 30 -b:v 14M -minrate 14M -maxrate 14M -bufsize 28M -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -f flv "$YT_DEST"
unset YT_DEST
This example asks FFmpeg to read the file at its media rate (-re), encode H.264 at a constant 14 Mbps, use a 60-frame keyframe interval for 30 fps, encode audio as AAC, and send an FLV stream to the supplied destination. libx264 must be present in the installed build; if FFmpeg reports that the encoder is unavailable, check the build shown by ffmpeg -version and use a build with a YouTube-supported encoder. The example is for the stated 1080p/30 H.264 mode; do not reuse its bitrate or frame-rate settings unchanged for a different mode.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #3
Use a representative clip with motion and sound, then watch YouTube’s stream health while it ingests. YouTube recommends testing before an event and monitoring stream health. A command that starts successfully does not by itself confirm that the stream is healthy or that its content is cleared for broadcast.
Know what the install does—and does not—solve
Installing FFmpeg gives the VM command-line media tools. It does not create the VM, configure its network path, supply a YouTube stream key, establish a YouTube live broadcast, or guarantee that the VM’s CPU and connection can keep up with your chosen encoding mode. Also, Google-provided Compute Engine OS images generally include the guest environment, while imported or custom images may need separate guest-environment work; that is not an FFmpeg installation prerequisite.
Rank #4
FFmpeg’s official documentation notes that its online documentation tracks the newest revision. If a command option or encoder differs on an older Ubuntu package, use documentation matching the installed version where available and inspect the local build rather than assuming the newest online behavior.
Troubleshooting
ffmpeg: command not found: Confirm the install completed in the VM’s SSH session, not in Cloud Shell. Runsudo apt update, retrysudo apt install -y ffmpeg, then checkffmpeg -version.- “Unknown encoder” or missing
libx264: The installed build does not expose the encoder used in the example. Reviewffmpeg -versionfor its build configuration and use an FFmpeg build with a YouTube-supported encoder. - YouTube does not receive a stream: Recheck that you copied the complete RTMPS destination for the active stream, including the required key component, and that the stream key has not been reset. Keep the key private.
- Stream health is poor or the stream buffers: Compare the selected mode’s bitrate with the VM’s available upstream capacity. Test the connection, lower the resolution or frame rate, or choose a lower recommended bitrate for the intended mode; then test again while observing YouTube’s health indicator.
- Audio is missing: Check that the source file contains an audio stream and that the input is the intended file. If the source has no audio, an AAC output setting cannot create meaningful program audio.
- The stream stops when the SSH session ends: A foreground FFmpeg process is tied to the VM session and is not an always-on managed broadcast service. Use an appropriate process-management approach for your VM workflow, or choose a cloud service designed to keep an uploaded-video stream running.
- YouTube accepts the connection but raises a content concern: Verify that you have the necessary rights to the video and audio. An encoder connection does not grant permission to stream copyrighted material or determine whether a channel’s content complies with YouTube policies.
Cost and operational considerations
The apt installation commands above install the Ubuntu package; they do not state or determine the price of your Google Cloud VM. VM charges depend on the instance and its usage, so account for the VM’s continued operation and your own stream setup when deciding whether to keep this self-managed method running. The StreamNeo cloud option below is a separate service, not a Google Cloud VM price comparison.
Best Value
Or let it run in the cloud
If your goal is to keep uploaded videos looping as a YouTube live stream, StreamNeo is an alternative to managing FFmpeg on a VM. Upload a recording or build a playlist, add your YouTube stream key once, and go live; StreamNeo runs it in the cloud, so nothing has to stay on at home. Every slot streams the upload as made, up to 4K 60fps, at one price per slot with no quality tiers, and automatically recovers if YouTube drops the stream. The first day is free with no card required. Monthly pricing is $9.99 per month. It streams to YouTube and plays uploaded videos; it does not stream from a camera. Start the free day on StreamNeo.
Quick Recap
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.

