
Making GIFs From Video Files With Python - killahpriest
http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python/#
======
w1ntermute
Please use silent HTML5 videos instead of animated GIFs wherever possible.
They are much more bandwidth- and CPU-efficient. This site allows you to
automatically upload/convert animated GIFs into that format:
[http://gfycat.com/](http://gfycat.com/)

The links allow you to see the animated GIFs as well, if viewer's device
doesn't support HTML5.

~~~
Recoil42
The problem, for me, is that HTML5 video is a technical solution with no
social advantage. There are so many places on the web where images are allowed
that videos will never be allowed -- for good reason. Forums, comment threads,
etc.

What we need is an image container format that allows for a silent (and only
silent) video stream to be embedded. A better GIF. Something that site
maintainers would feel entirely comfortable in allowing.

~~~
skymt
A new format would be overkill. Websites can just set the "muted" attribute on
video elements. If you also set "loop" & "autoplay" and hide the controls,
you've got a video that acts just like a GIF.

~~~
boyaka
Example, with sound on:
[http://home.comcast.net/~yugami/lean.html](http://home.comcast.net/~yugami/lean.html)

------
killahpriest
Originally from/more discussion at
[http://www.reddit.com/r/programming/comments/1w2c58/a_few_an...](http://www.reddit.com/r/programming/comments/1w2c58/a_few_animated_gifs_and_their_python_code_xpost/)

------
olssonm
Nice! Also check out: "Stupid programmer tricks and Star Wars .gif":
[http://rarlindseysmash.com/posts/stupid-programmer-tricks-
an...](http://rarlindseysmash.com/posts/stupid-programmer-tricks-and-star-
wars-gifs)

Also Python, but uses VideoLan (VLC) to some extent to create really nifty
Star Wars gifs.

------
theophrastus
(on 'jessie'):

apt-cache search 'movie.<asterisk>python|python.<asterisk>movie'

... <squatmo-germane> ...

well, nutz.

(and how the hell do you type a real asterisk in this comment forum? tried
escapes... tried html entities...)

~~~
maxerickson
For code, just put a couple spaces before the line:

    
    
      apt-cache search 'movie.*python|python.*movie'
    

In general, you can also stick a space after them * * *.

~~~
theophrastus
thank you. i would've never thought of that. * * _

------
donbronson
This is awesome and much easier than writing FFMPEG commands (which is what I
do now). An enhancement could be adding voice to text.

------
drakaal
Anyone done a benchmark of this vs AVISynth? I have software I wrote in
AVISynth for doing 2d to 3d Stereoscopic upconversion based on motion and
parallax. I have often wished I had it in something more "real" like Python.

~~~
0x09
Have you tried VaporSynth? It's kind of a spiritual successor to AviSynth in
the form of a Python module. Can even load AviSynth plugins.

------
pronoiac
This is nifty! Though it's tempting to draft a GUI for it.

------
jrockway
This is much nicer than my normal method of getting the frames with mplayer
-vo png and then using ImageMagick to assemble the frames into an animated
GIF.

------
idoco
I just watched the whole 'Pigs in a polka' video and it is so good! The API is
also very cool :)

------
stephenitis
@Schneems has a really good tutorial on this using ffmpeg.
[http://www.schneems.com/post/41104255619/use-gifs-in-your-
pu...](http://www.schneems.com/post/41104255619/use-gifs-in-your-pull-request-
for-good-not-evil/)

------
JoshTriplett
mplayer can do this as well:

    
    
        mplayer videofile -vo gif89a:fps=15:output=video.gif
    

You can use mplayer's other options to set the start time, duration, and
cropping.

------
gioi
Thank you! I've never met MoviePy and it looks really good. I'm waiting for
libopenshot to be released, what do you think about it?

------
na85
Isn't this overkill? You can get the exact same result with FFMPEG and a
single shell command.

Seems like a solution in search of a problem.

~~~
ivanca
Can you easily integrate django with a shell command? Or with the python imgur
image hosting? Easy online creation of gifs seems kind of useful.

------
lassse
I use [http://www.gifrocket.com/](http://www.gifrocket.com/) for Mac.

------
radoslawc
Nice, kept me occupied for an hour :) also I must say author did a great job
with module and documentation.

------
Chromozon
Very well made tutorial.

------
mattdeboard
Very nice API.

------
lawsohard
this is awesome

