#!/usr/bin/bash
#These are the command line arguments that the user puts in when calling the script
#This is the name of the movie you give
MOVIE=$1
#This is the mogrify or convert command you want
STRING=$2
#This is where the user tells if they want the frame counter. They have to put frame in the command if they want to use it. They have to write something
TEXT=$3
#If the command line has no arguments...
if [ $# == 0 ];
then
echo I need a movie to use
exit
fi
#It tells the user it needs a movie and exits
echo Processing the video called: $MOVIE
#This will streamline the image files it dumps out
FRAMEPRE=${MOVIE}-frame-
echo I will call the frames this:- $FRAMEPRE -with frame numbers following
#This dumps out the frames
ffmpeg -i ${MOVIE} -r 24 -s 640x360 -f image2 ${FRAMEPRE}%04d-expelled.png
#This compiles the dumped frames into a variable
FRAMES=`ls *expelled.png`
#Set I that we will increment in the loop
I=1
#For every object in the variable FRAMES
for FRAME in $FRAMES
#start the loop
do
#This does what the person wants to do, any string is fine. Imagemagick is preferable
${STRING} $FRAME
#This is for the third argument. The user has to put in SOMETHING or it won't work. They could put no for example.
if [ $TEXT == frame ];
then
#This puts the frame counter on
mogrify -pointsize 16 -font courier -annotate +50+50 "Frame ${I}" $FRAME
fi
#This renames all the expelled names to flop names
NFN=`printf "${FRAMEPRE}%04d-flop.png" $I`
#Increment the loop
I=$(($I+1))
#This moves FRAME to NFN or new file name
mv $FRAME $NFN
#This converts the .png to jpg. I found this gave the movie the best quality than just doing .jpg Just .png gives weird blue fragments
convert $NFN $NFN.jpg
echo converting frame $I
#cp $FRAME $NFN
done
#This compiles the movie at a rate of 24fps
ffmpeg -f image2 -r 24 -s 640x360 -i ${FRAMEPRE}%04d-flop.png.jpg RedoneMovie.mov
#These 2 remove all of the images, so you are left with just the original movie and the changed movie
rm *.png
rm *.png.jpg
This is the original movie that I put in (an image of it).
And this is the movie that the script made.
No comments:
Post a Comment