I have a small animation formatted as a GIF image file which I would like to convert to a video. Is that possible?
1 Answer
Using a Nautilus Script
Overview
You can easily convert GIF files to videos by using the imagemagick
suite and avconv
. To make the process easier I have written a small Nautilus script that takes your GIF file and the desired framerate as its input and outputs an MP4 file.
Code
#!/bin/bash
# NAME gif2mp4 0.1
# AUTHOR Glutanimate (c) 2013 (https://askubuntu.com/users/81372/glutanimate)
# LICENSE GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# DESCRIPTION Converts GIF files of a specific framerate to MP4 video files.
# DEPENDENCIES zenity,imagemagick,avconv
TMPDIR=$(mktemp -d)
FPS=$(zenity --width 200 --height 100 --entry --title "gif2mp4" --text="Please enter the frame rate.")
VIDDIR=$(dirname $1)
if [ -z "$FPS" ]
then
exit
fi
notify-send -i video-x-generic.png "gif2mp4" "Converting $(basename "$1") ..."
convert "$1" $TMPDIR/frame%02d.png
avconv -r $FPS -i $TMPDIR/frame%02d.png -qscale 4 "$VIDDIR/$(basename "$1" .gif).mp4"
notify-send -i video-x-generic.png "gif2mp4" "$(basename "$1") converted"
rm -rf $TMPDIR
Installation instructions
Please see here for more information on how to install this script: How can I install a Nautilus script?