Linux: Animated gifs from youtube videos

February 21st, 2013

The following animated gifs are short scenes from youtube videos. They are looped, which occasionally gives a mesmerizing effect.

avatar-rinusavatar-beyonceavatar-skitta
 

 

The original videos can be found here, here, and here. Programs that I use are youtube-dl, avidemux, and mplayer. I have taken the following steps to create these gifs.

  • Download the entire video:
    youtube-dl http://www.youtube.com/watch?v=9bZkp7q19f0
  • Use avidemux to select the desired part and save it as bestand-1.avi
  • Remove the sound:
    mencoder -ovc lavc -nosound bestand-1.avi -o bestand-2.avi
  • Crop the video:
    mencoder -ovc lavc -vf crop=140:140:105:45 bestand-2.avi -o bestand-3.avi
  • Resize to 100×100:
    mencoder -ovc lavc -vf scale=100:100 bestand-3.avi -o bestand-4.avi
  • Convert to animated gif in black/white:
    mplayer bestand-4.avi -saturation -100 -vo gif89a:output=bestand-5.gif:fps=30
  • Or convert to animated gif, colors:
    mplayer bestand-4.avi -vo gif89a:output=bestand-5.gif:fps=30

Note that gif images are limited to 256 colors; it is for this reason that black/white gifs almost always yield better results.

This entry was posted on Thursday, February 21st, 2013 at 19:47 and is filed under linux. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.