Live data from Hacker News

High quality GIF with FFmpeg

blog.pkh.me

31–40 of 131 posts

Re: High quality GIF with FFmpeg

#31

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

Don't compile it just use the official binaries!

Re: High quality GIF with FFmpeg

#32
>As you probably know, GIF is limited to a palette of 256 colors.

No, it's not. OK, the current, wrong, implementations do limit it to 256 colors, but that's not a limitation of gif. Mulitple frames without a delay allow multiple pallets and multiple times 265 colors.

But this limitation is just another reason not to use it.

Can I use Webm?

http://caniuse.com/#feat=webm

Yes, you can, and you should. Or h.264:

http://caniuse.com/#feat=mpeg4

Re: High quality GIF with FFmpeg

#33

Nice article and good job implementing it. I would have preferred a small explanation of the filter graph option (-lavfi), but I guess that's outside the scope of the post.

Yeah, but the article is already quite long so I omit the "details" on that...

Basically, it's just to specify a complex filtergraph: in the case of -vf you're just passing one video stream which gets filtered by successive filters. In the case of -lavfi (or -filter_complex if you prefer) you can feed multiple inputs (and get multiple outputs). In this case, the second input is the palette image.

You can find more information on http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction

Re: High quality GIF with FFmpeg

#34
post #32

>As you probably know, GIF is limited to a palette of 256 colors. No, it's not. OK, the current, wrong, implementations do limit it to 256 colors, but that's not a limitation of gif. Mulitple frames without a delay allow multiple pallets and multiple times 265 colors. But this limitation is just another reason not to use it. Can I use Webm? http://caniuse.com/#feat=webm Yes, you can, and you should. Or h.264: http://…

Can you show an example of an animation with more than 256 colors?

As you said, the hack to get more than 256 colors is to redefine a sub rectangle with a new palette. But that's also the mechanism used to make animations. Are you able to get fluid playback with that?

Note: I'm not talking about new frame being just a new sub rectangle, more about N sub rectangles for the same frame, then a delay event, then M sub rectangles for the new frame, etc

Re: High quality GIF with FFmpeg

#35

Earlier quoted context omitted.

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

If only iOS (and Android?) allowed you to play inline videos the way you can on the desktop, and the way they play animated GIF's inline. Besides allowing us to adopt video throughout and save on bandwidth and have better video quality, this will be a huge productivity boost to developers: we can finally stop having the GIF vis JIF pronunciation debate.

Firefox on Android plays inline videos just fine. Sites like GFYcat work as expected, and loop appropriately.

Re: High quality GIF with FFmpeg

#36
post #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/OpenW…

Oh hey, I wrote that! There are plenty of apps that are distributing LGPL code on the App Store, for example, VLC for iOS [1] includes FFmpeg. The static linking requirement on iOS 7 and earlier prompted some proprietary app developers (like Sparrow [2]) to distribute their object files to allow re-linking.

Now that iOS 8 offers dynamic frameworks, I'm not sure if this situation has changed. Even though they are dynamically linked, it is impossible for the end user to replace a library due to the code signing requirements.

1. http://www.videolan.org/vlc/download-ios.html 2. https://web.archive.org/web/20131013023029/http://sprw.me/lg...

Re: High quality GIF with FFmpeg

#37
post #31

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

Don't compile it just use the official binaries!

That's a good option if the official binaries support all the codecs you need and have all the correct hardware acceleration flags set for your particular CPU/GPU. That's ... theoretically possible, I suppose.

Re: High quality GIF with FFmpeg

#38
post #34
post #32

>As you probably know, GIF is limited to a palette of 256 colors. No, it's not. OK, the current, wrong, implementations do limit it to 256 colors, but that's not a limitation of gif. Mulitple frames without a delay allow multiple pallets and multiple times 265 colors. But this limitation is just another reason not to use it. Can I use Webm? http://caniuse.com/#feat=webm Yes, you can, and you should. Or h.264: http://…

Can you show an example of an animation with more than 256 colors? As you said, the hack to get more than 256 colors is to redefine a sub rectangle with a new palette. But that's also the mechanism used to make animations. Are you able to get fluid playback with that? Note: I'm not talking about new frame being just a new sub rectangle, more about N sub rectangles for the same frame, then a delay event, then M sub re…

None that works with current browsers implantations, because they erroneous ignore no delay between frames and wait anyway. But that's a bug in the gif decoder, not a limitation of gif. OK, this is hairsplitting, but it illustrates how borken the state of gif is.

Re: High quality GIF with FFmpeg

#39

Earlier quoted context omitted.

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

VP9 has lossless encoding support.

http://base-n.de/webm/VP9lossless.html

Re: High quality GIF with FFmpeg

#40
post #32

>As you probably know, GIF is limited to a palette of 256 colors. No, it's not. OK, the current, wrong, implementations do limit it to 256 colors, but that's not a limitation of gif. Mulitple frames without a delay allow multiple pallets and multiple times 265 colors. But this limitation is just another reason not to use it. Can I use Webm? http://caniuse.com/#feat=webm Yes, you can, and you should. Or h.264: http://…

[deleted]
Post reply on HN