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 > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th March 2021, 21:47   #1  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Modern x265 grain tuning

--tune grain has been around for years now, and is rather a blunderbuss, mainly turning off cu-size recursion and yield a near-constant QP within and between frames. It works for heavy film grain, but really reduces compression efficiency for clean content, and some for light grain. The performance hit of turning off rskip is also substantial.

Since --tune grain was introduced, default x265 is a lot better at light-moderate grain. And we've got newer tools that seem like they should help us to better tune for quality and performance with moderately grainy content. In particular:
--rskip now has a mode 2 based on CU edge density, and with that we have
--rskip-edge-threshold to set what the recursion threshold should be

Has anyone played around with those?

Beyond that, I think --rdoq 20 and --psy-rd 4.0 are likely higher than needed these days.

What tweaks are people using for grainy sources these days?
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 15th March 2021, 22:07   #2  |  Link
quietvoid
Registered User
 
Join Date: Jan 2019
Location: Canada
Posts: 570
Quote:
Beyond that, I think --rdoq 20 and --psy-rd 4.0 are likely higher than needed these days.
What tweaks are people using for grainy sources these days?
I'm pretty sure some people are still using --psy-rdoq 50.0 and --psy-rd 5.0 for UHD BD authoring with x265.
Maybe it was a one-off though..

What I know is that disabling strong intra smoothing is often useful for larger grain.
__________________
LG C2 OLED | GitHub Projects
quietvoid is offline   Reply With Quote
Old 15th March 2021, 22:36   #3  |  Link
rwill
Registered User
 
Join Date: Dec 2013
Posts: 343
Strong intra smoothing is just smoothing the prediction pels at the border of a CU from which the prediction is formed, its better left ON than to have some sharp angular prediction details across a whole CU which then have to be removed by the residual.

What wonders me is that the last x265 versions I tried had SAO badly broken and introducing blocks in slight gradients overlayed with grain. I do not get why the wont fix that. Its probably been in there for years.
rwill is offline   Reply With Quote
Old 15th March 2021, 23:10   #4  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by quietvoid View Post
I'm pretty sure some people are still using --psy-rdoq 50.0 and --psy-rd 5.0 for UHD BD authoring with x265.
Maybe it was a one-off though..
UHD BD also can have crazy high bitrates, so --tune grain is perfectly reasonable. Peak Bitrate is 80 Mbps IIRC. And the lowest disc size is 50 GB, which offers a lot of ABR even for long movies.

Of course, UHD resolution masters, especially remasters, often have way more visible grain than the original creatives ever would have seen on a perf screen. Super 35mm movies can look like 720p upsampled to 2160p and then a jacked-up film grain effect applied.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 16th March 2021, 05:41   #5  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
I use --psy-rd 4.0 --psy-rdoq 15 -qcomp 0.7 --rskip 2 --rskip-edge-threshold 0.2 --strong-intra-smoothing for both clean and noisy content. Am very happy with these settings for both types of content. I only encode FHD, though. UHD on my fastest PC is too slow to encode
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 16th March 2021, 23:44   #6  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by microchip8 View Post
I use --psy-rd 4.0 --psy-rdoq 15 -qcomp 0.7 --rskip 2 --rskip-edge-threshold 0.2 --strong-intra-smoothing for both clean and noisy content. Am very happy with these settings for both types of content. I only encode FHD, though. UHD on my fastest PC is too slow to encode
Thanks for the tip!

What bitrates are you targeting/getting with what CRF?
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 17th March 2021, 06:07   #7  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
Quote:
Originally Posted by benwaggoner View Post
Thanks for the tip!

What bitrates are you targeting/getting with what CRF?
I always use CRF 21. For clean sources, between 3000 and 6000 kbps. For noisy ones, depends on how noisy they are but bitrate can shootup to 12,000 kbps. Most of the time it's usually less

I've also disabled SAO and lowered deblocking strength to -4,-4. HME is turned on as well (umh,umh,star). Can't virtually never tell a difference between original and the encode

The reason I upped --psy-rd and --psy-rdoq is that at low values, I was able to spot halo's in dark scenes when encoding Blade Runner 2049 which is pretty clean with little mosquito noise. Increasing these values made the problem go away and I stuck at using them
__________________
ffx264 || ffhevc || ffxvid || microenc

Last edited by microchip8; 17th March 2021 at 06:15.
microchip8 is offline   Reply With Quote
Old 17th March 2021, 08:00   #8  |  Link
ShortKatz
Registered User
 
Join Date: Aug 2018
Location: Germany
Posts: 118
I also use --rskip 2 for my UHD encodes. But I have --rskip-edge-threshold at the default, because I'm unsure how to tune this setting. And you do not find much information about --rskip-edge-threshold in the internet.
ShortKatz is offline   Reply With Quote
Old 17th March 2021, 09:10   #9  |  Link
olle83
Registered User
 
Join Date: Mar 2021
Posts: 6
Wow, you guys are using high psy-values.
I noticed that high psy-setting make grain look sharp and annoying to me, it gets amplified. Lower settings keep it looking natural.

I'm just using this type of settings:
Code:
--crf 21.3 --input-res 1664x936 --fps 24000/1001 --frames 12345 --frame-threads 2 --preset slower --ref 6 --ctu 32 --rd 3 --limit-refs 3 --limit-tu 0 --deblock -3:-3 --keyint 360 --min-keyint 24 --merange 26 --no-sao --psy-rd 2.0 --psy-rdoq 1.2 --rc-lookahead 60 --aq-mode 3 --aq-strength 0.85 --no-cutree --qcomp 0.65 --cbqpoffs -1 --crqpoffs -1 --range limited --colorprim 1 --transfer 1 --colormatrix 1 --output-depth 10 --profile main10 --level-idc 5.0 --high-tier --no-open-gop --repeat-headers --aud --hrd
I modify aq-strength according to how much grain source has. If there's little or none I increase it and if there's huge amounts I decrease it.

I'm using 10 bit even for 8 bits sources too.
olle83 is offline   Reply With Quote
Old 17th March 2021, 17:06   #10  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by microchip8 View Post
I always use CRF 21. For clean sources, between 3000 and 6000 kbps. For noisy ones, depends on how noisy they are but bitrate can shootup to 12,000 kbps. Most of the time it's usually less

I've also disabled SAO and lowered deblocking strength to -4,-4. HME is turned on as well (umh,umh,star). Can't virtually never tell a difference between original and the encode

The reason I upped --psy-rd and --psy-rdoq is that at low values, I was able to spot halo's in dark scenes when encoding Blade Runner 2049 which is pretty clean with little mosquito noise. Increasing these values made the problem go away and I stuck at using them
Are you encoding from 10-bit or 8-bit, and to 10-bit or 8-bit?
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 17th March 2021, 17:15   #11  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
Quote:
Originally Posted by benwaggoner View Post
Are you encoding from 10-bit or 8-bit, and to 10-bit or 8-bit?
I encode 8 bit input to 10 bit HEVC/x265
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 17th March 2021, 17:17   #12  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
Quote:
Originally Posted by ShortKatz View Post
I also use --rskip 2 for my UHD encodes. But I have --rskip-edge-threshold at the default, because I'm unsure how to tune this setting. And you do not find much information about --rskip-edge-threshold in the internet.
The lower, the higher precision/quality and vice versa
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 18th March 2021, 05:48   #13  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 328
If we want to find out if it's improved, wouldn't encoding Alien be the best test? I remember previously someone attempted to do it and the result was that the encode came out larger than the original. I do not own the movie, so I personally am not able to do this.
RanmaCanada is offline   Reply With Quote
Old 20th March 2021, 00:04   #14  |  Link
ShortKatz
Registered User
 
Join Date: Aug 2018
Location: Germany
Posts: 118
Quote:
Originally Posted by microchip8 View Post
The lower, the higher precision/quality and vice versa
Thanks. The documentation tells the default is 5. But according to the log, the default is set to "rskip-edge-threshold=0.05". This is kind of confusing. So, this means your 0.2 translates to 20?
ShortKatz is offline   Reply With Quote
Old 20th March 2021, 06:18   #15  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,843
Quote:
Originally Posted by ShortKatz View Post
Thanks. The documentation tells the default is 5. But according to the log, the default is set to "rskip-edge-threshold=0.05". This is kind of confusing. So, this means your 0.2 translates to 20?
No, it translates to 2. I wrote 0.2 by mistake. Should be 0.02
__________________
ffx264 || ffhevc || ffxvid || microenc

Last edited by microchip8; 20th March 2021 at 06:20.
microchip8 is offline   Reply With Quote
Old 20th March 2021, 09:31   #16  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,718
Quote:
Originally Posted by RanmaCanada View Post
If we want to find out if it's improved, wouldn't encoding Alien be the best test? I remember previously someone attempted to do it and the result was that the encode came out larger than the original. I do not own the movie, so I personally am not able to do this.
Alien is a very good sample, also many of the old b/w movies are really hard for the encoder. Crisp image and lots of sharp grain. The Bridge on the River Kwai (4K) is also a very tough one.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 24th March 2021, 14:19   #17  |  Link
ReinerSchweinlin
Registered User
 
Join Date: Oct 2001
Posts: 454
Quote:
Originally Posted by Boulder View Post
Alien is a very good sample, also many of the old b/w movies are really hard for the encoder. Crisp image and lots of sharp grain. The Bridge on the River Kwai (4K) is also a very tough one.
Stanley Cubrik used to work with very hig ISO Films in order to capture the "natural look of low ambient lighting" in some scenes, resulting in a lot of grain in darker scenes. I can imagine these movies could be a good test-source, too.
ReinerSchweinlin 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:43.


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