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.
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.