← back to roto on ba3a.dev

WebpTiming

object WebpTiming

Corrects the timing of an animated WebP as ffmpeg writes it: every frame duration is right except the last one's. Works on the RIFF bytes alone, so no picture data is decoded or rewritten.

Functions

Link copied to clipboard
fun withTotal(webp: ByteArray, totalMs: Long): ByteArray

A copy of webp whose last ANMF frame lasts totalMs less the durations of the frames before it. A still WebP, with no ANMF chunk, comes back unchanged. Bytes that are not a whole WebP file, or a last duration outside 1 to 16777215 ms, are refused with an IllegalArgumentException.