Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > New and alternative video codecs

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th December 2024, 18:21   #1  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
What is the maximum number of threads in x264?

I know that the x264 codec isn't improved. The codec is in use though.
I'm interested in the topic of correctly adding the default number of threads in x264 for the i5 13600K processor. For me x264 adds threads=30. Doesn't it overstate?

https://code.videolan.org/videolan/x...30973295c87aca
Jamaika is offline   Reply With Quote
Old 8th December 2024, 05:56   #2  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,913
Amount of threads is, IIRC, 1.5x num of CPU. You should just use 'auto' and don't bother.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 8th December 2024, 07:21   #3  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
My question is for auto 30 threads. Is this value from outer space and heats the processor until I finally burn it? For vvenv, xeve there are protections up to 12 threads.
resolution < 720p: 4, < 5K 2880p: 8, >= 5K 2880p: 12 threads

https://www.intel.com/content/www/us...fications.html
For 13600K total threads 20

For x265 is:
x265 [info]: Thread pool created using 20 threads

Last edited by Jamaika; 8th December 2024 at 07:28.
Jamaika is offline   Reply With Quote
Old 9th December 2024, 14:39   #4  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 361
Quote:
Originally Posted by Jamaika View Post
My question is for auto 30 threads. Is this value from outer space and heats the processor until I finally burn it? For vvenv, xeve there are protections up to 12 threads.
resolution < 720p: 4, < 5K 2880p: 8, >= 5K 2880p: 12 threads

https://www.intel.com/content/www/us...fications.html
For 13600K total threads 20

For x265 is:
x265 [info]: Thread pool created using 20 threads
Use more therads than "physical" threads won't burn you CPU more than "1:1 threads".

Also I don't think that 12 threads thing is protection.
Z2697 is offline   Reply With Quote
Old 9th December 2024, 16:34   #5  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
Quote:
Originally Posted by Z2697 View Post
Also I don't think that 12 threads thing is protection.
Xeve gives max 8 threads. Where does this preventiveness come from?
I read and read. I wasn't interested when I had old processor 4 threads that x264 gives 6. Today I find out that vvenc is tested only for 8/12 threads because otherwise other functions may work incorrectly and be e.g. fps incompatible.

How is compatibility for x264/x265 with max thread 30? 10 years ago it was not possible to add 30 threads.

Last edited by Jamaika; 9th December 2024 at 16:38.
Jamaika is offline   Reply With Quote
Old 9th December 2024, 17:56   #6  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 361
Quote:
Originally Posted by Jamaika View Post
Xeve gives max 8 threads. Where does this preventiveness come from?
I read and read. I wasn't interested when I had old processor 4 threads that x264 gives 6. Today I find out that vvenc is tested only for 8/12 threads because otherwise other functions may work incorrectly and be e.g. fps incompatible.

How is compatibility for x264/x265 with max thread 30? 10 years ago it was not possible to add 30 threads.
They are limitations, I guess. Either lacking the implementation of atuomatically choose thread count based on "physical threads" or lacking enough parallel capability.

High core count CPUs did exist 10 years ago, but less common. I know some people prefer to limit the threads in x264 to 16 and use multiple concurrent encoding sessions to utilize the rest of total threads, but that just their personal preference, there's no major downside to use more threads.
Z2697 is offline   Reply With Quote
Old 8th December 2024, 08:45   #7  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,913
It's not out of space. There's a formula behind it. I recall back in the days Dark Shikari explained it once how the amount is calculated but I can't find it no more :/
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 8th December 2024, 14:08   #8  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,385
If i remember properly, the max = height/40.
Another thing i vaguely remember, it wasn't also recommended to have more than 20, as above there is a several quality drop.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 8th December 2024, 18:50   #9  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
Quote:
Originally Posted by jpsdr View Post
If i remember properly, the max = height/40.
Another thing i vaguely remember, it wasn't also recommended to have more than 20, as above there is a several quality drop.
Impossible. For my video 1920 divided by 40 is 48.
Jamaika is offline   Reply With Quote
Old 8th December 2024, 21:38   #10  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,173
You may wanna take a look at my post from earlier on this year: https://forum.doom9.org/showthread.php?p=1999533
Jean Philippe was spot on then and is spot on now:

Quote:
Originally Posted by jpsdr View Post
max = height/40.
In my example, I was encoding a UHD source, so 3840x2160 which means 2160:40 = 54 maximum threads and sure enough if you count all the "boxes" you get 54:




We can make a little list here:

720x480 = 480/40 = 12 maximum threads (SD NTSC)
720x576 = 576/40 = 14 maximum threads (SD PAL)
1280x720 = 720/40 = 18 maximum threads (HD)
1920x1080 = 1080/40 = 27 maximum threads (FULL HD)
3840x2160 = 2160/40 = 54 maximum threads (UHD)


To me, however, more than the lack of ability to scale on multiple cores/threads, the biggest downside is the lack of AVX512 which are there for x264 8bit but are missing for x264 10bit.
FranceBB is offline   Reply With Quote
Old 8th December 2024, 21:56   #11  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
Quote:
Originally Posted by FranceBB View Post
To me, however, more than the lack of ability to scale on multiple cores/threads, the biggest downside is the lack of AVX512 which are there for x264 8bit but are missing for x264 10bit.
Thanks for the answer. Now it's more correct, although x264 adds 30 threads and not 27. Correct or incorrect? Should max threads be added?
X264 is an old codec that only has AVX512F. I think AVX10 is already there.
Free OpenCL has also been abandoned.
Jamaika is offline   Reply With Quote
Old 15th December 2024, 20:57   #12  |  Link
Sagittaire
Testeur de codecs
 
Sagittaire's Avatar
 
Join Date: May 2003
Location: France
Posts: 2,530
Quote:
Originally Posted by FranceBB View Post
You may wanna take a look at my post from earlier on this year: https://forum.doom9.org/showthread.php?p=1999533
To me, however, more than the lack of ability to scale on multiple cores/threads, the biggest downside is the lack of AVX512 which are there for x264 8bit but are missing for x264 10bit.
Well I think that the ability to scale on multiple cores/threads is really higher problem for speed encoding than lack AVX512 compatility.

In the best case, speed AVX512 improvement must be at ~10% for x264 and certainely less in real life encoding scenario.

If you want I have really interessing test for your 52C/112T Xeon to prove that ... ;-)
__________________
Le Sagittaire ... ;-)

1- Ateme AVC or x264
2- VP7 or RV10 only for anime
3- XviD, DivX or WMV9

Last edited by Sagittaire; 15th December 2024 at 21:00.
Sagittaire is offline   Reply With Quote
Old 15th December 2024, 21:18   #13  |  Link
LunaRabbit
Lunarian
 
LunaRabbit's Avatar
 
Join Date: Dec 2024
Posts: 15
Quote:
Originally Posted by Sagittaire View Post
In the best case, speed AVX512 improvement must be at ~10% for x264 and certainely less in real life encoding scenario.
Did they ever solve the problem with AVX512 causing chips to heat up quickly and throttle? I've held off on buying any Intel stuff for several years now because of that. AVX512 does sound interesting but I've never heard anything good about it. But I don't have many friends running the latest Xeon either.
LunaRabbit is offline   Reply With Quote
Old 15th December 2024, 23:32   #14  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,173
Quote:
Originally Posted by LunaRabbit View Post
Did they ever solve the problem with AVX512 causing chips to heat up quickly and throttle?
Yes, however in my case we're talking about a very controlled environment, namely a server room, which is not what most people would run those things on. That being said, Xeon are very different from consumer chips. I wouldn't recommend any Intel consumer CPU these days at least given that they seem to be all hands on power efficiency rather than performance and I'm not a fan of the hybrid Efficiency Core / Performance Core approach either. I mean, it makes sense on a laptop but definitely not on a desktop. My personal workstation from 2017 is powered by a 20c/40th Xeon (AVX2 only, no AVX512) and an NVIDIA Quadro P4000, with 64 GB of RAM. It's getting older, but it's still pretty good encoding-wise. Still, with October 2025 getting closer and Windows 10 approaching the end of support, Microsoft would deem such a thing "obsolete" as it only has a TPM 1.2 and not a TPM 2.0 chip. Sure, there are workarounds to get that abomination of Windows 11 running anyway despite the lack of a TPM 2.0 chip, but still this just shows how ridiculous the requirement is...

Quote:
Originally Posted by Sagittaire View Post
If you want I have really interessing test for your 52C/112T Xeon to prove that ... ;-)
Yeah, I saw the benchmark post and I've been eager to try it, but I have to find a bit of time to do that. Generally those have very little downtime aside from every second Wednesday of the month when I install the Windows Security Updates (yes, I know that Patch Tuesday is the second Tuesday of the month, but it's in U.S time, which translates to Wednesday in UK time).
FranceBB is offline   Reply With Quote
Old 23rd December 2024, 10:04   #15  |  Link
Sagittaire
Testeur de codecs
 
Sagittaire's Avatar
 
Join Date: May 2003
Location: France
Posts: 2,530
Quote:
Originally Posted by FranceBB View Post
Yeah, I saw the benchmark post and I've been eager to try it, but I have to find a bit of time to do that. Generally those have very little downtime aside from every second Wednesday of the month when I install the Windows Security Updates (yes, I know that Patch Tuesday is the second Tuesday of the month, but it's in U.S time, which translates to Wednesday in UK time).
In fact for your monster Xeon, you need particular benchmark version.

Certainly with 8 simultaneous mulipart encoding scession to saturate your 56/112 thread CPU.

I can make really particular benchmark to show the multipart encoding interest.
__________________
Le Sagittaire ... ;-)

1- Ateme AVC or x264
2- VP7 or RV10 only for anime
3- XviD, DivX or WMV9
Sagittaire is offline   Reply With Quote
Old 9th December 2024, 07:27   #16  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,173
Opencl is still supported as per x264 8bit and you can still compile x264 with support for it. I use it with --opencl all the time. The problem is that once again that's only for the 8bit version as it never made its way into the 10bit version (and probably never will).
FranceBB is offline   Reply With Quote
Old 9th December 2024, 08:23   #17  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 838
True but X264 OpenCL doesn't support the motherboard and is at version level 1.2.
Jamaika is offline   Reply With Quote
Old 9th December 2024, 18:15   #18  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,913
Do note that x264 is not very effective at utilizing so many threads. I have a 12c/24t CPU and even though x264 runs with 25 threads on it, the cores/threads are not fully pegged at 100%. I get more like 80-85% utilization per core/thread. Also, the more threads you throw at it, there will be a small decrease in quality.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 9th December 2024, 21:09   #19  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 361
Quote:
Originally Posted by microchip8 View Post
Do note that x264 is not very effective at utilizing so many threads. I have a 12c/24t CPU and even though x264 runs with 25 threads on it, the cores/threads are not fully pegged at 100%. I get more like 80-85% utilization per core/thread. Also, the more threads you throw at it, there will be a small decrease in quality.
I tried the "more thread less quality" with x265 and found "not quite".
The situations which make difference are:
1) pools < 4 / pools >= 4
2) frames-threads = 1 / frame-threads > 1
3) no-wpp / wpp
For pools and frame-threads, the number beyond the upper bound (4 and 1 respectively, as above) don't seem to impact any quality.

I might find some time to test x264 as well.

Last edited by Z2697; 10th December 2024 at 05:40.
Z2697 is offline   Reply With Quote
Old 9th December 2024, 22:52   #20  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,913
The loss is there, you just can't see it. It's not like it loses so much quality that it's blatently visible.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:29.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.