wader / static-ffmpeg

Multi-arch docker image with ffmpeg/ffprobe binaries built as hardened static PIE binaries with no external dependencies
https://hub.docker.com/r/mwader/static-ffmpeg/
MIT License
260 stars 62 forks source link

AVX512 not working with x265 or svt-av1 codecs #483

Closed phpb-com closed 1 week ago

phpb-com commented 3 months ago

I've tried to run this ffmpeg on a system with AVX512 and found that neither x265 nor svt-av1 are using it. I was able to make svt-av1 use it after adding -DENABLE_AVX512=ON to the Dockerfile (to the compilation flags of svt-av1) but was not able to make x265 use or detect it. Do you know of any reasons why that might be the case with x265?

phpb-com commented 3 months ago

actually, adding asm=avx512 to the -x265-params does seem to work, so I guess the only thing is to maybe add compilation flag to the svt-av1 if it it not going to break compilation for the other architectures.

wader commented 3 months ago

Hey, huh nice find! i guess at the time i assumed it would be feature detected. I see in build log that some other libs and ffmpeg do detect and i hope build with avx512.

So yes it would be great to add this if it needs to be done explicitly in some places. I wonder if it needs to be done conditionally only for amd64? also for svt-av1 the cmake has AVX512 stuff but for x265 i don't find much about asm=avx512, do you know if it's documented etc somewhere? ...also are there more cpu features we should enable in some libs?

About breaking, good question. I did a quick search what kind of support one can expect on half-modern cpus but was not clear, seems there are subsets of AVX-512? i also wonder if ffmpeg and libs usually runtime detect even if built with it?

phpb-com commented 3 months ago

https://www.intel.com/content/dam/develop/external/us/en/documents/mcw-intel-x265-avx512.pdf has the flag for avx512 so that is where I got it and converted into x265-param. Seems that the avx-svt1 has similar flag and it is in their documentation, but I have not tried it, and it is default to asm=max. x264 uses avx512 without any need to modify or recompile.

I am not sure of any other flags, or codecs that could benefit from them, but I am sure there are some for vpx codecs too.

wader commented 3 months ago

Aha now i see, you mean for x265 i do build with avx512 but it need to be enabled at runtime with -x265-params? if so can it be made default or is there some reason it's not default?

Sorry for feature creeping this issue, probably good to focus on fixing just avx512 for x265 and svt-av1 first. Can look at other stuff later.

Please do a draft PR if you like. It's a bit late here but can have a look at it also tomorrow

phpb-com commented 3 months ago

I think that x265 is not using avx512 unless forced is because it may actually make the encoding slower, so it is a good thing. As for the svt-av1, it does increase the performance but (from my understanding) it should be enabled during compile time to be utilized. In the end I think that the only thing that I should PR is svt-av1 compile flags, so I will do that for now. Enjoy your evening, I'll do it sometime within next 12 hours since I am AFK at the moment.

wader commented 3 months ago

I guess for x265 it could be mentioned in the README that it's possible

wader commented 1 week ago

Close issue? svt1-av1 is now built with avx512 and as i understand x265 can use avx512 with an option