Live data from Hacker News

High quality GIF with FFmpeg

blog.pkh.me

21–30 of 131 posts

Re: High quality GIF with FFmpeg

#21
post #15

I use this shell script for generating gifs out of .mov files: https://gist.github.com/artursapek/5b3d15ecac5ff75593c4 I can probably improve it further by using some of what's in this article, but it's already faster and better than any online tool I've found.

> (convert -delay 5 -loop 0 $tmp_dir/ffout*.png $2) >& /dev/null So using ImageMagick for this... How is this memory wise BTW? (all frames are in memory at once or not?)

Not sure, actually. Never had it be enough of a resource hog to even think about it.

Re: High quality GIF with FFmpeg

#22

ffmpeg is downright magical - just don't get caught using the one in the Ubuntu/Debian repositories. Compile your own ffmpeg if you have any need to do serious work; the Libav fork just isn't as capable. The reasons are obvious if you look into the development philosophies of the two projects. https://github.com/mpv-player/mpv/wiki/FFmpeg-versus-Libav

I think that ffmpeg is returning in Ubuntu 15 http://www.webupd8.org/2014/11/ffmpeg-returns-to-official-ub...

Actually in Debian as well.

Re: High quality GIF with FFmpeg

#23
post #9

I use this shell script for generating gifs out of .mov files: https://gist.github.com/artursapek/5b3d15ecac5ff75593c4 I can probably improve it further by using some of what's in this article, but it's already faster and better than any online tool I've found.

You can pipe the frames from FFmpeg to convert to avoid temporary files. http://superuser.com/a/730389

Neat! Unix pipes are amazing. Thanks.

Re: High quality GIF with FFmpeg

#24

And to complete the circle, run the gif through Gfycat and check out the mindblowing bandwidth savings: http://gfycat.com/IllustriousHairyGermanpinscher GIF: 1 MB Video: 73k

> GIF: 1 MB

> Video: 73k

Yes, but with some loss of quality http://imgur.com/1qkJYEA

(not as much as I thought, though)

Re: High quality GIF with FFmpeg

#25

And to complete the circle, run the gif through Gfycat and check out the mindblowing bandwidth savings: http://gfycat.com/IllustriousHairyGermanpinscher GIF: 1 MB Video: 73k

Yes please. Let's leave GIF in the 20th Century, where it belongs.

is it possible to have pixel-perfect animations (avoid compression artifacts completely) while using h.264 or VP8 and still get good filesize?

also, what about alpha transparency? video formats do not have this. GIF is shitty for video clips, but it's not without uses. it just needs to be replaced by APNG [1].

[1] http://en.wikipedia.org/wiki/APNG

Re: High quality GIF with FFmpeg

#26

So it's using a simple Median Cut quantization... which is okay, but you can get great results using an octree quantizer, and without dithering. Dithering kills your compression savings in GIF so you'd want to avoid it if possible. In any case, you can see the difference a better quantizer makes here: http://www.leptonica.com/color-quantization.html

here's how my quantizer does: full-color, undithered, floyed-dithered: http://imgur.com/a/lrLTd#0 repo: https://github.com/leeoniya/RgbQuant.js demos: http://o-0.me/RgbQuant/ this image is actually a pretty poor example of quantization, it's too easy. full color gradients give a much better indicator of behavior, quality and performance. if you really are interested in different algorithms, check this out: http://www…

That is pretty amazing, thanks for sharing. I am interested in different quantization methods, if only for screenshot usage ( I am working on a remote control product, and the quantization used to be quite poor before I added in octree ). Of course, most of my code is in C# but I can at least take a look at the algorithms, and if they are MIT licensed, I can see what it would take to convert them.

Re: High quality GIF with FFmpeg

#27
I wanted to use FFmpeg in an iOS app, but I ran into licensing issues—the FFmpeg wrapper [1] and FFmpeg itself [2] are both LGPL 2.1, which I didn't think you could use in an iOS app.

Since this project does exactly that, I took a second look and found a discussion on that specific use case [3]. It didn't quite clarify things, but it looks like it _might_ be legal to use FFmpeg in an app.

[1] https://github.com/OpenWatch/FFmpegWrapper [2] https://www.ffmpeg.org/legal.html [3] https://trac.ffmpeg.org/ticket/1229

Re: High quality GIF with FFmpeg

#28
post #18

And to complete the circle, run the gif through Gfycat and check out the mindblowing bandwidth savings: http://gfycat.com/IllustriousHairyGermanpinscher GIF: 1 MB Video: 73k

I like to imagine going back in time to 2005-06 and telling myself "You know what's going to come back in a big way? Animated GIFs!" I wouldn't believe myself whatsoever.

I would like to go back in time to 1993 and make Tim Berners-Lee add video support to the element so that we could do things like this today:

  
If this had happened no one would need to use GIFs. :(

Re: High quality GIF with FFmpeg

#29

Earlier quoted context omitted.

here's how my quantizer does: full-color, undithered, floyed-dithered: http://imgur.com/a/lrLTd#0 repo: https://github.com/leeoniya/RgbQuant.js demos: http://o-0.me/RgbQuant/ this image is actually a pretty poor example of quantization, it's too easy. full color gradients give a much better indicator of behavior, quality and performance. if you really are interested in different algorithms, check this out: http://www…

That is pretty amazing, thanks for sharing. I am interested in different quantization methods, if only for screenshot usage ( I am working on a remote control product, and the quantization used to be quite poor before I added in octree ). Of course, most of my code is in C# but I can at least take a look at the algorithms, and if they are MIT licensed, I can see what it would take to convert them.

nQuant is a quantizer in C#, Apache licensed

http://nquant.codeplex.com/

Re: High quality GIF with FFmpeg

#30
post #29

Earlier quoted context omitted.

That is pretty amazing, thanks for sharing. I am interested in different quantization methods, if only for screenshot usage ( I am working on a remote control product, and the quantization used to be quite poor before I added in octree ). Of course, most of my code is in C# but I can at least take a look at the algorithms, and if they are MIT licensed, I can see what it would take to convert them.

nQuant is a quantizer in C#, Apache licensed http://nquant.codeplex.com/

Wu v2 is probably the best hands-off quantizer that I have seen. It's not the fastest and probably too resource intensive for embedded apps, but it is remarkably good. I would recommend it (or anything based on it) without hesitation.

I'm actually in the process of porting it to js using typed arrays and possibly WebGL/GLSL. You can compile it pretty easily to asm.js for max pure-js perf via Emscripten, but I don't know how clean its API/interface will be and if it will leak globals based on how the code is structured [1]

[1] http://www.ece.mcmaster.ca/~xwu/cq.c

Post reply on HN