You run an ordinary FFmpeg command and get Unknown encoder 'libx264' instead of a video. The command is fine. Your FFmpeg build was compiled without the libx264 library.

FFmpeg is modular. External encoders such as libx264 (the most popular H.264 encoder) are included only if the build was configured with them. A minimal build does not have it, however correct your command is.

Why This Happens

libx264 is an external library, not part of FFmpeg’s own source code. Whoever compiled your FFmpeg had to enable it (with --enable-libx264 and the matching license flag). Many minimal builds leave it out to avoid the GPL license terms that come with libx264, for example slim Docker images and some pre-built archives.

The message means exactly what it says: your build has no encoder named libx264. Changing the spelling or adding an option will not help. You need a build that includes the encoder.

Step 1: Confirm What Your Build Has

Before installing anything, confirm that libx264 is missing. -encoders lists every encoder compiled into your FFmpeg. It needs no input file and is safe to run anywhere.

ffmpeg -encoders

Search the output for libx264. A full build shows a line like this:

 V....D libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)

If the line is missing, your build does not have the encoder, and that is the cause. The letters at the start come from the legend ffmpeg prints above the list (V marks a video encoder, and D means it supports direct rendering method 1). You can ignore them. What matters is whether a line with the name libx264 exists at all.

To see what the build can do with H.264 in general, use -codecs. It lists each codec with the encoders and decoders available for it.

ffmpeg -codecs

Find the h264 row. The E flag means an encoder is present, and the parentheses list which encoders (such as libx264) are available. If the h264 row lists only decoders, this build cannot encode H.264.

Step 2: Install a Full Build (Per OS)

Replace your minimal build with a full build that includes libx264. The steps depend on your operating system.

Windows: use the gyan.dev “full” or “essentials” build. Both include libx264. Download and extract it, then add its bin folder to your PATH. If you use the Chocolatey package manager, this installs a full build:

choco install ffmpeg-full

Linux: the distribution’s package is usually enough. On Debian and Ubuntu, the ffmpeg package includes libx264:

sudo apt update && sudo apt install ffmpeg

If your repository’s build lacks libx264, switch to a full static build from a trusted source, such as John Van Sickle’s static builds.

macOS: Homebrew’s ffmpeg formula is built with libx264 by default:

brew install ffmpeg

After installing, run ffmpeg -encoders again and check that the libx264 line appears. Also check that you are running the new binary, not an older one that comes earlier in your PATH.

Step 3: Verify With a Real Encode

With libx264 in your build, this standard H.264 encode should run without errors. It re-encodes the video with CRF (constant rate factor) quality control. -crf 23 is a reasonable default; the best value depends on your source and resolution.

ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4
  • -c:v libx264 — use the libx264 H.264 encoder
  • -crf 23 — quality target; lower is higher quality and larger files

If it finishes and the file plays, the Unknown encoder problem is solved. For H.264 settings, see How to Compress Video.

Alternative Encoders When x264 Is Unavailable

Sometimes you cannot install a new build right away, for example on a locked-down server or in a restricted container. You can then use an encoder that comes with almost every FFmpeg build, because it does not depend on an external GPL library.

mpeg4 is FFmpeg’s built-in MPEG-4 Part 2 encoder. It is in most builds (check with ffmpeg -encoders). It produces an MP4 that players such as VLC can play, but web browsers such as Chrome and Firefox cannot. It also compresses less efficiently than H.264.

ffmpeg -i input.mp4 -c:v mpeg4 -q:v 4 output.mp4
  • -q:v 4 — quality scale for mpeg4 (lower is better; 2–5 is a sensible range)

libvpx (VP8) is another common option in builds with WebM support. If your build has it, you can make a WebM file instead:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M output.webm
  • -b:v 1M — target video bitrate (VP8 expects an explicit bitrate)

These are temporary workarounds. When you can, install a full build and go back to libx264, which gives the best quality for the file size in H.264. Before you use an alternative, check with ffmpeg -encoders that your build has it.

Summary

Situation What to do
Unknown encoder 'libx264' appears Your build lacks libx264 — do not change the command
Confirm the cause ffmpeg -encoders and check for a libx264 line
Permanent fix Install a full build (gyan.dev/Chocolatey, distro ffmpeg, Homebrew)
Verify the fix ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4
Cannot install yet Fall back to -c:v mpeg4 or -c:v libvpx

FAQ

Why does the command work on one machine but not another?

FFmpeg builds differ. The machine where it works has a full build with libx264, and the other has a minimal build without it. The command is the same; only the FFmpeg binaries differ. Run ffmpeg -encoders on both and compare.

Can I just add an option to enable libx264?

No. No option adds an encoder at run time. Encoders are compiled into the binary when it is built, so the only way to get libx264 is to install (or compile) a build that includes it.

Is libx264 the same as the h264 codec?

Not exactly. h264 is the codec (the format). libx264 is one encoder that produces it. FFmpeg may also have hardware encoders for h264, such as h264_nvenc, which are other encoders for the same codec. ffmpeg -codecs shows which encoders your build offers for h264.

Will mpeg4 output play in the same players as libx264?

Not everywhere. Players such as VLC play MPEG-4 Part 2 in an MP4 container, but web browsers such as Chrome and Firefox do not. It is also less efficient: at the same file size, mpeg4 looks worse than libx264. Use it as a temporary fallback, not a replacement.