sudo apt install ffmpeg. On AlmaLinux and Rocky Linux, FFmpeg is not in the default repositories: enable EPEL, the CRB repository (PowerTools on version 8) and RPM Fusion, then run sudo dnf install ffmpeg. Check the result with ffmpeg -version. FFmpeg needs root access, so install it on a VPS or dedicated server, not on shared hosting.What FFmpeg is used for on a server
FFmpeg is a command-line toolkit that reads, converts and processes almost any audio and video format. On a server it usually runs behind an application rather than by hand. Common jobs include:
- converting uploaded videos to a web-friendly format (H.264 MP4 or WebM),
- creating thumbnails and preview images from videos,
- extracting or converting audio,
- resizing and compressing media to save bandwidth,
- packaging video for streaming, for example as HLS segments.
Video processing is CPU-heavy. A single high-resolution conversion can keep several cores busy for minutes, so plan the server size around how much media you process.
Before you start
- ✓ Root or sudo access to a VPS or dedicated server.
- ✓ A supported Linux release. Check yours with
cat /etc/os-release. - ✓ Enough disk space for the source files and the converted output.
- ✓ A test file to confirm the install works.
Install FFmpeg on AlmaLinux and Rocky Linux 9
FFmpeg comes from RPM Fusion, which depends on EPEL and on 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-devel
ffmpeg -version
Install FFmpeg on AlmaLinux and Rocky Linux 8
Version 8 uses the PowerTools repository instead of CRB.
sudo dnf install -y epel-release dnf-plugins-core
sudo dnf config-manager --set-enabled powertools
sudo dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm
sudo dnf install -y ffmpeg ffmpeg-devel
ffmpeg -version
You only need ffmpeg-devel if you compile software against the FFmpeg libraries. To run FFmpeg, the ffmpeg package is enough.
Install FFmpeg on Debian 12 and 13
sudo apt update
sudo apt install -y ffmpeg
ffmpeg -version
Install FFmpeg on Ubuntu 22.04 and 24.04
sudo apt update
sudo apt install -y ffmpeg
ffmpeg -version
The Debian and Ubuntu packages are in the main repositories, so no extra repository is needed.
Check that FFmpeg works
# Version and build options
ffmpeg -version
# Is the H.264 encoder available?
ffmpeg -hide_banner -encoders | grep -i 264
# Quick test: convert a file and check the output
ffmpeg -i input.mov -c:v libx264 -c:a aac test.mp4
Everyday FFmpeg commands
| Task | Command |
|---|---|
| Convert to a web-friendly MP4 | ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4 |
| Resize to 1280 px wide | ffmpeg -i input.mp4 -vf scale=1280:-2 output.mp4 |
| Extract the audio as MP3 | ffmpeg -i input.mp4 -vn -q:a 2 output.mp3 |
| Trim without re-encoding | ffmpeg -ss 00:00:10 -to 00:00:40 -i input.mp4 -c copy clip.mp4 |
| Make a thumbnail at 5 seconds | ffmpeg -ss 00:00:05 -i input.mp4 -frames:v 1 thumb.jpg |
| List the codecs FFmpeg supports | ffmpeg -codecs |
In the conversion command, -crf sets the quality: lower numbers give better quality and larger files, and 23 is a common default. -preset trades speed for file size: slow makes smaller files but takes longer.
Which video codec to use
| Codec | FFmpeg encoder | When to use it |
|---|---|---|
| H.264 | libx264 |
The safest choice for the web. It plays in almost every browser and device. |
| H.265 (HEVC) | libx265 |
Smaller files at the same quality, but browser support is limited. |
| VP9 | libvpx-vp9 |
Open format used in WebM files, well supported in Chrome and Firefox. |
| AV1 | libaom-av1 or libsvtav1 |
The smallest files, but encoding is slow on a CPU. |
If you are not sure, use H.264 for the main file. Add other formats only when you need the smaller size.
Convert a whole folder
This loop converts every MOV file in the current folder to MP4 and keeps the original files.
for f in *.mov; do
ffmpeg -n -i "$f" -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k "${f%.mov}.mp4"
done
The -n option skips files that were already converted, so you can safely run the loop again.
Run FFmpeg safely on a production server
- Run jobs one at a time. Use a queue in your application instead of starting a conversion for every upload at once.
- Lower the priority. Start conversions with
nice -n 10so the website keeps its share of the CPU. - Limit threads with
-threadswhen the server also serves visitors. - Clean up temporary files. Failed jobs can leave large partial files behind, so remove old files from your work folder on a schedule.
- Run as a normal user, not as root, and only on files your application controls.
GPU hardware encoding
On a server with an NVIDIA GPU, FFmpeg can encode with NVENC, which is much faster than CPU encoding for H.264 and H.265. This needs the NVIDIA driver and an FFmpeg build with NVENC support. Check whether your build has it:
ffmpeg -hide_banner -encoders | grep -i nvenc
# If listed, encode on the GPU
ffmpeg -i input.mp4 -c:v h264_nvenc -preset p5 -c:a copy output.mp4
If nothing is listed, the build does not include NVENC. GPU encoding suits services that process a lot of video, such as streaming platforms and media libraries.
Troubleshooting
| Message or problem | Cause | Fix |
|---|---|---|
No match for argument: ffmpeg |
RPM Fusion, EPEL or CRB/PowerTools is not enabled | Repeat the repository steps for your version, then run the install again. |
Unknown encoder 'libx264' |
The FFmpeg build does not include x264 | Install FFmpeg from RPM Fusion or the Debian/Ubuntu repositories, which include it. |
| Server becomes slow during conversions | FFmpeg uses all available CPU cores | Limit threads with -threads 2, or run jobs with nice -n 10 so the website stays responsive. |
ffmpeg: command not found |
The install did not finish, or the binary is not on the path | Run the install command again and check its output for errors. |
Keep FFmpeg updated
FFmpeg reads untrusted files, so security fixes matter. Update it with the rest of the system: sudo dnf upgrade or sudo apt update && sudo apt upgrade. Avoid copying random static binaries from the internet, because they do not receive updates.
For other software on the same server, see our guides to installing MongoDB on a cPanel server and upgrading to Debian 13.
Need help with this?
Processing video at scale? Our Cloud VPS and dedicated servers give you root access and the CPU headroom FFmpeg needs.
Frequently asked questions
Can I install FFmpeg on shared hosting?
No. Installing FFmpeg needs root access, which shared hosting does not give. Use a VPS or a dedicated server.
Do I need ffmpeg-devel?
Only if you compile software against the FFmpeg libraries. To run FFmpeg commands, the ffmpeg package is enough.
Why is FFmpeg not in the default AlmaLinux or Rocky Linux repositories?
Some of the codecs FFmpeg includes are not shipped in the base repositories. RPM Fusion provides the full package, and it needs EPEL and the CRB (or PowerTools) repository.
How much CPU does FFmpeg need?
It depends on the resolution and the codec. Converting high-resolution video is CPU-heavy and can use every core, so size the server for your workload and limit threads if the server also runs a website.
Related guides
