11

So, I know about the obvious

ffmpeg -version

but it doesn't give info such as which version of libx265 is included in my current ffmpeg build. Is there an easy way to check it, apart from converting a small dummy file using the codecs that I want to check and then reading the file's metadata?

I looked into

ffmpeg -h

but I didn't find anything that seemed relevant. For instance, I found these:

ffmpeg -encoders
ffmpeg -codecs

They do list encoders or codecs, but without their version :/

1
  • 2
    Not implemented.
    – Gyan
    Commented Aug 13, 2018 at 16:02

4 Answers 4

7

Unfortunately it's not possible to list the exact versions of encoders ffmpeg has been compiled against.

The only way to find out is to run an actual encode:

ffmpeg -f lavfi -i nullsrc -frames:v 1 -c:v libx264 test.mp4

For example, this already prints in the ffmpeg log:

[libx264 @ 0x1518214b0] 264 - core 164 r3108 31e19f9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - ...

This gives you the x264 version. With x265, you get similar metadata printed in the ffmpeg log:

x265 [info]: HEVC encoder version 3.4+31-6722fce1f

libvpx prints it like this:

[libvpx-vp9 @ 0x13e0080f0] v1.13.1

Some encoders might only show their version when running ffmpeg with -loglevel debug.

Using MediaInfo

You can also use mediainfo the metadata of the output file:

$ mediainfo test.mp4 | grep "Writing library"
Writing library                          : x264 core 164 r3108 31e19f9

Some libraries may embed this information into the output file. libvpx does not, for example.

Do not rely on your binaries!

Do not rely on existing binaries or libraries present on your system, as your ffmpeg version may have been statically compiled against a different library (such as the case with static builds available from ffmpeg.org).

2
  • I executed that command and got the file test.mp4, now I don't know how to do the "check the metadata of the output file". I don't know if that metadata is missing in accordance with your "Note that not all encoders will write such metadata though.", or I don't know how to look for it. Where is it, how is it called? Commented Mar 20 at 19:45
  • @Santropedro The answer was lacking details, I added some. The most reliable way is to actually run the encode.
    – slhck
    Commented Mar 21 at 12:38
2

Often the version will show in the name of the codec library. You just have to figure out where the libraries are located. For example on Linux:

$ which ffmpeg
/usr/local/bin/ffmpeg

$ ldd /usr/local/bin/ffmpeg
 ...

$ ls -l /usr/local/lib/libx265*
/usr/local/lib/libx265.199.so
2
  • Unfortunately that's only the ABI version. Even major changes to the software can maintain the same ABI.
    – OrangeDog
    Commented Jul 13, 2023 at 16:02
  • If it's in /usr/local/bin then you probably built it yourself and know what versions you used. If it's installed from a package, and is dynamically linked, you can check the package versions of those libraries.
    – OrangeDog
    Commented Jul 13, 2023 at 16:06
1

Actually, if you are on a Linux platform, yes there is a simple way to verify.

There are a few ways to do it, depending on how high of a level of confidence you require in terms of accuracy. For instance, if you know that if a codec is available, that it has the capability you need (e.g. Decode or Encode), then a very basic search is all you need, such as this:

ffmpeg -v quiet -codecs | grep dirac

Above will return a result if the codec support exists, and null if it isn't. Keep in mind, this is a crude solution, and therefore false positives are plausible. It's not a good method if you need to differentiate between similarly named codecs. However, the technique can still be applied, with a bit more effort.

If you don't know whether a codec has the capabilities you need (e.g. in a script), it's possible to check for both the codec function(s) and codec name in a similar manner:

ffmpeg -v quiet -codecs | grep '.*DE.*opus'
                                       ^ name of codec you would enter on command line
                                  ^^ D=Decoder; E=Encoder

For instance, in BaSH you could have something like this in a script:

if [[ $(ffmpeg -v quiet -codecs | grep ".*DE.*dirac.*") ]]; then echo "true"; fi

The line above will return "true" if ffmpeg is capable of both decoding and encoding Dirac streams.

Explanation: if you run ffmpeg with the -codec switch, you will get an output of all codecs it understands. The codecs are prefaced with letter codes that describe their function. 'D' means Decode, meaning that particular codec has decoding capability (read). While 'E' means Encode, or compiling/writing capability using that particular codec.

The -v quiet flag suppresses the ffmpeg text header in its output.

To re-cap, the format is:

ffmpeg -v quiet -codecs | grep {codec-name}

or

codec_exists=$(ffmpeg -v quiet -codecs | grep codec-name)

or to check for a decoder:

if [[ $(ffmpeg -v quiet -codecs | grep ".*D.*codec-name.*") ]]; then echo "true"; fi

to check for an encoder:

if [[ $(ffmpeg -v quiet -codecs | grep ".*E.*codec-name.*") ]]; then echo "true"; fi

to check for whether a codec name exists AND it can decode AND it can encode:

if [[ $(ffmpeg -v quiet -codecs | grep ".*DE.*codec-name.*") ]]; then echo "true"; fi
1
  • None of that includes version numbers
    – OrangeDog
    Commented Jul 13, 2023 at 16:00
-2

List all available decoders

ffmpeg -decoders

List all available encoders

ffmpeg -encoders

External encoders such as H.265 must be installed separately and enabled during compile using '--enable-library' (e.g. --enable-libx265). In which case, you can use the libx265 on the command line to check version.

On my system:

$ ./bin/x265 -V
x265 [info]: HEVC encoder version 2.8+40-0106f9f2f867

Hope that helps. Cheers.

3
  • 1
    The installed binaries are not a good source for checking the version. They may differ depending on the PATH, and ffmpeg may have been compiled statically against another version of the library altogether (which may not even have an executable on the system).
    – slhck
    Commented Aug 14, 2018 at 10:47
  • Ah okay. I happen to install mine using that x265 path. If you don't know what library was used during install it would complicate matters. However, FFmpeg does require x265 to be installed on your system per trac.ffmpeg.org/wiki/Encode/H.265 (bundled or not).
    – iangetz
    Commented Aug 14, 2018 at 12:38
  • 2
    That's not correct – the requirement only applies when you're building the binary. FFmpeg does not require x265 to be installed. You can, for example, go to johnvansickle.com/ffmpeg and just download the binary, which will run on its own.
    – slhck
    Commented Aug 14, 2018 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .