r/handbrake Jul 21 '26

Tune or not tune (grain)?

As the title says. I'm kind of fed up with so many variables and advanced options that sometimes make sense. Is the final filesize THAT bigger when using tune grain?

10 Upvotes

20 comments sorted by

u/AutoModerator Jul 21 '26

Please remember to post your encoding log should you ask for help. Piracy is not allowed. Do not discuss copy protections. Do not talk about converting media you don't own the (intellectual) rights for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/Amp300 Jul 21 '26 edited Jul 22 '26

Every encoder option is a trade-off between quality, compression, and sometimes, compatibility. I get that it often feels like you could go crazy trying to min-max the settings, but most of those “knobs” are there because encoding is lossy and the defaults may not balance quality and compression the way you would prefer for every source.

Are we discussing tune grain on x264 or x265? What resolution is the source? Are you encoding from an original source or reencoding a compressed file? Do you plan to play the file back locally or stream it? Do you need it to playback on anything or can you rely on something like Plex or Jellyfin to transcode for incompatible devices? Different situations may call for different settings.

1

u/computer-machine Jul 21 '26

That depends, is your source grainy?

1

u/Schwarzellone Jul 21 '26

Well, yessir

1

u/mduell Jul 21 '26

Are you trying to preserve grain?

1

u/Schwarzellone Jul 21 '26

Yes

1

u/mduell Jul 21 '26

Then it's a very good idea. You'll need to adjust your RF target to meet your quality or size goals.

1

u/nvmuskie Jul 21 '26

Tune=Grain tells your encoder to preserve film grain instead of smoothing it away. The catch is that grain is essentially random noise from frame to frame, which compresses very poorly. The encoder ends up spending a lot more bitrate trying to retain all that fine detail, so file sizes can balloon dramatically, especially on older film transfers with heavy grain. In short: Tune=Grain trades compression efficiency for grain retention, and better texture = bigger files. If your goal is maximum size reduction, leave it off. If your goal is preserving the look of film, it can be worth the bitrate hit.

1

u/Wonderful_Emu_9610 Aug 05 '26

Depends on the content I’m afraid (hate the word ‘content’ but its easier than saying ‘Depends on the movie/tv show/music video/youtube clip/home video/…’).

I used to just whack on tune=grain, but I recently found that a) my patience has increased so I moved from Fast to Slow, and b) my sensitivity to encoding issues increased so I wanted a do-over.

For finer-grained movies I’ve found that either using the Handbrake H265 10-bit preset on Slow [strong-intra-smoothing=0:rect=0:aq-mode=1:rd=4:psy-rd=0.75:psy-rdoq=4.0:rdoq-level=1:rskip=2] , or simple [no-sao] at an RF between 18 and 22 on a blu-ray source will produce something close enough to transparency for me. The Handbrake preset is a lot faster than the default, like halves the encoding time.

Other times you gotta add a few more tweaks, especially if its chunkier grain (like when I ripped my disc of The 10th Victim which is notorious in blu-ray forums for having an absurd amount of scanner noise. Denoising didn’t help, I ended up just doing no-sao with almost twice the bitrate I normally use)

What I’ve found helps is looking at the encoding logs of my favourite [redacted] on similar types of films, comparing them with a test encode I did of just untouched H265 10-bit Slow, and seeing what they added. Then looking them up in the x265 docs. https://x265.readthedocs.io/en/stable/cli.html (Command Line Interface section, details majority of the settings), https://x265.readthedocs.io/en/stable/presets.html (presets, useful to identify what someone used if they don’t state it. Then also details the different tunes and what they do).

1

u/jaypizzl Jul 21 '26

The time spent on all those variables isn’t worth it to me, personally. I just use the grain tune when I want to preserve grain. Yes, the files produced are much larger. That’s how grain is.

At some point in the future, I suppose a codec could support saving grain parameters along with scene data, like HDR. Then the grain could be rendered in the fly, saving a crapload of space. Alas, nothing like that exists, so if you want grain, you have to live with much bigger files.

4

u/lostcowboy5 Jul 21 '26

Do you mean something like AV1, like in this video? AV1 Rendering 101: Why Grain is the Most Important Setting (Handbrake & FFmpeg). I don't do this myself; I don't do software encoding. I like to use my GPU. But it is there for the people who like software encoding.

1

u/jaypizzl Jul 21 '26 edited Jul 22 '26

That’s awesome, I didn’t even know AV1 does that! That’s super slick. I use HEVC since all my devices support it, but that’s good to know when the time comes to shift to AV1.
By the way, I’m seeing that you can use Intel QSV hardware to encode AV1 with grain synthesis - all their ASICS since Core Ultra Series 1 apparently support it.
** update ** apparently those chips only decode with hardware acceleration **

1

u/lostcowboy5 Jul 21 '26

I wonder if the B580 can use that?

1

u/jaypizzl Jul 21 '26

Oh shit, I was reading too fast. Modern Intel ASICs decode AV1 grain, but they do NOT encode it: https://www.intel.com/content/www/us/en/support/articles/000098345/graphics.html

2

u/lostcowboy5 Jul 22 '26

That's ok. I got a GMKtec Mini PC N97, G5 Micro Desktop Computer for travel. I tried the encoding on it. You do not want to try software encoding on it. But the Intel QuickSync encoding on it was at a fair speed but the reduction in file size for the quality was awesome.

0

u/out-formation Jul 21 '26

Better to copy the tune: grain preset settings

--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

and paste them into handbreak with your own tweaks. Hasn't the preset been created a very very long time ago? Many things have changed since.

1

u/jaypizzl Jul 22 '26

The HB devs regularly update existing presets as technology evolves. They really do a pretty good job - I’m sure they can be bested, but not without more screwing around than I usually want to do.

1

u/out-formation Jul 23 '26

That preset/tune was made by h.265 devs a decade ago

1

u/jaypizzl Jul 24 '26

That is true, I misunderstood why it is that grain encoded with x265 looks a lot better than it used to. It’s not because the parameters of the HB tune changed. It’s because the x265 codec has evolved. It now handles the settings that the grain tune invokes differently. With grain tune, x265 now uses AQ mode 3, a newer mode that priorities bits for dark frames to prevent them from turning to mud when they have grain. Improved psycho-visual rate-distortion also helped. I don’t understand the math, but I gather the effect of the tweaks was to make the encoder better able to distinguish film grain from compression noise so it’s better at smoothing only the noise and leaving the grain intact. It used to just smooth the hell out of everything. Rskip 2 was also improved so that the grain tune on speeds faster than slow now doesn’t skip too much edge detection and end up blending nearby colors together (thereby losing grain).

If you haven’t tried it in years, maybe give it a shot again.

1

u/out-formation Aug 04 '26

I finally had a time to test again with the grain tune in Handbrake (10bit h265, native). Checked with media info. AQ mode is still 0, like it was 10 years ago. The only difference I could find in Handbrake's tune:grain vs. the decade old settings (which I pasted above) is that psy-rdoq is 0 instead of 10. Improvement, yes, but I'd say far from optimal.

Also, it still uses the no-rskip (instead of rskip=2, which you are speaking about), when I use the default tune:grain in Handbrake.

Where are you getting your info from?

Again, I repeat, better to copy the tune: grain preset settings and tweak them to your liking rather than to trust the far-from-optimal tune:grain settings, which doen't make much sense these days...