• Stars
    star
    237
  • Rank 169,885 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A command line tool for creating animated GIFs from YouTube.

WGif

Build Status Code Climate

WGif is a command line tool for creating animated GIFs from YouTube videos.

Other tools can make gifs, but no other tool can make high quality gifs easily like wgif can

you can use that quote on your readme

β€” Kevin Liddle, Software Craftsman

##TL;DR

Usage: wgif [YouTube URL] [output file] [options]

    -f, --frames N          Number of frames in the final gif. (Default 20)
    -s, --start HH:MM:SS    Start creating gif from input video at this timestamp. (Default 00:00:00)
    -d, --duration seconds  Number of seconds of input video to capture. (Default 1)
    -w, --width pixels      Width of the gif in pixels. (Default 480px)
    -u, --upload            Upload finished gif to Imgur
    -p, --preview           Preview finished gif with Quick Look
  	-i, --info				Displays info about finished gif (currently just file size)
    -h, --help              Print help information.

Example:

    $ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif -s 00:03:30 -d 2 -w 400 -i --upload

Installation (Mac OS X)

Update 2014/04/23: One of WGif's dependencies requires ImageMagick to compile. Before installing, make sure you:

$ brew install imagemagick

using Homebrew, or install it with your favorite package manager.

Then, to install from Rubygems:

$ gem install wgif

To install from source, run

$ gem build wgif.gemspec

and

$ gem install wgif-0.3.0.gem

to install the executable.

WGif uses FFmpeg for video transcoding and ImageMagick to optimize GIFs. To install dependencies with Homebrew, just run

$ wgif install

Making a GIF

WGif expects two arguments: a YouTube video URL and a name for the GIF it creates. So,

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif

Is enough to create a GIF of Bjork explaining her television. Without any extra parameters, WGif starts at the beginning of the video, and creates a 20-frame, 480px GIF of the first second. Since GIFs are more art than science, you'll probably want to tweak the size, duration, and number of frames.

Start by isolating the section of the video you'd like to GIF. Bjork starts her advice about dishonest Icelandic poets around 3 minutes 30 seconds, and it lasts about two seconds. Pass the start timestamp with -s or --start and the duration with -d or --duration:

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif --start 00:03:30 -d 2

A good start, but the GIF is way too big: around 5.6 megabytes. We can pass -f or --frames to specify the total number of frames in the finished GIF. This defaults to 20, so let's drop a few to reduce the file size:

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif --start 00:03:30 -d 2 -f 18

To preview the output in a Quick Look window, add the --preview flag:

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif --start 00:03:30 -d 2 -f 18 --preview

You'll see a preview pop up in a Quick Look window like this one:

Preview

Dropping frames shrunk the file to 2.2 megabytes, but it's still not small enough to post on my Sugarcubes fan-Tumblr. Let's scale it down a little with the -w or --width flag:

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif --start 00:03:30 -d 2 -f 18 --width 350

And finally, now that everything's completed, let's add the --upload flag to automatically post it to Imgur:

$ wgif https://www.youtube.com/watch?v=1A78yTvIY1k bjork.gif --start 00:03:30 -d 2 -f 18 --width 350 --upload
Finished. GIF uploaded to Imgur at http://i.imgur.com/iA28DuR.gif

And here it is:

Bjork

"You shouldn't let poets lie to you."

Changes

  • v0.5.4, 2015/7/26: Add --version flag. Upgrade viddl-rb and rmagick.
  • v0.5.3, 2015/7/26: Fix sort order of globbed frames. (Issue #19)
  • v0.5.2, 2015/1/24: Use /usr/bin/env ruby in binary.
  • v0.5.1, 2014/8/15: Lock down dependency versions.
  • v0.5.0, 2014/8/15: Add support for sub-second timestamps in --start and --duration flags (Issue #13).
  • v0.4.0, 2014/5/30: Show file size with --info flag. (Thanks, justalisteningman!)
  • v0.3.1, 2014/5/10: Fixes frame order for gifs with more than 100 frames. (Issue #14)
  • v0.3.0, 2014/4/20: Add Quick Look preview with --preview flag.
  • v0.2.0, 2014/4/11: Add automatic upload to Imgur with --upload flag.

Contributors

Thanks to arlandism and ellie007 for pairing on Imgur uploads. Thanks to justalisteningman for adding file size info. Thanks to aparrish for diagnosing an Ubuntu frame ordering bug.

Contributions

Are welcome via pull request.

License

This project is MIT licensed. See LICENSE.txt for details.

More Repositories

1

DaveDaveFind

A simple search engine based on the web crawler developed in Udacity's CS101 course.
Python
73
star
2

sicpclojure

I personally don't think SICP will help you much with Clojure. YMMV.
JavaScript
51
star
3

Kicksaver

Find and save Kickstarter projects ending soon.
Python
15
star
4

malcontent

Ring middleware for Content-Security-Policy
Clojure
14
star
5

fmj

A POSIX emoji formatter
Awk
11
star
6

instant-bot

βš‘οΈπŸ€– Instant bots on AWS Lambda ⚑️
JavaScript
11
star
7

serverless-integration-patterns

⚑️ Enterprise Integration Patterns using AWS Lambda and serverless
Python
7
star
8

defrag

Solidity
7
star
9

What-Good

What good will you do today?
Python
5
star
10

ride-or-die

TypeScript
5
star
11

doxx

TypeScript
4
star
12

specljs-template

A Leiningen template for specljs, the ClojureScript spec runner.
Clojure
4
star
13

Meme-Pool

Meme Pool is an image blog that evolves.
Python
4
star
14

commaparty

Hiccup for Ruby.
Ruby
3
star
15

build-a-bot-workshop

JavaScript
2
star
16

Evolutionary-Audio

An experiment using an evolutionary algorithm to generate sounds. It was harder than I thought.
Python
2
star
17

lute-drop

I hear that you and your bard have sold your lutes and bought flutes.
TypeScript
2
star
18

clojurescript-tic-tac-toe

Simple Clojurescript minimax tic-tac-toe
Clojure
2
star
19

property-based-testing

Prime factors Kata examples with property-based tests
Java
2
star
20

Tabminder

Stop distracted browsing before it starts.
JavaScript
2
star
21

Hawk-and-Dove

An early experiment in learning objects. A simulation of Smith and Price's "Hawk-Dove" in PyGame.
Python
2
star
22

udacity-keybindings

Vim keybindings for Udacity's embedded CodeMirror editor.
JavaScript
2
star
23

COMEFROM

Completely Online Milgram Experiment For Researching Obedience to Machines
JavaScript
2
star
24

beetrace

🐝 play a bee movie sound effect on every system call
DTrace
1
star
25

ecmendenhall.github.com

JavaScript
1
star
26

ttt-book

Dockerfile
1
star
27

lambda-py

A tiny Python lambda calculus interpreter.
Python
1
star
28

jbx-governor

Partially Automated Luxury Juicebox Governance
TypeScript
1
star
29

ttt-book-code

Solidity
1
star
30

hi_h8rs

✨ πŸ’– ✨
1
star
31

Infinite-Charleston

Infinite Pete & Trudy Charleston.
JavaScript
1
star
32

epl

E Programming Language.
Clojure
1
star
33

cellular-automata-bot

1
star
34

sicp-clj

SICP exercises in Clojure.
Clojure
1
star
35

pushpin

Lightweight shared items and comments for Pinboard. Pretend Google Reader never died.
Ruby
1
star
36

numberwang

That's numberwang! Let's rotate the board!
Shell
1
star
37

ecm

Git repository for my personal site.
Python
1
star
38

mutepoets

silence speaks volumes
TypeScript
1
star
39

Java-TTT

Simple minimax Tic Tac Toe in Java.
Java
1
star