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

[Feature request] Add support for JPEG XL screenshots due to greater speed and compression #1525

Open
0fbcb238c0 opened this issue Sep 15, 2024 · 1 comment

Comments

@0fbcb238c0
Copy link

gamescope will currently always save screenshots as lossless AVIF.
While AVIF has support for HDR and mostly offers better compression than PNG, it is soundly beaten by JPEG XL (JXL) in terms of speed AND compression while also supporting HDR.

To quantify this I created two datasets and encoded them losslessly to AVIF and JXL.
First set: 560 PNG screenshots, 1920x1080, sourced from over 60 games, 1182MB in size
Second set: 1300 PNG screenshots, 3840x2160, sourced from over 80 games, 13421MB in size

Encoding

Used were the latest releases of the reference encoders, v0.11.0 for libjxl and v1.1.1 for libavif.
Since gamescope uses AVIF_SPEED_FASTEST, which is 10, I used the fastest settings with no additional parameters for both encoders.
Since writing to disk always adds a delay I also measured the encoding time if written to /tmp, a RAM disk, same as gamescope's default behaviour.
I repeated each encode ten times, five for SSD, five for RAM and averaged the encoding times.

The commands to encode:
AVIF: /usr/bin/time -f "%E seconds" parallel -j 16 /usr/bin/avifenc -l --speed 10 {} DEST ::: *.png
JXL: /usr/bin/time -f "%E seconds" parallel -j 16 /usr/bin/cjxl -d 0 --effort 1 {} DEST ::: *.png

Encoding results 1920x1080

AVIF:
Encoding time SSD:      09.30 seconds
Encoding time RAM:      09.33 seconds
Compressed size:        1285MB
Size change in Percent: +8.71 %

JXL:
Encoding time SSD:      02.40 seconds
Encoding time RAM:      01.73 seconds
Compressed size:        1088MB
Size change in Percent: -7.95 %

JXL, e2, second fastest setting:
Encoding time SSD:      15.20 seconds
Encoding time RAM:      14.16 seconds
Compressed size:        1012MB
Size change in Percent: -14,38 %

Encoding results 3840x2160

AVIF:
Encoding time SSD:      102.2 seconds
Encoding time RAM:      101.4 seconds
Compressed size:        13334MB
Size change in Percent: -0.65 %

JXL:
Encoding time SSD:      38.80 seconds
Encoding time RAM:      22.15 seconds
Compressed size:        12558MB
Size change in Percent: -6,43 %
@jonnyawsom3
Copy link

The poor performance of lossless AVIF has been known for years. I'm surprised it was added at all, yet alone made the only option.
AOMediaCodec/av1-avif#111

In an ideal scenario there could be JXL compression with adjustable speed and/or quality, since it excels at the high range wanted for screenshots and photos, especially in HDR.

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