Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

gifify

> 开发工具
Open source

Convert any video file to an optimized animated GIF.

6.3K stars0 likes2 views
WebsiteGitHub

About

Convert any video file to an optimized animated GIF.

NOTE FROM AUTHOR

I am no more using this project or providing any support to it, if you want to maintain it, ping me here: [email protected].

This project was created 4 years ago, there might be better ways to turn a video into a GIF now, use google!

/NOTE FROM AUTHOR

gifify

Convert any video file to an optimized animated GIF. Either in its full length or only a part of it.

Demo time

This screencast was recorded with lolilolicon/FFcast then converted to a GIF with:

bash
gifify screencast.mkv -o screencast.gif --resize 800:-1

Features

  • command line interface
  • programmatic JavaScript (Node.JS) stream interface
  • unix friendly, supports stdin & stdout
  • optimized! uses pornel/giflossy to generate light GIFS
  • lots of options: movie speed, fps, colors, compression, resize, reverse, from & to, subtitles
  • no temp files used, everything happens in memory
  • fast! Extracting a 5-second GIF from the middle of a 2-hour movie takes less than 20 seconds

Requirements

Before using gifify, please install:

  • Node.js ($ brew install node)
  • FFmpeg ($ brew install ffmpeg)
  • convert, the famous ImageMagick ($ brew install imagemagick)
  • pornel/giflossy, it's a gifsicle fork (waiting for gifsicle#16 to be merged) ($ brew install giflossy)

You can also use the gifify Docker image which comes with everything installed.

Installation

bash
npm install -g gifify

Command line usage

…

Programmatic usage

See the example.

javascript
var fs = require('fs');
var gifify = require('gifify');
var path = require('path');

var input = path.join(__dirname, 'movie.mp4');
var output = path.join(__dirname, 'movie.gif');

var gif = fs.createWriteStream(output);

var options = {
  resize: '200:-1',
  from: 30,
  to: 35
};

gifify(input, options).pipe(gif);

You can also pass a readable stream to gifify(stream, opts).

Readable stream input performance

Gifify supports streams both on command line (cat movie.mp4 | gifify -o out.gif) and in the programmatic API (gifify(readableStream, opts).pipe(writableStream)).

While it's super useful in some cases, if you have the file on disk already, you better do gifify movie.mp4 -o out.gif or gifify(filePath, opts).pipe(writableStream).

Why? Because piping 3.4GB when you want to cut from 40:20 to 40:22 still takes a loooooot of time and does not give you any performance benefit.

FFmpeg has to read from 0GB -> $START_BYTE_40:20 and discards it. But everything flows in your memory.

When using direct file input from command line, we pass the -i filename option to FFmpeg and then it's super fast!

Be careful when |piping.

Adding some text

You can burn some simple text into your GIF:

bash
gifify back.mp4 -o back.gif --from 01:48:23.200 --to 01:48:25.300 --text "What?..What?What?"

Result:

Subtitles

You can burn subtitles into your GIF, it's that easy:

bash
gifify 22.mkv -o movie.gif --subtitles 22.ass --from 1995 --to 2002 --resize 600:-1

You must create new subtitles files, the timecodes for the complete film will not work for a five seconds GIF.

Create subtitles using aegisub and augment the font size for a great effect!

Here's the 22.ass from the previous command, created with aegisub:

…

Result extracting a GIF from 22 Jump Street:

GIF Performance

On modern hardware GIF is the slowest and most expensive video codec. Can we please allow it to be obsoleted?

https://pornel.net/efficient-gifs#sec44

YOLO!

Giflossy

Giflossy is a fork of gifsicle, gifsicle author is currently working on integrating the lossy part in gifsicle.

So in little time we will be able to directly use gifsicle and gifiscle packages.

Thanks

jclem/gifify was a great source of inspiration.

Issues· 26 open

View all issuesOpen on GitHub
  • #119

    I use windows wsl -d ubuntu install gifify(Contains required plugins) run but show error

    Updated Nov 7, 2023
  • #94

    Maximum call stack size exceeded.

    Updated Jul 7, 2023
  • #118

    requirement not automatically installed

    Updated Sep 8, 2021
  • #95

    Neither dependency works on 2.4.0

    Updated Apr 15, 2020
  • #117

    Gif lossy has been merged

    Updated Mar 4, 2020
  • #62

    Could not find convert

    questionUpdated Feb 28, 2020
  • #111

    Pass additional arguments to ffmpeg

    Updated Feb 12, 2019
  • #110

    Fix/review --resize option #Help

    Updated Nov 22, 2018
  • #29

    Error: convert needs fontconfig

    Updated Nov 15, 2018
  • #108

    Need Design Logo?

    Updated Sep 12, 2018

> Tags

JavaScriptffmpeggifgififygifsicle

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 25, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具