Kagami / ffmpeg.js

Port of FFmpeg with Emscripten
Other
3.29k stars 335 forks source link

GIF Encoding? #66

Closed mattdesl closed 4 years ago

mattdesl commented 5 years ago

I'd love to be able to encode high quality GIF on the client-side with WASM ffmpeg. Right now the pure-JS GIF encoding solutions are pretty slow and don't produce the same high quality as ffmpeg.

I wonder if you'd consider adding a GIF only build?

Here's a couple articles on what flags are used in high quality ffmpeg GIFs:

Solarswordsman commented 5 years ago

I've had success simply adding the gif demuxer/decoder/encoder flags in the Makefile, if you're able to build this yourself. Just add gif to COMMON_DEMUXERS, COMMON_DECODERS, and to make things easy on yourself, just add it to WEBM_MUXERS and WEBM_ENCODERS as they'll be included in both builds.

If you wanted a gif only build, you could go down that road probably with only the Makefile, removing what you don't want, just be careful not to remove any dependencies ffmpeg needs in general (there aren't many, you could probably just start removing stuff until it breaks :P).

I know this isn't a "here's your javascript file" answer, but it's very doable, the Makefile is quite clean and simple. Only hard part is getting emscripten to work properly, as I think some recent versions have an issue that the current source isn't handling. (It's an issue on this repository, though I can't find it).

Anyway, all those flags will be available if you add gif to the ffmpeg build.

goatandsheep commented 4 years ago

what is the decoder you use? I tried seeing what giphy did, but couldn't figure it out.

Kagami commented 4 years ago

@Solarswordsman is right. I suggest to rebuild with gif encoder.

goatandsheep commented 4 years ago

@Kagami rebuild this package with gif option?

Kagami commented 4 years ago

Yes.

goatandsheep commented 4 years ago

thank you! what option is that? can you show an example command? Do i just use -f gif? Is it built in? Do I need a special decoder?