#!/bin/bash -x ##################### #### This is the master file in charge of calling up all the scripts #### that I've written to composite series of images with #### imagemagick. It calls them up in the right order making sure the #### proper image folders are always used, so that the result is a #### sequence of films who have undergone various compositing #### effects. The only two variables that really need changing are #### COMPOSE and LEADIN, which affect the duration of the video #### composition. File folders are given in the commandline after the #### "./master" command in the order that they should be #### processed. Each folder will be processed twice, once forwards and #### once backwards. At the moment 8 folders of images are needed. All #### images have to be png format numbered and named from 001-999 and #### have the same size. This program is purely for experimental #### purposes, in no way should you expect it to work;) Current #### working version of imagemagick is 6.5.3 ####################### # removes files created during processing after program is completed # or broken, and exit properly if ctrl-c is pressed. trap "rm -f *.list *.mpc *.cache" 0 trap "rm -f *.list *.mpc *.cache" 1 2 3 15 trap "exit 0" 2 export COMPOSE=115 # duration of the individual compositions LEADIN=72 # duration of lead ins before and after compositions export comp_ripple=no # says that the ripple effect isn't being combined with a composition FOLDER1=01 # number of the first input folder of a sequence ### Timing defaults for sunset effect stages export FADE_SUNSET=$(( COMPOSE / 3)) # duration of fade export SIG_ARC=$(( COMPOSE - FADE_SUNSET )) # duration of sigmoidal and contrast & arc distort effects export ARC_COUNT=$(( SIG_ARC / 2 )) # duration of distort arc effect ### Timing defaults for tractor effect stages export FADE_TRACTOR=$(( COMPOSE / 3 )) # duration of the fade export TRACTOR=$(( COMPOSE - FADE_TRACTOR )) # duration of the tractor-beam effect # the in-folders are written into a seperate file along with the # number of files in each in-folder until [ $# = 1 ]; do FILES=$(ls $1 | wc -l) echo "in$FOLDER1 $1 $FILES">>folder.list shift FOLDER1=`echo $FOLDER1|sed 's/^0*//'` # Zero needs to be taken away so 08 and 09 are recognized FOLDER1=$(( FOLDER1 + 1 )) # Move on to the next folder in the argument FOLDER1=`printf "%02d" $FOLDER1` # Add 0 infront so that awk doesnt confuse teens with 1 done export OUTFOLDER=$1 # name of the output folder export COUNT=1 # current number of outfolder ###### LEADIN 1 - Plain # Copies the amount of files specified in LEADIN to the out folder in # sequence. The child process "leadin" does this. A separate file # "caller.list" keeps track of which file to call next in the child # process. The child process "call-files" keeps track of which file # and folder to process. LeadIn () { while [ $COUNT -le $LEADIN2 ]; do ./call-files $COUNTIN1 ./leadin export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) # Next file to be processed done } export FOLDER1=01 # first infolder to call in this phase export FOLDER2=01 # last infolder to call in this phase export COUNTIN1=1 # first file to be called in current infolder LEADIN2=$LEADIN # LEADIN2 refers to the files in the overall process involved in this particular leadin LeadIn ###### COMPOSITION 1 - Sunset # At first only one file is needed for this composition. Sunset1 () { ./call-files $COUNTIN1 ./sunset # Seperate "sunset" file contains imagemagick process export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } # At the end two files are needed Sunset2 () { ./call-files $COUNTIN1 $COUNTIN2 ./sunset export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } # Trigger for knowing when to move on to the next effect SunsetCount () { export COMPOSE1=$(( LEADIN2 + ARC_COUNT )) # same as ARC_COUNT, but taking current COUNT into account export COMPOSE2=$(( LEADIN2 + SIG_ARC )) # same as SIG_ARC, but taking current COUNT into account COMPOSE3=$(( LEADIN2 + COMPOSE )) # same as COMPOSE, but taking current COUNT into account export DEFAULT_FETCH=$COUNT # First runthough will note and set defaults } SunsetCountProcess () { # Takes tasks which will be repeated and lumps them in a function SunsetCount Sunset1 . defaults-sunset.list # here defaults are set by calling a file which uses export while [ $COUNT -le $COMPOSE2 ]; do # Sigmoidal-contrast and arc distort parts of the "sunset" effect Sunset1 done } SunsetProcess () { # The arc fade with top and bottom radius. Requires two files. COUNTIN2=1 # First file to call in that folder export MASK_LUT=maskC.mpc # A default for the rest of the process, was variable during first part while [ $COUNT -le $COMPOSE3 ]; do Sunset2 done } SunsetCountProcess export FOLDER2=02 # last infolder to call in this phase SunsetProcess ######### LEADIN 2 - Plain LeadCountProcess () { # Takes tasks which will be repeated and lumps them in a function export COUNTIN1=$COUNTIN2 # As FOLDER2 is now FOLDER1, change the file number to be called. LEADIN2=$(( LEADIN + COMPOSE3 )) # Adds the preset LEADIN to the number of files called so far LeadIn } export FOLDER1=02 # The folder to copy is set next folder in the commandline argument LeadCountProcess ###### COMPOSITION 2 - Tractor # Composition created through child process "tractor-beam". Files from # two folders combined. Tractor() { ./call-files $COUNTIN1 $COUNTIN2 ./tractor-beam export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } TractorCount () { export COUNTIN2=1 export COMPOSE1=$(( LEADIN2 + TRACTOR )) # Same as TRACTOR, but taking current COUNT into account COMPOSE3=$(( COMPOSE1 + FADE_TRACTOR )) # Same as FADE_TRACTOR, but taking current COUNT into account export DEFAULT_FETCH=$COUNT } export FOLDER2=03 # second infolder to call in this phase TractorCount # During the first runthrough defaults are saved in the child # processes and then exported from the parent process Tractor . defaults-tractor.list # Compositing of tractor-beam effect for the number of files specified # in COMPOSE while [ $COUNT -le $COMPOSE3 ]; do Tractor done ###### LEADIN 3 - Plain export FOLDER1=03 LeadCountProcess ###### COMPOSITION 3 - Sunset SunsetCountProcess export FOLDER2=04 SunsetProcess ###### LEADIN 4 - Ripple # Leadin is no longer just a copy, but rather also has a "ripples" # effect. RipplyLead () { ./call-files $COUNTIN1 ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } export FOLDER1=04 LEADIN2=$(( LEADIN + COMPOSE3 )) export COUNTIN1=$COUNTIN2 export DEFAULT_FETCH_RIPPLES=$COUNT # First runthough will note and set defaults RipplyLead . defaults-ripple.list # Ripples also have default values which only have to be set once while [ $COUNT -le $LEADIN2 ]; do RipplyLead done ###### COMPOSITION 4 - Tractor & ripple # First the "tractor-beam" and then the "ripples" effect are performed. TractorRipple () { ./call-files $COUNTIN1 $COUNTIN2 ./tractor-beam ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } TractorRippleProcess () { export comp_ripple=yes # Flag to note that an intermediary file is needed between the two effects. TractorCount TractorRipple . defaults-tractor.list while [ $COUNT -le $COMPOSE3 ]; do TractorRipple done } export FOLDER2=05 TractorRippleProcess ###### LEADIN 5 - Ripple RipplyLeadCount () { export comp_ripple=no # Intermediary is no longer needed LEADIN2=$(( LEADIN + COMPOSE3 )) export COUNTIN1=$COUNTIN2 while [ $COUNT -le $LEADIN2 ]; do RipplyLead done } export FOLDER1=05 RipplyLeadCount ######COMPOSITION 5 - Sunset & ripple # First the "sunset" and then the "ripples" effect are performed. # At first only one file is needed for this composition... SunsetRipple1() { ./call-files $COUNTIN1 ./sunset ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } # ...at the end two. SunsetRipple2() { ./call-files $COUNTIN1 $COUNTIN2 ./sunset ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } SunsetRippleCountProcess () { export comp_ripple=maybe # Flag to say only one in and an intermediary file are needed SunsetCount SunsetRipple1 . defaults-sunset.list while [ $COUNT -le $COMPOSE2 ]; do SunsetRipple1 done export comp_ripple=yes } SunsetRippleProcess () { COUNTIN2=1 export MASK_LUT=maskC.mpc while [ $COUNT -le $COMPOSE3 ]; do SunsetRipple2 done } SunsetRippleCountProcess export FOLDER2=06 SunsetRippleProcess ###### LEADIN 6 - Ripple export FOLDER1=06 RipplyLeadCount ###### COMPOSITION 6 - Tractor & ripple export FOLDER2=07 TractorRippleProcess ###### LEADIN 7 - Ripple export FOLDER1=07 RipplyLeadCount ######COMPOSITION 7 - Sunset & ripple SunsetRippleCountProcess export FOLDER2=08 SunsetRippleProcess ###### LEADIN 8 - Ripple export FOLDER1=08 RipplyLeadCount ###### LEADIN 9 - Ripple backwards # Files are now being called in backwards order by call-file-backwards file. LeadRipBack () { comp_ripple=no while [ $COUNT -le $LEADIN2 ]; do ./call-files-backwards $COUNTIN1 ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) done } LEADIN2=$(( LEADIN + LEADIN2 )) COUNTIN1=$COUNTIN2 LeadRipBack ###### COMPOSITION 8 Sunset ripple backwards # Since the compositions are being done backwards, at first two files # are needed then only one. sunset-backwards now performs the # composition in reverse order. SunRipBack1 () { ./call-files-backwards $COUNTIN1 ./sunset-backwards ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } SunRipBack2 () { ./call-files-backwards $COUNTIN1 $COUNTIN2 ./sunset-backwards ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } SunBackCount () { export COMPOSE1=$(( LEADIN2 + FADE_SUNSET )) export COMPOSE2=$(( COMPOSE1 + ARC_COUNT )) COMPOSE3=$(( LEADIN2 + COMPOSE )) export DEFAULT_FETCH=$COUNT COUNTIN2=0 export MASK_LUT=maskC.mpc } SunRipBackCountProcess () { SunBackCount export comp_ripple=yes SunRipBack2 . defaults-sunset.list while [ $COUNT -le $COMPOSE1 ]; do SunRipBack2 done } SunRipBackProcess () { export COUNTIN1=$COUNTIN2 export comp_ripple=maybe while [ $COUNT -le $COMPOSE3 ]; do SunRipBack1 done } export FOLDER2=07 # Folders are now being counted down SunRipBackCountProcess export FOLDER1=07 SunRipBackProcess ###### LEADIN 10 Ripple backwards LEADIN2=$(( LEADIN + COMPOSE3 )) LeadRipBack ###### COMPOSITION 9 Tractor ripple backwards # First the "tractor-beam-backwards" and then the "ripples" effect are # performed. Tractor beam is done in reverse order. TractorRipBack () { ./call-files-backwards $COUNTIN1 $COUNTIN2 ./tractor-beam-backwards ./ripples export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } TractorBackCount () { export COUNTIN2=0 export COMPOSE1=$(( LEADIN2 + FADE_TRACTOR )) COMPOSE3=$(( LEADIN2 + COMPOSE )) export DEFAULT_FETCH=$COUNT } TractorRipBackProcess () { export comp_ripple=yes TractorBackCount TractorRipBack . defaults-tractor.list while [ $COUNT -le $COMPOSE3 ]; do TractorRipBack done export COUNTIN1=$COUNTIN2 } export FOLDER2=06 TractorRipBackProcess export FOLDER1=06 ####### LEADIN 11 Ripple backwards LEADIN2=$(( LEADIN + COMPOSE3 )) LeadRipBack ###### COMPOSITION 10 Sunset ripple backwards export FOLDER2=05 SunRipBackCountProcess export FOLDER1=05 SunRipBackProcess ####### LEADIN 12 Ripple backwards LEADIN2=$(( LEADIN + COMPOSE3 )) LeadRipBack ###### COMPOSITION 11 Tractor ripple backwards export FOLDER2=04 TractorRipBackProcess export FOLDER1=04 ####### LEADIN 13 Ripple backwards LEADIN2=$(( LEADIN + COMPOSE3 )) LeadRipBack ###### COMPOSITION 12 - Tractor backwards # No more ripple effect needed TractorBack () { ./call-files-backwards $COUNTIN1 $COUNTIN2 ./tractor-beam-backwards export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } TractorBackProcess () { TractorBackCount TractorBack . defaults-tractor.list while [ $COUNT -le $COMPOSE3 ]; do TractorBack done export COUNTIN1=$COUNTIN2 } export comp_ripple=no # Flag to note that an intermediary file is needed no longer needed export FOLDER2=03 TractorBackProcess export FOLDER1=03 ###### LEADIN 14 Plain backwards LeadBack () { LEADIN2=$(( LEADIN + $COMPOSE3 )) while [ $COUNT -le $LEADIN2 ]; do ./call-files-backwards $COUNTIN1 ./leadin export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) # Next file to be processed done } LeadBack ###### Composition 13 Sunset backwards SunBack1 () { ./call-files-backwards $COUNTIN1 ./sunset-backwards export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } SunBack2 () { ./call-files-backwards $COUNTIN1 $COUNTIN2 ./sunset-backwards export COUNTIN1=`awk 'NR==1 {print $2}' caller.list` export COUNTIN2=`awk 'NR==2 {print $2}' caller.list` export COUNT=$(( COUNT + 1 )) } SunBackCountProcess () { SunBackCount SunRipBack2 . defaults-sunset.list while [ $COUNT -le $COMPOSE1 ]; do SunBack2 done } SunBackProcess () { export COUNTIN1=$COUNTIN2 while [ $COUNT -le $COMPOSE3 ]; do SunBack1 done } export FOLDER2=02 SunBackCountProcess export FOLDER1=02 SunBackProcess ###### LEADIN 15 Plain backwards LeadBack ###### Composition 14 Tractor backwards export FOLDER2=01 TractorBackProcess export FOLDER1=01 ###### LEADIN 16 Plain backwards LeadBack