View Full Version : x264 "threads" quality problem
andiandi
16th September 2021, 23:50
Hi,
I'm dealing with a very grainy video, I tried to reduce threads to 1 to help improving quality a bit but looking at the result it seems to me that the default thread settings for me (threads = 6) gives better results in many of my tests with several bitrates.
It's odd because AFAIK low threads implies better quality.
I was wondering if it was because of the grainy source causing more random results (or something else) and if threads=1 is really better whatever the source is ?
Thank you
LoRd_MuldeR
17th September 2021, 01:15
It is slice-based threading that can have a certain detrimental effect on quality. That is what x264 used in the early days (and is still available as an option, for low-latency scenarios).
Nowadays, x264 uses frame-based threading, by default. And, with frame-based threading, the effect of the thread count on quality should really be negligible. But I don't see how using more threads could actually improve the result.
So, the question is, how exactly did you determine that the result with more threads is "better" than with one thread? :confused:
BTW: You could try adding "--non-deterministic" in order to slightly improve quality. By default, x264 enforces deterministic behavior when using multiple threads. This option removes the restriction (at the cost of repeatability).
See also:
https://raw.githubusercontent.com/jpsdr/x264/master/doc/threads.txt
andiandi
17th September 2021, 03:45
So, the question is, how exactly did you determine that the result with more threads is "better" than with one thread? :confused:
With my eyes only. I compared several encoding settings and many frames to see if it can improves that grainy source, even a slightly bit that would be unnoticeable in motion.
Then I noticed that in several occurrences threads=1 seemed worse to me, which is strange.
Asmodian
17th September 2021, 03:51
Then I noticed that in several occurrences threads=1 seemed worse to me, which is strange.
Were the file sizes the same?
andiandi
17th September 2021, 04:00
Were the file sizes the same?
Yes. Same bitrates/file sizes.
Asmodian
17th September 2021, 04:12
And you aren't comparing I-frames to P-frames or P-frames to B-frames?
andiandi
17th September 2021, 04:16
And you aren't comparing I-frames to P-frames or P-frames to B-frames?
I compared B-frames to B-frames.
LoRd_MuldeR
17th September 2021, 21:45
With my eyes only. I compared several encoding settings and many frames to see if it can improves that grainy source, even a slightly bit that would be unnoticeable in motion.
Then I noticed that in several occurrences threads=1 seemed worse to me, which is strange.
Frame-by-frame comparisons are not always expedient. AFAIK, x264 is mostly optimized to look good at "normal" playback speed.
Also, to my understanding, x264 is deterministic as long as you are encoding with the exactly same settings and option "--non-deterministic" was not set. By changing the number of threads you are changing the encoding settings, though. This means that results won't be exactly same. It's a bit like rolling the dice again. Even though the differences should be very small, things could happen to come out slightly "better" in some frames, and slightly "worse" in other frames.
So, unless "threads=1" consistently looks worse than "threads=6", with various different sources, and not just in a few selected frames, I wouldn't worry too much ;)
andiandi
18th September 2021, 00:58
Frame-by-frame comparisons are not always expedient. AFAIK, x264 is mostly optimized to look good at "normal" playback speed.
Also, to my understanding, x264 is deterministic as long as you are encoding with the exactly same settings and option "--non-deterministic" was not set. By changing the number of threads you are changing the encoding settings, though. This means that results won't be exactly same. It's a bit like rolling the dice again. Even though the differences should be very small, things could happen to come out slightly "better" in some frames, and slightly "worse" in other frames.
So, unless "threads=1" consistently looks worse than "threads=6", with various different sources, and not just in a few selected frames, I wouldn't worry too much ;)
Ok. Then I'll just do some more tests to make sure there isn't real issues, but I got it and the difference is indeed very small so it should be alright.
Thank you :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.