knah / VRCMods

A collection of various VRChat mods aimed at improving user experience or fixing issues
GNU General Public License v3.0
245 stars 137 forks source link

[Lag Free Screenshots] Add WebP Support #231

Open Zexxx opened 2 years ago

Zexxx commented 2 years ago

WebP has way faster compression algorithm along with much smaller file size compared to png. With encoding being faster this could help reduce the lag during the screenshot process.

dakyneko commented 2 years ago

I've implemented this but @knah rejected the idea we would depend on other library like libwebp. I asked already 6 months ago and recently but same answer. So either I'll publish my own fork or he will accept a PR, who knows ;)

Also that claim about encoding being faster is not true, it's slower than both png and jpeg in my benchmark even as I'm using the method = 0 which is the fastest. That said I still think that cons is shadowed by the pros of webp.

Zexxx commented 2 years ago

That's odd that it's slower for you, maybe i should test it properly and not just use cwebp as a mini test. Although i would be very interested in it regardless if its slower than png for those benefits of significantly lower sizes. I had a png straight from in game at 16k come in at 192mb when converted to 66mb. Altho please do make that fork!

dakyneko commented 2 years ago

Altho please do make that fork!

We'll see if @knah is wiling to react. If not I could make a fork but beware that maintaining fork is effort. Tho it's true LFS itself didn't change much over time. I could consider making a fork if more people are interesting :thinking: I do have an open PR which improves speed by a lot https://github.com/knah/VRCMods/pull/226 (still not merged), so yeah. I could ask to maintain the package at this point maybe :P I would be more active.

That's odd that it's slower for you, maybe i should test it properly and not just use cwebp as a mini test.

I'm not sure how you bench or where you saw that webp compression speed would be faster. In my experience and sources like: https://groups.google.com/a/webmproject.org/g/webp-discuss/c/mu1RYRAe72A?pli=1 or https://siipo.la/blog/whats-the-best-lossless-image-format-comparing-png-webp-avif-and-jpeg-xl they all agree encoding is slower. I didn't see anything to the contrary. But:

The results look promising on the compression side (up to 50% on some images), however encoding times are very slow - x5 slower on lossy, x10 for lossless compression.

That's not unusual ratio, indeed.

what's faster is the decompression: because of smaller size AFAIK https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study

Decoding speeds faster than PNG have been demonstrated, as well as 23% denser compression than what can be achieved using today's PNG format. We conclude that WebP is a more efficient replacement for today's PNG image format.

That said, it's possible the IO is the bottleneck (esp with hard drives) to write the files down with huge size like ~200MB. Tho that isn't the subject of the bench above. Not sure if that's what you saw? In my testing I have m2 ssd so no bottleneck there.

dakyneko commented 2 years ago

As you know with EAC thing, this won't happen. But if you're interested: I ported lfs to cvr and I added webp support too.