Log inSign up

Getting FFmpeg onto a server and putting it to work

On Ubuntu and Debian, sudo apt install ffmpeg is all it takes. On Rocky Linux and AlmaLinux 9, enable EPEL, CRB and RPM Fusion Free first, then sudo dnf install ffmpeg. When you need a newer release than your distribution ships, drop a static build into /usr/local/bin. Confirm with ffmpeg -version and a short test encode.

Topic: Go, Ruby, Java and other runtimes · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

Should you use the distro package or a static build?

Use the distribution package unless a feature you need is missing from its version. Packages get security fixes through normal updates and link against system libraries, which keeps them small. Ubuntu 24.04 ships FFmpeg 6.1, Ubuntu 22.04 ships 4.4, Debian 12 ships 5.1 and Debian 13 ships 7.1; RPM Fusion keeps Rocky and Alma 9 on a recent release.

A static build is a single self-contained binary with a large set of codecs compiled in. It is handy for getting the newest encoder options on an older LTS release, or for pinning one exact FFmpeg version for a pipeline. The trade-off is that nothing updates it for you. You can keep both: the package in /usr/bin and the static binary in /usr/local/bin, which comes first on the default PATH.

How do you install FFmpeg on Ubuntu or Debian?

The package is in the main archive on Debian and in universe on Ubuntu, which is enabled on standard images.

sudo apt update
apt policy ffmpeg
sudo apt install -y ffmpeg
ffmpeg -version | head -n1
ffprobe -version | head -n1

The package pulls in ffprobe as well, which you will use to inspect files. It includes the common encoders such as libx264, libx265, libvpx, libopus, libmp3lame and libdav1d for AV1 decoding.

How do you install FFmpeg on Rocky Linux or AlmaLinux 9?

The RHEL family leaves patent-encumbered codecs out of its own repositories, so the full FFmpeg comes from RPM Fusion Free, which builds on top of EPEL and the CRB repository.

sudo dnf install -y epel-release dnf-plugins-core
sudo dnf config-manager --set-enabled crb
sudo dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm
sudo dnf install -y ffmpeg
ffmpeg -version | head -n1

If dnf reports a conflict with an ffmpeg-free package from EPEL, swap it with sudo dnf swap ffmpeg-free ffmpeg --allowerasing. More on these repositories is in the package managers guide.

How do you install a static build?

Download the release archive linked from the FFmpeg download page for Linux static builds, verify it, and copy the two binaries into place. The commands below use the amd64 release build that matches every BitcoinVPS plan.

mkdir -p ~/ffmpeg-static && cd ~/ffmpeg-static
curl -fsSLO https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
curl -fsSLO https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz.md5
md5sum -c ffmpeg-release-amd64-static.tar.xz.md5
tar -xf ffmpeg-release-amd64-static.tar.xz
sudo install -m 0755 ffmpeg-*-amd64-static/ffmpeg ffmpeg-*-amd64-static/ffprobe /usr/local/bin/
hash -r
which ffmpeg
ffmpeg -version | head -n1

To upgrade, repeat the download and install steps. Static binaries cannot use the system resolver plugins, so if FFmpeg fails to resolve host names when reading network URLs, installing nscd usually solves it.

How do you check which codecs are available?

List encoders and filter for the ones you plan to use; a missing line means that build cannot produce the format.

ffmpeg -hide_banner -encoders | grep -E 'libx264|libx265|libsvtav1|libopus|aac'
ffmpeg -hide_banner -decoders | grep -i av1
ffmpeg -hide_banner -filters | grep -E 'scale|drawtext'

Then prove the whole chain with a synthetic five-second clip, which needs no input file:

ffmpeg -hide_banner -f lavfi -i testsrc2=duration=5:size=1280x720:rate=30 \
  -f lavfi -i sine=frequency=440:duration=5 \
  -c:v libx264 -preset veryfast -pix_fmt yuv420p -c:a aac test.mp4
ffprobe -hide_banner test.mp4

ffprobe should report an H.264 video stream at 1280x720 and an AAC audio stream, five seconds long.

Which everyday commands are worth knowing?

A handful of patterns cover most server tasks. Each writes a new file and leaves the source untouched.

# Web-friendly MP4: H.264 + AAC, metadata at the start for fast playback
ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k -movflags +faststart output.mp4

# Copy streams into a new container without re-encoding
ffmpeg -i input.mkv -c copy output.mp4

# Extract audio as MP3
ffmpeg -i talk.mp4 -vn -c:a libmp3lame -q:a 2 talk.mp3

# Thumbnail at 10 seconds, 640 px wide
ffmpeg -ss 10 -i input.mp4 -frames:v 1 -vf scale=640:-2 thumb.jpg

# Cut a clip from 1:00 to 1:30 without re-encoding
ffmpeg -ss 00:01:00 -to 00:01:30 -i input.mp4 -c copy clip.mp4

# HLS segments for streaming from a web server
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac -f hls -hls_time 6 -hls_playlist_type vod stream.m3u8

Lower -crf means higher quality and larger files; slower presets give smaller files at the same quality for more CPU time. Live streaming with an RTMP ingest is covered in streaming with Nginx RTMP.

How do you run long encodes without hurting other services?

Encoding uses every vCPU it can get. On a shared vCPU server, run batch jobs at low priority, limit threads, and keep them alive after you log out.

# Low CPU and disk priority
nice -n 15 ionice -c3 ffmpeg -i big.mov -c:v libx264 -threads 2 -crf 22 big.mp4

# Hard CPU cap with a transient systemd scope
sudo systemd-run --scope -p CPUQuota=150% -p MemoryMax=1G \
  ffmpeg -i big.mov -c:v libx264 -crf 22 big.mp4

Start long runs inside tmux so a dropped SSH connection does not kill them. For a folder of files, a short loop works:

for f in ~/incoming/*.mov; do
  nice -n 15 ffmpeg -n -i "$f" -c:v libx264 -crf 23 -c:a aac -movflags +faststart "${f%.mov}.mp4"
done

The -n flag skips files that already exist, so the loop can be re-run safely.

How do you troubleshoot FFmpeg errors?

Read the last few lines of output first; FFmpeg states the real reason right before it exits.

  • Unknown encoder: the build lacks that codec; check -encoders or use the static build.
  • height not divisible by 2: use scale=640:-2 instead of -1.
  • Killed: the kernel ran out of memory; high-resolution filters and HEVC encodes need more RAM, so add swap or lower -threads.
  • Wrong binary runs: type -a ffmpeg lists every copy on PATH in order.
  • Disk full mid-encode: check free space first with df -h.

Add -loglevel warning -stats in scripts for quieter logs that still show progress.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4occasional conversions and thumbnails2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A8-16steady batch transcoding8 vCPU, 16 GB RAM, 350 GB NVMe$57.60/mo$57.60 for 1 month

Questions about Install FFmpeg

Can FFmpeg use a GPU on a BitcoinVPS server?

No. The plans have shared vCPUs and no GPU, so encoding runs in software with libx264, libx265 or SVT-AV1. Use faster presets when time matters.

Which version does my distribution ship?

Run apt policy ffmpeg on Ubuntu or Debian, or dnf info ffmpeg on Rocky and Alma after enabling RPM Fusion.

Is a static build safe to use?

It is built from FFmpeg source, and you should verify the checksum after download. Remember to update it yourself, since apt or dnf will not.

How do I remove the static build?

Delete /usr/local/bin/ffmpeg and /usr/local/bin/ffprobe, then run hash -r. The packaged version in /usr/bin takes over again.

How much CPU does transcoding need?

Enough that a single 1080p H.264 encode can keep two vCPUs busy for longer than the clip lasts with slow presets. Batch jobs fit better on plans with more vCPUs.