Log in

View Full Version : Slow, custom builds of ffmpeg and x264.


kromak
18th April 2026, 01:59
Slow, custom builds of ffmpeg and x264

Hello. I compiled and built both libx264 and ffmpeg libraries from source. Unfortunately, both proved to be slower than the two old John Van Sickle pre-built binaries that I use. The performance gap varies a bit, but it is often considerably slower on two different x264 preset. The difference is always there, and I have no idea as to why this happens.

I used two small clips with two different presets, one of them with two different crf values, to compare the two pre-built binaries and my own. The first is the one that I use daily, from early 2017, presumably using the latest ffmpeg and x264 from that period (Lavf57.66.102 and Lavc57.81.100 libx264). The second is a ffmpeg-4.2.1 one (Lavf58.29.100 and Lavc58.54.100). Generally these two shows nearly identical performance. I can notice some small difference between videos encoded between them that could explain this very small gap in performance, especially in veryfast preset. But it is not relevant.

The third it is my custom build ffmpeg with an x264. It is a ffmpeg 7.0.3 one with an x264 from the same period (Lavf61.1.100 and Lavc61.3.100). As the results bellow shows, it is always slower. The one million dollar question it is: Why?

benchmark 1

x264, ultrafast, crf 20
antiga: 1.41x
4.1.2: 1.39x
7.0.3: 1.30x

x264, slow, crf 27:
antiga: 0.29x
4.1.2: 0.288x
7.0.3: 0.271x

x264, slow, crf 20:
antiga: 0.223x
4.1.2: 0.22x
7.0.3: 0.21x




benchmark 2

x264, ultrafast, crf 20
antiga: 0.742x
4.1.2: 0.737x
7.0.3: 0.725x

x264, slow, crf 27:
antiga: 0.390x
4.1.2: 0.387x
7.0.3: 0.372x

x264, slow, crf 20:
antiga: 0.312x
4.1.2: 0.308x
7.0.3: 0.295x


I thought some possible explanations for these results: Slower compiler, slower Glibc, slower Gcc, newer libx264 being slower, different compiler settings.

Given that most of more relevant code is written in assembly, this likely puts a limit in what the three first options can influence. What else I could be tried? I tried profiling once, but it produced a far slower x264, a difference bigger from it to my current x264 than from it to Van Sickle binaries, I think.

StainlessS
18th April 2026, 12:34
From an old version ffmpeg,


C:\Users\steve>ffmpeg -version
ffmpeg version n8.0.1-28-g9c93070155 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 15.2.0 (Rev8, Built by MSYS2 project)
configuration: --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++' --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-conversion --disable-autodetect --enable-amf --enable-bzlib --enable-cuvid --enable-d3d12va --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-gpl --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-libaom --disable-debug --enable-libfdk-aac --enable-libbluray --enable-libvpl --enable-libsoxr --enable-libspeex --enable-libtwolame --enable-libxml2 --enable-libzimg --enable-libshine --enable-avisynth --enable-libxvid --enable-version3 --enable-libsrt --enable-openal --enable-openssl --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --enable-nonfree --extra-cflags=-DAL_LIBTYPE_STATIC --extra-cflags='-ID:/MABS-ff/local64/include' --extra-cflags='-ID:/MABS-ff/local64/include/AL'
libavutil 60. 8.100 / 60. 8.100
libavcodec 62. 11.100 / 62. 11.100
libavformat 62. 3.100 / 62. 3.100
libavdevice 62. 1.100 / 62. 1.100
libavfilter 11. 4.100 / 11. 4.100
libswscale 9. 1.100 / 9. 1.100
libswresample 6. 1.100 / 6. 1.100

Exiting with exit code 0

C:\Users\steve>


Starting out check comparison between versions.

I aint no expert, but maybe clues in above.

EDIT: And with ffmpeg -buildconf as suggested below, I get

C:\Users\steve>ffmpeg -buildconf
ffmpeg version n8.0.1-28-g9c93070155 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 15.2.0 (Rev8, Built by MSYS2 project)
configuration: --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++' --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-conversion --disable-autodetect --enable-amf --enable-bzlib --enable-cuvid --enable-d3d12va --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-gpl --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-libaom --disable-debug --enable-libfdk-aac --enable-libbluray --enable-libvpl --enable-libsoxr --enable-libspeex --enable-libtwolame --enable-libxml2 --enable-libzimg --enable-libshine --enable-avisynth --enable-libxvid --enable-version3 --enable-libsrt --enable-openal --enable-openssl --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv --enable-nonfree --extra-cflags=-DAL_LIBTYPE_STATIC --extra-cflags='-ID:/MABS-ff/local64/include' --extra-cflags='-ID:/MABS-ff/local64/include/AL'
libavutil 60. 8.100 / 60. 8.100
libavcodec 62. 11.100 / 62. 11.100
libavformat 62. 3.100 / 62. 3.100
libavdevice 62. 1.100 / 62. 1.100
libavfilter 11. 4.100 / 11. 4.100
libswscale 9. 1.100 / 9. 1.100
libswresample 6. 1.100 / 6. 1.100

configuration:
--pkg-config=pkgconf
--cc='ccache gcc'
--cxx='ccache g++'
--ld='ccache g++'
--extra-cxxflags=-fpermissive
--extra-cflags=-Wno-int-conversion
--disable-autodetect
--enable-amf
--enable-bzlib
--enable-cuvid
--enable-d3d12va
--enable-d3d11va
--enable-dxva2
--enable-iconv
--enable-lzma
--enable-nvenc
--enable-zlib
--enable-sdl2
--enable-ffnvcodec
--enable-nvdec
--enable-cuda-llvm
--enable-gpl
--enable-libmp3lame
--enable-libopus
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-libx265
--enable-libdav1d
--enable-libaom
--disable-debug
--enable-libfdk-aac
--enable-libbluray
--enable-libvpl
--enable-libsoxr
--enable-libspeex
--enable-libtwolame
--enable-libxml2
--enable-libzimg
--enable-libshine
--enable-avisynth
--enable-libxvid
--enable-version3
--enable-libsrt
--enable-openal
--enable-openssl
--extra-cflags=-DLIBTWOLAME_STATIC
--extra-cflags=-DLIBXML_STATIC
--extra-libs=-liconv
--enable-nonfree
--extra-cflags=-DAL_LIBTYPE_STATIC
--extra-cflags='-ID:/MABS-ff/local64/include'
--extra-cflags='-ID:/MABS-ff/local64/include/AL'

Exiting with exit code 0

C:\Users\steve>


EDIT: Also, ffmpeg -h full
but you will havta not blink, it zips past pretty quick.
(Or ffmpeg -help full >D:\ffmpeg_help.txt" where drive D: must exist)

qyot27
18th April 2026, 18:11
*cough* -buildconf *cough*

Z2697
19th April 2026, 19:23
A separate decoding / encoding test would find out what part is the problem (if it's one of them).
But the disk R/W speed may play a big role... so maybe decode to null, and encode from synthetic source? (e.g. testsrc2)