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: 861
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,916
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: 861
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 8th December 2024, 08:45   #4  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,916
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   #5  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,405
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   #6  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 861
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   #7  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,210
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   #8  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 861
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 9th December 2024, 07:27   #9  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,210
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   #10  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 861
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, 14:39   #11  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
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   #12  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 861
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   #13  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
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 9th December 2024, 18:15   #14  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,916
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   #15  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
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   #16  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,916
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
Old 10th December 2024, 05:31   #17  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
Quote:
Originally Posted by microchip8 View Post
The loss is there, you just can't see it. It's not like it loses so much quality that it's blatently visible.
For x265 the results which I referred as "don't impact quality" are bitexact if --no-info is used.
The loss is not there.

But for the "make difference" situations, you are correct, the loss is very small, very hard to see.

Last edited by Z2697; 10th December 2024 at 05:37.
Z2697 is offline   Reply With Quote
Old 10th December 2024, 09:19   #18  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,916
I was talking about x264, since this thread is about x264. And the quality drop due to very many threads doesn't come from my mouth but from a past main dev of x264, Dark Shikari.
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 10th December 2024, 14:33   #19  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 457
The source is 3840x2160 video scaled from 1920x1080 'cause it's just for testing
(How to limit the [IMG] display size?)

Last edited by Z2697; 10th December 2024 at 14:35.
Z2697 is offline   Reply With Quote
Old 10th December 2024, 15:14   #20  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 861
Thanks for the test. I understand that there is no difference in speed between thread 48 and 64. What is processor? What does adding the graphics card opencl option do?

The 30 threads option is therefore recommended for editing movies.
Jamaika 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 08:34.


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