This is a script which uses the convert command from ImageMagick as well as mencoder of MPlayer to morph and create a video from several images. It is mostly usefull when doing morphs of the same subject in different conditions.
#!/bin/bash
fileglob=$1 newSize="1200x800" resizeQuality=85 outputForm='png' counterFormat='%05d' tmpPrefix='foo' outputPrefix='output' fps=24 outputVideoFilename='output' CNT=0
if [ "x${fileglob}" == "x" ] then echo "Missing filemask parameter" exit fi
for currentImage in ${fileglob} do j=`printf "${counterFormat}" ${CNT}`
if [ "x${previousImage}" != "x" ] then echo "Morphing ${previousImage} -> ${currentImage} (${tmpPrefix}-${j}-%${counterFormat}.${outputForm})" convert -resize ${newSize} -quality ${resizeQuality} -depth 8 ${previousImage} ${currentImage} -morph 180 ${tmpPrefix}- ${j}-${counterFormat}.${outputForm} else echo "previousImage is not defined" fi
CNT=$((${CNT}+1)) previousImage=${currentImage} done
echo "Renaming all frames from ${tmpPrefix}-*.${outputForm} -> ${outputPrefix}-XXXXX.${outputForm}" CNT=1
for i in ${tmpPrefix}-0*.${outputForm} do j=`printf "${counterFormat}" ${CNT}` mv -i "${i}" ${outputPrefix}-${j}.${outputForm} CNT=$(($CNT+1)) done
echo "Encoding files"
mencoder "mf://${outputPrefix}*.${outputForm}" -mf fps=25 -o ${outputVideoFilename}.avi -ovc lavc -lavcopts vcodec=mpeg4
|