Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x265: don't apply tune by default #1423

Open
0n-s opened this issue Dec 14, 2024 · 2 comments
Open

x265: don't apply tune by default #1423

0n-s opened this issue Dec 14, 2024 · 2 comments

Comments

@0n-s
Copy link

0n-s commented Dec 14, 2024

x265 tunes are intended for specific types of content or objectives (e.g. the specific characteristics of animations or better scores on metrics). They are not general purpose & should only be explicitly applied by the user. The only sane default tune is no tune.

In particular, the ssim tune libheif defaults to completely disables psychovisual RD which harms perceptual fidelity in favor of better SSIM scores.

@bradh
Copy link
Contributor

bradh commented Dec 14, 2024

Like my other comment (on #1424), do you have metrics on single image vs image sequence? It might (or might not) be a breaking change to adjust defaults at the library level, but we could provide alternative tuning suggestions in documentation or in the example applications.

@0n-s
Copy link
Author

0n-s commented Dec 15, 2024

Frankly, I find it preposterous that the burden of proof is on me to show that the default settings of x265 are generally better than the almost certainly mindless, or at least misguided, non-default x265 tuning of libheif (please do not impulsively reply to this characterization before reading the quote at the very end of my comment). But it's easy enough, so here's 2 samples (video & still). I didn't do it with libheif since I can't figure out how to disable the tune parameter entirely there, so it's all with FFmpeg, plus additional parameters to match libheif's other settings. The only difference is the lack of a container format, really.

Here's a sample of ParkJoy (available here). In order: -tune ssim, & without -tune ssim; all other parameters are equivalent.

ssim.mp4
normal.mp4

Notice the bark of the trees in the foreground, the grass, & the trees in the background, which all look much more blurry with -tune ssim.

Sizes for these:

1788K normal.h265
1764K ssim.h265

I tried to match the bitrate as much as I could for those.

Here's 10164842933.jpg from the KonIQ-10k IQA database, decoded to PNG. Again, first -tune ssim, then without -tune ssim, but all other settings are the same.

ssim
normal

Here, notice the bottom left, & the bottom right, both of which are lower quality & smoothed out with -tune ssim.

Sizes for these:

104K normal.h265
 96K ssim.h265

This was encoded a bit differently from the above because instead of trying to match bitrates, I tried to match quality (as in -q to heif-enc).

These results are to be expected, really. I mentioned in the OP that the only sane default tune is no tune, & that's not my specific opinion, that's just the conclusion one comes to from x265's docs on them:

The psnr and ssim tune options disable all optimizations that sacrafice metric scores for perceived visual quality (also known as psycho-visual optimizations). By default x265 always tunes for highest perceived visual quality but if one intends to measure an encode using PSNR or SSIM for the purpose of benchmarking, we highly recommend you configure x265 to tune for that particular metric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants