Convert movie frames to .gif shell script

10Oct11
#/bin/sh
#Make a Gif from 3 frames from a movie
#Usage gifmaker.sh /path/to/movie.bla n  n /outputfile.bla
#ARGS $1=INPUT FILENAME $2=NUM FRAMES $3=START POS $4=OUTPUT FILENAME

#extract 3 .PNG files from source video
ffmpeg -i $1 -r 25 -vframes $2 -ss $3 $1-%03d.png

#convert .PNGs into single .GIFs
for FRAME in $(seq -f %03g $2)
do
   convert $1-$FRAME.png $1-$FRAME.gif
done

FWD=$(/bin/ls $1-*.gif)
BWD=$(echo "${FWD}" | sed 1d | sort -r | sed 1d)

#combine in gifsicle
gifsicle  --delay 4 --loopcount=0 --colors 256 $FWD $BWD > $4.gif

Networked Media – Piet Zwart Terminal Sessions

Sh script that enables you to output n number of frames as a gif from a timecoded position on a video file.


Images taken from comedy-horror classic Horror Express.

About these ads


No Responses Yet to “Convert movie frames to .gif shell script”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: