Log in

View Full Version : Best x265 Film Grain Settings Without Tuning For Film Grain?


HD MOVIE SOURCE
23rd July 2022, 18:22
Hi,

I've read multiple reports about tuning for film grain using x265 is very poor. So, apart from just slamming more bit-rate in and hoping for the best. What are the best film grain settings?

The type of settings I'm looking for are ones that resolve film grain perfectly. I'm not looking to blur anything, I want pin-sharp film grain with zero macro noise blocking or blurring. For reference, think Django (Arrow) and For a Few Dollars More (Kino Lorber) 4K Ultra HD Blu-ray transfers. Django 4K resolves grain practically perfectly.

Can anyone help me find the best settings (generally) for film grain? Even secondary things like deblock settings that could help grain look finer without any blur of softness.

I'm trying to keep things to the 4K Ultra HD Blu-ray standard, so I'm not looking for settings that this standard cannot do, like more than 3 B Frames. Because I'm also trying to understand encoding on 4K Blu-ray, and one day, you never know, encode something.

I'm not thinking about compression or data saving here, so as long as it can fit into around 98 Mbps, and is compliant with UHD-BD I'd like to hear it please.


Because I'm learning still, would it be possible to explain what the settings do that improve grain? You don't have to, but that would be great if you could.

Thanks,
Carl.

RanmaCanada
24th July 2022, 02:49
not possible AFAIK. You will not get pin sharp grain in HEVC. If you want pin sharp, go to x264.

Though I could be wrong, and if I am, someone will correct me, hopefully.

rwill
24th July 2022, 07:56
not possible AFAIK. You will not get pin sharp grain in HEVC. If you want pin sharp, go to x264.

Though I could be wrong, and if I am, someone will correct me, hopefully.

But he even writes that he has UHD BD examples where grain is very good in his opinion. So it sure is possible. Then again maybe not with x265.

Boulder
24th July 2022, 10:44
I think the commercial encoders studios use do retain grain much better than x265.

However, if data saving is not the issue, why not just remux and enjoy the original as it is.

rwill
24th July 2022, 11:12
However, if data saving is not the issue, why not just remux and enjoy the original as it is.

I think because he is "trying to understand encoding on 4K Blu-ray, and one day, you never know, encode something".

Not everyone is just re-encoding pirated remuxes because they cannot afford neither the original discs nor the HDD space.

HD MOVIE SOURCE
25th July 2022, 06:24
I think because he is "trying to understand encoding on 4K Blu-ray, and one day, you never know, encode something".

Not everyone is just re-encoding pirated remuxes because they cannot afford neither the original discs nor the HDD space.

Correct, I'm not doing this to just rip a movie, I'm trying to find out if there are any settings that make grain look better, even though x265 may have its issues with grain, I've certainly seen plenty of examples of grain looking very good on 4K UHD Blu-ray.

Was it just a case of the bit-rates being high enough that the film grain resolved almost perfectly?

rwill
25th July 2022, 07:51
Correct, I'm not doing this to just rip a movie, I'm trying to find out if there are any settings that make grain look better, even though x265 may have its issues with grain, I've certainly seen plenty of examples of grain looking very good on 4K UHD Blu-ray.

Was it just a case of the bit-rates being high enough that the film grain resolved almost perfectly?

UHD BD are more or less encoded at 0.2-0.5 bits/pixel. While this helps a lot with the illusion of the film grain still being there its not the original film grain which was present in the source the encode was done from.

BD encoders employ some models and tools and are tuned by the encoder 'operator' to produce a 'look' which should be true to the original content, keeping the artistic intent.

Sadly x265 is no such encoder as far as I can tell.

kolak
25th July 2022, 16:33
Not sure which BD encoder are you talking about ?
Today's BD encoding is about doing it as quickly and cheaply as possible :) No one spends any time on it.
Grain modelling, keeping artistic intent? Hmmm...it's rather a fantasy (maybe single titles).
Any titles with "nice grain" are simply not done with x265 as it's not very good with it.

benwaggoner
26th July 2022, 01:33
Some things that can help:

Higher --psy-rd and --psy-rdoq
Not using --rd 6 (on by default in slower-placebo)
Using --rskip 2 instead of 1
Reducing --pbratio

HD MOVIE SOURCE
28th July 2022, 22:51
Some things that can help:

Higher --psy-rd and --psy-rdoq
Not using --rd 6 (on by default in slower-placebo)
Using --rskip 2 instead of 1
Reducing --pbratio


Thank you, will take a look at these settings.

HD MOVIE SOURCE
31st July 2022, 03:43
Some things that can help:

Higher --psy-rd and --psy-rdoq


Higher --psy-rd and --psy-rdoq?
I saw that the values here go to 5.0 with --psy-rd and 50 with --psy-rdoq. Is there a good ratio to use between them both? I'm not sure about the strength of each one, and exactly what it does.

Do the scale equally? So --psy-rd 1.0 then --psy-rdoq is 10?

Thanks.

Boulder
31st July 2022, 12:21
--no-sao is also a must whenever any detail or grain is to be retained.

benwaggoner
1st August 2022, 03:12
Higher --psy-rd and --psy-rdoq?
I saw that the values here go to 5.0 with --psy-rd and 50 with --psy-rdoq. Is there a good creation to use between them both? I'm not sure about the strength of each one, and exactly what it does.

Do the scale equally? So --psy-rd 1.0 then --psy-rdoq is 10?
The old --tune grain settings are really old, and tuned for very old versions (pre 2.0, certainly) of x265. --psy-rd of 5.0 is pretty high, and --psy-rdoq of 50 is way overkill. And there's no particular ratio between those to target for more modern versions. I'd definitely start in the single digits for both and tweak from there.

HD MOVIE SOURCE
5th August 2022, 21:47
The old --tune grain settings are really old, and tuned for very old versions (pre 2.0, certainly) of x265. --psy-rd of 5.0 is pretty high, and --psy-rdoq of 50 is way overkill. And there's no particular ratio between those to target for more modern versions. I'd definitely start in the single digits for both and tweak from there.

Okay, now what exactly am I looking for? Is it a sharpening tool? Or just the ability to preserve grain?


These are the listed grain settings tuning for grain, why are they bad?

--aq-mode 0
--cutree 0
--ipratio 1.1
--pbratio 1.0
--qpstep 1
--sao 0
--psy-rd 4.0
--psy-rdoq 10.0
--recursion-skip 0

Could you tell me what you would use for the best grain settings, considering that this isn't for streaming but for quality and preserving as much grain detail as possible?

Thanks for the help,
Carl.

excellentswordfight
6th August 2022, 10:15
As i dont do HEVC/x265 encodings over 20Mbps I dont have much experience when it comes to tuning for absolute transparency ... But I think that x265 get a bit too much hate when it comes to image preservation, I think its fine when using at least preset slow and --no-sao --deblock -1:-1 --aq-mode 1, and thats what I would recommend as a starting point, and then start tuning the settings benwaggoner mentioned.

Some things that can help:

Higher --psy-rd and --psy-rdoq
Not using --rd 6 (on by default in slower-placebo)
Using --rskip 2 instead of 1
Reducing --pbratio

interesting, just tired rskip 2 and I got a 2x speed increase for a medium grainy UHD source at preset slow. I dont think it helped much with the grain though, and it displayed a bit more blocking, but that speed increase just seems insane. I couldnt tell the encodes apart from normal viewing. Is that to be expected? Seems unreasonable.

Boulder
6th August 2022, 17:48
I've noticed that rskip mode 2 does help with the so called "onion effect" which sometimes occurs in flat areas, and it seems to create less floating noise when the grain is not so sharp. I also set the rskip edge threshold to 2 (=0.02).

bosox188
7th August 2022, 15:30
Some things that can help:

Higher --psy-rd and --psy-rdoq
Not using --rd 6 (on by default in slower-placebo)
Using --rskip 2 instead of 1
Reducing --pbratio


What's the thinking behind not using --rd 6 (or 5, which I believe is still the same as 6) for grainy sources? I know it tends to increase bitrates, but I thought that was due to it better preserving details, and could be offset via adjusting other settings if one thought it was bloating the encode too much.

I thought --rd 6 was actually a recommended setting for grainy encodes, though that may have been from much older posts I've read from a time when x265 grain preservation was more of a challenge. If the thinking has changed on that more recently, I'd be interested to hear it because I've not seen any other discussions saying that.

HD MOVIE SOURCE
7th August 2022, 20:05
Some things that can help:

Higher --psy-rd and --psy-rdoq
Not using --rd 6 (on by default in slower-placebo)
Using --rskip 2 instead of 1
Reducing --pbratio


Just wondering, skip=0, skip=1 and skip=2 could you tell the effects on an encode please? Also, exactly the impacts on grain. I'm not so much interested in efficiency, more on absolute quality of the grain.

benwaggoner
9th August 2022, 18:03
interesting, just tired rskip 2 and I got a 2x speed increase for a medium grainy UHD source at preset slow. I dont think it helped much with the grain though, and it displayed a bit more blocking, but that speed increase just seems insane. I couldnt tell the encodes apart from normal viewing. Is that to be expected? Seems unreasonable.
To trade some of that speed improvement for better quality, try lowering --rskip-edge-threshold to 2 or 3.

A simple check to see if tuning --rskip would matter would be to compare current encodes versus one with --rskip 0. If --rskip 0 doesn't look any better, you're not going to see quality gains by tweaking it, and it's more a matter of finding the fastest values that don't hurt quality.

--tune grain sets --rskip 0, as --rskip 2 wasn't available when it was implemented, which is a big reason why it is so darn slow.

benwaggoner
9th August 2022, 18:06
What's the thinking behind not using --rd 6 (or 5, which I believe is still the same as 6) for grainy sources? I know it tends to increase bitrates, but I thought that was due to it better preserving details, and could be offset via adjusting other settings if one thought it was bloating the encode too much.

I thought --rd 6 was actually a recommended setting for grainy encodes, though that may have been from much older posts I've read from a time when x265 grain preservation was more of a challenge. If the thinking has changed on that more recently, I'd be interested to hear it because I've not seen any other discussions saying that.
For grainy content at UHD resolutions, I've often seen --rd 6 look quite a bit worse than --rd 4. And lowering it gives some speed back that could be used for more fruitful optimizations.

I've not see --rd 4 better than --rd 6 at lower resolutions; certainly not below 1080p. I'm guessing that something about --rd 6 was tuned for lower resolutions that doesn't scale well above 1080p for some reason.

benwaggoner
9th August 2022, 18:12
Just wondering, skip=0, skip=1 and skip=2 could you tell the effects on an encode please? Also, exactly the impacts on grain. I'm not so much interested in efficiency, more on absolute quality of the grain.
--rskip 0 will never look worse than other modes AFAIK. I don't know of cases when --rskip 1 is better than --rskip 2 with an appropriate threshold, but I have not looked exhaustively.

Really, --rskip is an early-exit type performance optimization feature like --limit-tu, --early-skip, --limit-modes, --limit-refs etcetera. Using those modes never improves quality, but can improve speed a lot relative to minor quality reductions.

--rd 4 versus --rd 6 was a surprising exception to the general rule of quality versus encode speed having slower>=faster. Even esoteric performance-sapping options not included in --preset placebo like --cu-lossless shouldn't ever hurt quality, even if it almost never helps it with typical content and bitrates.

HD MOVIE SOURCE
14th August 2022, 04:41
--rskip 0 will never look worse than other modes AFAIK. I don't know of cases when --rskip 1 is better than --rskip 2 with an appropriate threshold, but I have not looked exhaustively.

Really, --rskip is an early-exit type performance optimization feature like --limit-tu, --early-skip, --limit-modes, --limit-refs etcetera. Using those modes never improves quality, but can improve speed a lot relative to minor quality reductions.

--rd 4 versus --rd 6 was a surprising exception to the general rule of quality versus encode speed having slower>=faster. Even esoteric performance-sapping options not included in --preset placebo like --cu-lossless shouldn't ever hurt quality, even if it almost never helps it with typical content and bitrates.

Interesting, thanks. I assume if you are using presets like slow, slower or very slow, you have to specifically tell the encoder to use rskip, limit-tu, early-skip, limit-modes, limit-refs because those presets would turn them off? I'm sure right now without looking when those modes get effected by the encoder presets.

I was testing manually turning them off but encoding takes so long when all the skips are turned off or most of them. If they are generally not worth it, I won't specify it in the encoder settings anymore. I'll just let the preset take care of it.

benwaggoner
15th August 2022, 21:29
Interesting, thanks. I assume if you are using presets like slow, slower or very slow, you have to specifically tell the encoder to use rskip, limit-tu, early-skip, limit-modes, limit-refs because those presets would turn them off? I'm sure right now without looking when those modes get effected by the encoder presets.

I was testing manually turning them off but encoding takes so long when all the skips are turned off or most of them. If they are generally not worth it, I won't specify it in the encoder settings anymore. I'll just let the preset take care of it.
If you use x265 without any presets, it'll follow the defaults for any parameter not otherwise specified. Those are pretty close to --preset medium, but there may be exceptions.

If you use x265 with a preset, it'll set the parameters as specified in the preset for anything not otherwise specified. But specific parameters set in the command line will always override x265 defaults or preset defaults.

Here's the handy dandy table: https://x265.readthedocs.io/en/master/presets.html