Skip to content
streamneo.
Setup Guides12 min read

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

Install and verify FFmpeg on a persistent Ubuntu Compute Engine VM, then prepare to test the separate YouTube Live encoder setup.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

To install FFmpeg for YouTube streaming, connect to your Ubuntu Compute Engine VM, refresh its package lists, and install the ffmpeg package with apt. Then verify the executable and check your media; installation alone does not configure or start a YouTube broadcast.

A Compute Engine VM is a persistent virtual machine you manage in your Google Cloud project. Cloud Shell is a separate, browser-accessible command-line environment. A command run in Cloud Shell is not thereby installed on your VM, so make sure you are connected to the intended instance before proceeding.

Confirm you are connected to the Ubuntu VM

Open an SSH session to the Ubuntu Compute Engine instance you intend to use. You can connect from the Google Cloud console or with the gcloud command-line tool; the precise steps depend on how the instance and access permissions are set up. This guide assumes you already have a VM and can log in. If you have not prepared Ubuntu for this use, the walkthrough on configuring Ubuntu for FFmpeg YouTube streaming covers broader host setup.

Once connected, check the shell prompt and identify the host before installing anything. Commands such as hostname and cat /etc/os-release can help confirm that you are on the expected machine and identify its operating system. Do not rely only on the fact that a terminal window is open: a local terminal, Cloud Shell and a VM SSH session can look similar while acting on different systems.

Cloud Shell is useful for running Google Cloud commands, but it is not a substitute for the persistent VM in this workflow. Google’s Live Stream API documentation includes an FFmpeg installation example in its own setup context; the apt commands are useful here too, but run them in the VM’s SSH session to install the package there. That API guide describes a distinct product workflow. You do not need to enable the Live Stream API simply to install FFmpeg or send an encoder stream directly to YouTube.

The VM must also be able to reach package repositories and, later, YouTube’s ingest endpoint. If a command cannot connect, first determine whether the session is on the correct host and whether the instance has the expected network access. Avoid changing firewall or project settings by guesswork; diagnose the particular connection failure and consult current Google Cloud documentation for the relevant network controls.

Update package lists and install FFmpeg

Ubuntu uses apt to manage software from configured repositories. Refreshing package metadata lets it learn what packages are available before you request FFmpeg. In the VM’s SSH session, run:

sudo apt update
sudo apt install -y ffmpeg

The first command updates package lists; it does not itself install all available system updates. The second asks Ubuntu to install the package named ffmpeg. The -y option accepts apt’s confirmation prompt, which is convenient when you are comfortable with the requested package changes. Without it, read the prompt before confirming.

Google Cloud’s Live Stream API setup guidance also uses apt to install FFmpeg as an encoder. Its example belongs to that API’s workflow, which has its own project, authentication and storage configuration. The package installation is relevant here, but those API steps are not prerequisites for direct FFmpeg-to-YouTube streaming.

Watch the installation output for errors rather than assuming that a command completed because it was entered. Apt may report that it cannot reach a repository, that a package could not be located, or that another package operation needs attention. Resolve the reported issue before moving on. Package availability and the version selected depend on the Ubuntu release and repositories configured on your particular VM; there is no single version to assume for every instance.

If you are unsure what apt plans to add or change, inspect its summary before accepting. Installing a package changes the VM’s software state, so make sure you are using the intended instance and a user with appropriate administrative permission. For a longer-running channel, note which machine you changed and keep a record of the commands used, especially if you later need to reproduce the setup on another VM.

Verify the FFmpeg executable and version

After apt finishes, ask the shell to run FFmpeg’s version command:

ffmpeg -version

A successful result displays version and build information rather than a “command not found” message. This confirms that the shell can find and launch the executable. It does not yet prove that your input file is readable, that the installed build supports every codec you may want, or that a YouTube stream will work.

If the shell cannot find ffmpeg, check that the installation completed without an error and that you are still in the same VM session. You can also locate the command with command -v ffmpeg. If it returns no path, revisit the apt output and package state rather than copying a binary from an unknown source.

Build details matter because FFmpeg is a family of command-line tools with features that can vary by package and build. The FFmpeg documentation explains the tools and notes that online documentation follows the newest revision. A distro package may differ, so use local help and the installed program’s output when a flag or codec question arises. For example, ffmpeg -h shows command help, while ffmpeg -codecs can help inspect codec support. Treat those listings as diagnostic information, not proof that YouTube will accept a complete stream.

Do not install a second FFmpeg build just because an online command uses an option you do not recognise. First check whether the option exists in your local help and whether the command’s input and output assumptions match your job. A recording, a local transcode and a live RTMP/RTMPS output are different tasks, even when all use the same executable.

Check the video and audio input

Before constructing a live command, confirm that FFmpeg can read the media you plan to use. A short test can reveal a bad file path, unsupported container, missing audio track or an unreadable file while you are still working outside the live broadcast. Use a representative sample: a devotional loop with music and vocals, for instance, should be checked for both its picture and sound rather than a silent test image alone.

Use FFmpeg to inspect a file without sending it anywhere:

ffmpeg -i /path/to/input.mp4

Replace the path with a real file on the VM. FFmpeg prints stream information and may also report that no output was specified; for this inspection step, that is expected. Look for video and audio stream entries, duration and any errors opening the file. If your source is a playlist or a directory of clips, test an individual representative item first, then separately plan how the playlist will be read and repeated. The guide to looping a YouTube live stream from a VPS deals with that ongoing playback problem rather than package installation.

An input can be valid but unsuitable for your planned output. A source with no audio will not gain meaningful programme sound merely because you specify an audio codec. A variable-frame-rate or high-resolution source can also demand more processing or bandwidth than a simpler loop. Decide what viewers need to see and hear, then choose an output mode that the VM, network path and channel can sustain.

For persistent channels, plan the loop and recovery behaviour as carefully as the initial file test. If a playlist begins again unexpectedly, the cause may be playlist or process logic rather than the FFmpeg installation. The article on a YouTube playlist that keeps starting over covers that separate failure mode. Keep your source files in a location the VM can read after you disconnect; a file available only on your laptop is not automatically available to the instance.

Gather YouTube Live encoder details

Installing FFmpeg supplies the encoder tool; you still need an active YouTube Live setup and output details. In YouTube Studio, prepare the live stream and obtain the current server URL and stream key for the encoder workflow. Treat the stream key as a credential: do not publish it in an article, screenshot, shared terminal transcript or a command-history example that others can read. If it is exposed, use YouTube’s current controls to replace or reset it.

YouTube’s encoder settings guidance lists RTMP and RTMPS as protocols and recommends RTMPS where compatible. It also lists H.264, H.265/HEVC and AV1 video, and AAC or MP3 audio for the documented workflows. These are ingestion options, not a guarantee that your installed FFmpeg build supports every option or that every combination fits your source and upload connection. Check the local build and YouTube’s current page before publishing a command.

The settings are linked. Codec, resolution and frame rate influence the bitrate you need; the selected bitrate must in turn fit the real upstream capacity of the VM’s network path. YouTube recommends testing the connection and stream before an event, not choosing a high mode by habit. A channel showing a static devotional image with music may need a different mode from a news loop with moving footage, but the actual choice still depends on source quality, desired viewing detail and available bandwidth.

Example H.264 output mode YouTube’s listed recommended bitrate Practical implication
720p at 30 fps 8 Mbps Lower resolution than 1080p, with lower recommended video bitrate in this comparison
1080p at 30 fps 14 Mbps More detail, with a higher recommended video bitrate in this comparison

These are YouTube encoder recommendations for the specified H.264 modes, not universal minimums or a promise about quality. The full table includes other codecs and modes; consult it for the output you intend to use. Remember that bitrate is not the same as the total bandwidth available to the VM: allow for connection variation and other traffic, and test the actual route rather than relying only on a plan label.

YouTube’s page also specifies constant bitrate (CBR) encoding for the listed guidance, recommends a two-second keyframe interval, and says not to exceed four seconds. Read the current encoder page when assembling your command, since requirements and recommendations can change. Set parameters deliberately; merely adding a stream URL and key to a command does not select a suitable codec, frame rate, bitrate or keyframe behaviour.

Build and test the separate stream workflow

Once the file, output mode and YouTube details are known, you can construct an FFmpeg command for the actual source. This article does not provide a ready-to-run command with guessed settings because the right inputs, codec support, bitrate and URL depend on your case. In particular, do not paste a real key into a public guide or copy a command that assumes a different file, frame rate or audio layout.

Keep the server address and key separate in your notes where possible, and ensure the final output URL is assembled in a way that does not expose the credential to other users on the machine. A placeholder in an example is not a credential and will not authenticate. Review the shell command before execution: FFmpeg options are order-sensitive, and options intended for an input can behave differently when placed after the output declaration.

Start with a short, controlled test using the actual media and the mode you plan to keep. YouTube advises testing before an event and monitoring stream health. Start the broadcast through the workflow you have configured, then inspect YouTube Studio’s preview and health indicators. Confirm picture, audio, timing and any warning about dropped frames or unstable delivery before leaving the stream unattended.

A clean ffmpeg -version result and a successful local file inspection are necessary checks, not sufficient ones. If the preview is black, revisit the input selection and video mapping; if it is silent, check for an audio stream and its mapping. If the ingest does not connect, check the current URL, key, protocol and outbound connectivity. If the picture arrives but health warnings appear, compare actual upstream capacity with the selected bitrate and reduce the output demand or choose a more appropriate mode.

For an always-on channel, a successful short test also does not prove that the process will keep running through a VM disconnect, reboot or later network interruption. You need an operating plan for starting, monitoring and recovering the encoder, and you should verify it rather than assuming the installation handles it. If keeping an FFmpeg process alive on your own VM becomes the maintenance burden, StreamNeo can remove that particular burden by turning an uploaded video into a YouTube live stream that runs without your computer left on.

Keep the installation distinct from channel operations

FFmpeg is a command-line program. It does not create a YouTube channel, enable live streaming on your account, choose a source file, provision a Compute Engine VM or supervise your channel’s schedule. Treat installation as one step in a chain: the VM must be reachable, the file must be present and readable, the encoder command must match the source and YouTube’s current requirements, and the broadcast must be checked in Studio.

That separation makes troubleshooting more practical. If ffmpeg -version fails, focus on package installation and the current host. If the version works but ffmpeg -i cannot read a file, focus on the path, file permissions or media. If local inspection works but Studio shows no preview, examine the stream command, credentials, protocol and network path. If a preview works but the channel later stops, investigate process supervision and VM lifecycle rather than reinstalling FFmpeg without evidence.

A VM is persistent compared with a temporary shell session, but it is still a machine that can be stopped, restarted or misconfigured. Check the instance’s lifecycle and access rules in Google Cloud, and make sure source media and any scripts are stored where they remain available. The right arrangement depends on whether you need a live, continually changing programme or are broadcasting a fixed uploaded video; the VPS internet radio walkthrough discusses the former kind of always-on source.

Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.

FAQ

Is Cloud Shell the same as my Ubuntu Compute Engine VM?

No. Cloud Shell is a separate Google Cloud command-line environment; your Compute Engine VM is the persistent instance you connect to over SSH. Run the installation commands in the VM session if you want FFmpeg installed on that VM.

Does installing FFmpeg start a YouTube live stream?

No. Installation makes the command-line tool available, and verification confirms that it can run. You still need a prepared YouTube Live workflow, an input, a suitable encoder command and a test in YouTube Studio.

Which FFmpeg version will apt install?

It depends on the Ubuntu release and configured package repositories on your VM. Check ffmpeg -version after installation and consult local help for the options and codec support available in that build.

Do I need Google’s Live Stream API to stream directly to YouTube?

Not simply to install FFmpeg or send an encoder stream to YouTube. Google’s Live Stream API documentation describes a separate Google Cloud workflow; for direct streaming, follow YouTube’s current encoder instructions and protect your stream key.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Setup Guides guides ↗ · All topics ↗