take a look at this: https://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast/107735#107735
..... After the Desktop Recorder has saved the recording into an OGV video, MPlayer will be used to capture JPEG screenshots, saving them into the 'output' directory.
On a terminal:
mplayer -ao null <video file name> -vo jpeg:outdir=output
Use ImageMagick to convert the screenshots into an animated gifs.
convert output/* output.gif
you can optimize the screenshots this way:
convert output.gif -fuzz 10% -layers Optimize optimised.gif
There is probably a better way to do it, but here is what I would do
First, split your animation in frames
convert animation.gif +adjoin temp_%02d.gif
Then, select one over n frames with a small for-loop in which you loop over all the frames, you check if it is divisible by 2 and if so you copy it in a new temporary file.
j=0; for i in $(ls temp_*gif); do if [ $(( $j%2 )) -eq 0 ]; then cp $i sel_`printf %02d $j`.gif; fi; j=$(echo "$j+1" | bc); done
If you prefer to keep all the non-divisible numbers (and so if you want to delete rather than to keep every nth frame), replace -eq
by -ne
.
And once you done it, create your new animation from the selected frames
convert -delay 20 $( ls sel_*) new_animation.gif
You can make a small script convert.sh
easily, which would be something like that
#!/bin/bash
animtoconvert=$1
nframe=$2
fps=$3
# Split in frames
convert $animtoconvert +adjoin temp_%02d.gif
# select the frames for the new animation
j=0
for i in $(ls temp_*gif); do
if [ $(( $j%${nframe} )) -eq 0 ]; then
cp $i sel_`printf %02d $j`.gif;
fi;
j=$(echo "$j+1" | bc);
done
# Create the new animation & clean up everything
convert -delay $fps $( ls sel_*) new_animation.gif
rm temp_* sel_*
And then just call, for example
$ convert.sh youranimation.gif 2 20
Best Answer
OK then
I started
ffcast
, didvim
, quitffcast
, thenconvert
ed.avi
→.gif
.I ran the recording commands in another terminal. Polished script for your
$PATH
at the end of this answer.What happened?
Capturing
ffcast
is the glorious product of some hacking at the Arch Linux community (mainly lolilolicon). You can find it on github (or in the AUR for Archers). Its dependency list is justbash
andffmpeg
, though you'll wantxrectsel
(AUR link) for interactive rectangle selection.You can also append
ffmpeg
flags right after the command. I set-r 15
to capture at 15 frames per second and-codec:v huffyuv
for lossless recording. (Play with these to tweak the size/quality tradeoff.)GIFfing
ImageMagick can read
.avi
videos and has some GIF optimisation tricks that drastically reduce file size while preserving quality: The-layers Optimize
toconvert
invokes the general-purpose optimiser. The ImageMagick manual has a page on advanced optimisations too.Final script
This is what I have in my
$PATH
. It records into a temporary file before converting.Thanks to BenC for detective work in figuring out the correct flags after the recent
ffcast
update.If you'd like to install the dependencies on a Debian-based distro, Louis has written helpful installation notes.