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 > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th September 2021, 23:50   #1  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 58
x264 "threads" quality problem

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
andiandi is offline   Reply With Quote
Old 17th September 2021, 01:15   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
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?

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/jp...oc/threads.txt
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th September 2021 at 01:34.
LoRd_MuldeR is offline   Reply With Quote
Old 17th September 2021, 03:45   #3  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 58
Quote:
Originally Posted by LoRd_MuldeR View Post
So, the question is, how exactly did you determine that the result with more threads is "better" than with one thread?
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.
andiandi is offline   Reply With Quote
Old 17th September 2021, 03:51   #4  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
Quote:
Originally Posted by andiandi View Post
Then I noticed that in several occurrences threads=1 seemed worse to me, which is strange.
Were the file sizes the same?
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 17th September 2021, 04:00   #5  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 58
Quote:
Originally Posted by Asmodian View Post
Were the file sizes the same?
Yes. Same bitrates/file sizes.
andiandi is offline   Reply With Quote
Old 17th September 2021, 04:12   #6  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
And you aren't comparing I-frames to P-frames or P-frames to B-frames?
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 17th September 2021, 04:16   #7  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 58
Quote:
Originally Posted by Asmodian View Post
And you aren't comparing I-frames to P-frames or P-frames to B-frames?
I compared B-frames to B-frames.
andiandi is offline   Reply With Quote
Old 17th September 2021, 21:45   #8  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by andiandi View Post
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
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th September 2021 at 21:53.
LoRd_MuldeR is offline   Reply With Quote
Old 18th September 2021, 00:58   #9  |  Link
andiandi
Registered User
 
Join Date: Aug 2017
Posts: 58
Quote:
Originally Posted by LoRd_MuldeR View Post
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
andiandi 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 14:31.


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