Closed miloxeon closed 1 month ago
AVIF compression is relatively slow and more memory-intensive compared with most other formats. The performance can also vary depending on the input image, see for example: https://github.com/libvips/libvips/issues/2983
Additionally, libvips only emits the "eval" signal (on which the image.onProgress
callback depends) once per work unit during image computation. Since AVIF does not support streaming/chunk-wise encoding, libvips must assemble the entire image in memory before passing it to the AVIF encoder. Consequently, there's no progress feedback during this final compression stage, as libvips considers the computation complete once it reaches this point.
Note that you can control the CPU effort spent on improving AVIF output by passing the effort
argument:
https://github.com/kleisauke/wasm-vips/blob/4702f7df3feeed3efcc07e904de2557a330fce18/lib/vips.d.ts#L7178-L7181
It defaults to 4
; lowering it to 0
will significantly speed up encoding (but will result in larger file sizes).
wow, it indeed speeds things up. Didn't know about the AVIF situation. Thanks!
Hi again!
In this playground demo, progress tracked using onProgress goes to 100% very quickly, but the lag after that takes way longer, making the tracking near useless. How do I track progress accurately?