How to enable libx264 in ffmpeg
Is it possible to change the configuration without reinstalling?
The --disable-libx264 flag is a bit misleading. This is not an option that disables the h264 codec during installation, but is a compile flag during creation of your binary/executable. To change that flag, you either need to recompile it yourself, or install a version which had it enabled during compilation. This comes down to the repository you are downloading it from. I can confirm h264 is available on the native x64 Ubuntu version in 18.04.
If not, how do I pass options while reinstalling?
You need to get ffmpeg from a different source which did not disable it. The native windows version installed by chocolatey has the flag enabled on my system. It might be that WSL uses a separate repository which disabled it.
As for how to proceed:
- Use the native windows version of ffmpeg
- Try a different Ubuntu version, e.g. 18.04 LTS
- Download ffmpeg from a different source, example
- Compile ffmpeg from source
Related videos on Youtube
user3053216
Updated on September 18, 2022Comments
-
user3053216 almost 2 years
I am trying to encode with libx264 in ffmpeg
ffmpeg -f image2 -r 25 -i frames/%03d.bmp -vcodec libx264 out.mp4
However, i get the following error message:
Unknown encoder 'libx264'
If us type
ffmpeg
in the console, it shows under configuration --disable-libx264, so I guess that is the reason.How can I enable this? I found in some other questions that it can be done by reinstalling with this option, but there where two things I could not find:
- Is it possible to change the configuration without reinstalling?
- If not, how do I pass options while reinstalling?
-
MMM about 3 yearsWhich OS are you trying this on? Some distributions of ffmpeg don't include the x264 encoders because of hollywood reasons. You can check your available codecs using the
-codecs
argument. -
user3053216 about 3 years@MMM I am using ubuntu 20.04 within windows subsystem for linux. I think the x264 encoder is not there, but i tried to install it with
sudo apt install libx264-dev
-
Elisa Cha Cha about 3 yearsWhere did you get this ffmpeg? The version from the repo supports libx264. Why not just use that?
-
user3053216 about 3 yearsThanks for the reply. I checked the compilation guide earlier and found that i should run
sudo apt install libx264-dev
to install the x264, but this seems to be not enough. -
boots about 3 yearsYou'd still need to compile ffmpeg with the switch --enable-libx264. see here trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu about 2/3 the way down. However, most versions you find already compiled will have it enabled by default. It is only the non-free option for the codecs where the licence prohibits binary sharing that are generally omitted. i.e. I use MINT and their version has x264 enabled as do the windows binaries from the ffmpeg distribution.