jnordberg / gif.js

JavaScript GIF encoding library
http://jnordberg.github.io/gif.js/
MIT License
4.76k stars 668 forks source link

compute deltas between frames #7

Open leeoniya opened 11 years ago

leeoniya commented 11 years ago

if you look at http://i.imgur.com/wypWt11.gif in GIMP you'll see why it fits into 3.95k, each frame is a delta from the previous frame.

i did a screen record with lossless codec at 60fps, compressed with gifsicle, which computed the background, frame deltas and i think also removed identical frames (which may be fast to identify with a hash or similar) or maybe it merged identical frames into longer-delayed single frames.

the original image size was tiny, each square block is a pixel. so if #2 is addressed, this would probably scale & encode in a < 100ms.

leeoniya commented 11 years ago

for image diffs, there's https://github.com/HumbleSoftware/js-imagediff/ but by the looks of https://github.com/HumbleSoftware/js-imagediff/blob/master/js/imagediff.js#L166, it doesn't use typed arrays and compares at the sub-pixel level. i would be tempted to rewrite it for a considerable speed boost.

jnordberg commented 11 years ago

That's really cool. It might also be possible to port or gificles optimizer to js, or compile it with emscripten

https://github.com/kohler/gifsicle

leeoniya commented 11 years ago

feel free to draw inspiration from my fresh-from-the-oven implementation based on the omggif encoder

https://github.com/leeoniya/GIFter.js

cheers!

EDIT my lib still places full-size frames (w/ transparency fill), I'll add logic in a couple days to return cropped frames w/offsets from the diff algo...

am9x commented 7 years ago

Hi leeoniya , you did the great tool, is there any solution for this issue?tks

Dylan-Chapman commented 7 years ago

+1 Image file sizes are really large with gif.js by default