#!/bin/bash -x
######################################################################
#2008 Creative2 a kubuntu user
#
# thanks a lot to :
#
#
#
#irc bash script channel for suggestion fix and more thank u guys !!
# prince_jammys
# greycat
# trash
# samuele bordignon
# lhunath
#Irc italian community
#kdenlive team
#and many others
######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see
#NOT IMPLEMETED: AUDIO
# This script is a modification to change random transitions by "dissolve"
version="0.7.8"
tempfolder="/tmp/" ##store the kdenlive's project
listoffile="/tmp/l2.txt"
profile="/home/quercus/.kde/share/apps/kdenlive/profiles/customprofile0"
## Luma folder
numberoffiles=$(wc -l "$listoffile" | awk '{print $1}') ##get the number of files on "$listoffile"
timeforpicture="$1"
transitiontime="$2"
tv="$3"
case $tv in
[n/N]|[t/T][s/S][c/C])
tv="NTSC"
lumafolder="$HOME/slidelumafolder/NTSC"
;;
[p/P]|[p/P][a/A][l/L])
tv="PAL"
lumafolder="$HOME/slidelumafolder/PAL"
;;
esac
aspectratio="$4"
cd "$lumafolder" ## go in the luma folder
lumaarray=(*) ## create a array with name's luma files
echo total pgm files.."${#lumaarray[@]}" ## print how many files there are in the folder
##FUNCTION HELP
functionhelp(){
echo "Script version $version tested on kdenlive:
0.7.2
0.7.3
0.7.4
0.7.4 svn
mlt:
0.3.7
0.3.8
0.3.9
0.4.0
0.4.1
0.4.2
0.4.3"
echo "
WHAT'S IT:
hi this script generates a kdenlive project automatically to create a presentation from
pictures.
INFO:
--luma folder is here : $HOME/slidelumafolder
--kdenlive temp files are here : $tempfolder/automaticslide.kdenlive
--list of files MUST BE HERE : $listoffile
USE:
** akw -h print this help
akw
example:
akw 4 1 PAL 1
4 Seconds for file
1 second for transition
PAL standard tv for europe region
1 aspect ratio for the picture, you should write always 1
"
}
#if [[ $1==-h ]];then
#functionhelp
#exit 1
#elif [[ ! $1 || ! $2 || ! $3 || ! $4 ]] ; then
# functionhelp && echo "sorry you have to type at least 4 input"
#exit 1
#fi
##############FUNCTION CHECK#######################
#
#
functionkdenlivechecking(){
version=$(kdenlive --version | awk '/Kdenlive:/{print $2}')
if [[ "$version"=="0.7.4" ]]; then
echo "This script was tested on kdenlive 0.7.4 and you have it :)"
else
echo "your kdenlive version is $vesion , you could get some problem this script is tested on
kdenlive 0.7.4! but it should work fine on kdenlive 0.7.3 and 0.7.2 older version are not supported!"
fi
#compiing luma file in you home
#check if exist and is empty a folder...
if ( shopt -s nullglob dotglob; f=($HOME/slidelumafolder/*); ((${#f[@]})) );then
echo "checking $HOME/slidelumafolder/...Luma folder exist and is not empty...ok"
else
if [[ ! -e $HOME/slidelumafolder ]];then
mkdir $HOME/slidelumafolder
mkdir $HOME/slidelumafolder/PAL
mkdir $HOME/slidelumafolder/NTSC
fi
if ! type -p convert >/dev/null; #if doesn't exist kdialog...
then
echo "Please install imagemagick"
echo
echo "Debian sudo apt-get install imagemagick"
exit
fi
for var in /usr/share/mlt/lumas/NTSC/*.png ; do
mynamevariable="${var##*/}" #2 get the name only
#cp "$var" "$HOME/slidelumafolder/NTSC/$mynamevariable"
mynamevari="${var##*/}"
mynamevariable="${mynamevari%%.*}"
convert "$var" "$HOME/slidelumafolder/NTSC/$mynamevariable.pgm " #convert #pgm
done
for var in /usr/share/mlt/lumas/PAL/* ; do
mynamevariable="${var##*/}" #2 get the name only
echo "cp "$var" "$HOME/slidelumafolder/$mynamevariable""
#cp "$var" "$HOME/slidelumafolder/PAL/$mynamevariable"
mynamevari="${var##*/}"
mynamevariable="${mynamevari%%.*}"
convert "$var" "$HOME/slidelumafolder/PAL/$mynamevariable.pgm"
echo "done!"
done
kdialog --passivepopup "Please remake presentation"
exit
fi
if [[ ! -e $listoffile ]];then
functionhelp
echo "$listoffile where is ??"
exit 1
fi
}
##############FUNCTION CHECK end #######################
##############dissolve effect#######################################à
dissolveeven(){
number=0 #initialize
echo "effect applied dissolve" # print the name of luma files
outslide=$(($2-1))
echo "">> "$tempfolder"/automaticslide.kdenlive
echo "4" >>"$tempfolder"/automaticslide.kdenlive
echo "5" >>"$tempfolder"/automaticslide.kdenlive
echo "loader" >>"$tempfolder"/automaticslide.kdenlive
echo "transition" >>"$tempfolder"/automaticslide.kdenlive
echo "luma" >>"$tempfolder"/automaticslide.kdenlive
echo "1" >>"$tempfolder"/automaticslide.kdenlive
echo "dissolve" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo " " >>"$tempfolder"/automaticslide.kdenlive
}
dissolveodd(){
number=0 #initialize
echo "effect applied dissolve" # print the name of luma files
outslide=$(($2-1))
echo "">> "$tempfolder"/automaticslide.kdenlive
echo "4" >>"$tempfolder"/automaticslide.kdenlive
echo "5" >>"$tempfolder"/automaticslide.kdenlive
echo "loader" >>"$tempfolder"/automaticslide.kdenlive
echo "transition" >>"$tempfolder"/automaticslide.kdenlive
echo "luma" >>"$tempfolder"/automaticslide.kdenlive
echo "1" >>"$tempfolder"/automaticslide.kdenlive
echo "dissolve" >>"$tempfolder"/automaticslide.kdenlive
echo "1" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo "0" >>"$tempfolder"/automaticslide.kdenlive
echo " " >>"$tempfolder"/automaticslide.kdenlive
}
############################START THE SCRIPT############################################
functionkdenlivechecking #START FUNCTION functionkdenlivechecking
if [ ! -d /tmp/automaticslide/ ]; then mkdir "$tempfolder"; fi #if there is not the temp folder create it !
###################create the correct wisley configuration file###################################
#
if [[ -e $tempfolder/automaticslide.kdenlive ]]; then #check If exist old project
rm $tempfolder/automaticslide.kdenlive #Remove it!
fi
############REMOVE OLD CONFIGURATION####################### OBSOLETE
if [[ -e /tmp/nowarslide.txt ]]; then
rm /tmp/nowarslide.txt
fi
##########################################################
#Print some stuff#
#
echo "total files... "$numberoffiles""
echo "time for picture "$timeforpicture""
echo "time for transition "$transitiontime""
echo "tv...."$tv""
###############set frame for seconds##############################
if [[ "$tv" == "PAL" ]] ; then
frameforsecond="24"
echo "frame for second $frameforsecond"
elif [[ "$tv" == "NTSC" ]] ; then
frameforsecond="30"
echo "frame for second $frameforsecond"
else
frameforsecond="$tv"
echo "frame for second $frameforsecond"
fi
##################################################################################
#
#
#
################start to write project#############################################
echo "" >>$tempfolder/automaticslide.kdenlive
echo "" >> $tempfolder/automaticslide.kdenlive
###################################################################################
number=1
numberoftransition=$(($numberoffiles-1)) #set number of transition = number of photos -1
totalframeforpicture=$(($frameforsecond*$timeforpicture )) #set number of frame for photo = frame for second * time for picture
totalframefortransition=$(($frameforsecond*$transitiontime )) # number of frames for transition ...
echo "start first transition...$(($totalframeforpicture-$totalframefortransition))" >> $tempfolder/automaticslide.log
echo "end fist transition...$totalframeforpicture" >> $tempfolder/automaticslide.log
firstduration=$(($totalframeforpicture-$totalframefortransition))
secondduration=$(($totalframeforpicture-$((2*$totalframefortransition))))
totalframeformyslide=$(($(($numberoffiles*$(($totalframeforpicture-$totalframefortransition))))+$totalframefortransition))
echo "total frame $totalframeformyslide" >> $tempfolder/automaticslide.log
totalsecondsforslide="$(($totalframeformyslide/$frameforsecond))"
echo "total second for slide $totalsecondsforslide" >> $tempfolder/automaticslide.log
####################create id start###################################################################################
###################end random effect#####################################
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo "producer" >> "$tempfolder"/automaticslide.kdenlive
echo "0.000000" >> "$tempfolder"/automaticslide.kdenlive
echo "15000" >> "$tempfolder"/automaticslide.kdenlive
echo "pause" >> "$tempfolder"/automaticslide.kdenlive
echo "black" >> "$tempfolder"/automaticslide.kdenlive
echo "colour" >> "$tempfolder"/automaticslide.kdenlive
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo " " >> "$tempfolder"/automaticslide.kdenlive
if [[ ! "$5" ]] ; then #if therere is not audio then..
echo " " >> "$tempfolder"/automaticslide.kdenlive
else
echo " " >> "$tempfolder"/automaticslide.kdenlive
echo "" >> "$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
fi
echo " " >> "$tempfolder"/automaticslide.kdenlive
####create producer for every file##############################
a=1
while read line
do
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "producer" >>"$tempfolder"/automaticslide.kdenlive
echo "1" >>"$tempfolder"/automaticslide.kdenlive
echo "15000" >>"$tempfolder"/automaticslide.kdenlive
echo "pause" >>"$tempfolder"/automaticslide.kdenlive
echo "$line" >>"$tempfolder"/automaticslide.kdenlive
echo "25" >>"$tempfolder"/automaticslide.kdenlive
echo "1" >>"$tempfolder"/automaticslide.kdenlive
echo "pixbuf" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
a=$(($a+1))
done < "$listoffile"
####create producer for every file END##############################
################################start odd files############################################
number=0
while [ $(($((2*$number))+1)) -le "$numberoffiles" ]
do
echo iniziale $(($((2*$number))+1))
if [[ $(($((2*$number))+1)) == 1 ]] ; then
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
number=$(($number+1 ))
else
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
number=$(($number+1 ))
fi
done
echo "" >>"$tempfolder"/automaticslide.kdenlive
##########################create playlist 2 even files###############################################
number=1
while [ $((2*$number)) -le "$numberoffiles" ]
do
echo iniziale $((2*$number))
############first file must print playlist id too#######################
if [[ $(( 2*$number )) == 2 ]] ; then
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "">>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
number=$(($number+1 ))
########the normal file must print only they own stuff#################
else
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
number=$(($number+1 ))
fi
done
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo " " >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "">>"$tempfolder"/automaticslide.kdenlive
count=1
countoftransition=$(($numberoffiles-1))
files="/tmp/nowar.nowar"
echo $(($count*$totalframeforpicture ))
echo "count of file " "$count"
echo "count of transition $countoftransition"
pointofend=$(($numberoffiles-1 ))
while [ $((2*$count)) -le "$pointofend" ]
do
##correction=$(($((3*$count))+2))
correction=0
echo "start"
transitionstart=$(($(($((2*$count))*$totalframeforpicture ))- $(($((2*$count))*$totalframefortransition ))))
transitionend=$(($(($((2*$count))*$totalframeforpicture ))- $(($(($(($((2*$count))-1 ))*$totalframefortransition ))))+$correction))
# randomeffectlumaeven $transitionstart $transitionend $((2*$count))
dissolveeven $transitionstart $transitionend $((2*$count))
transitionend=$(($transitionend-$correction))
count=$(($count+1 ))
done
#######random effect odd
count=0
while [ $(($((2*$count))+1)) -le "$pointofend" ]
do
echo "start"
##correction=$(($((3*$count))+2))
correction=0
odd=$(($((2*$count))+1))
transitionstart=$(($(($odd*$totalframeforpicture ))- $(($odd*$totalframefortransition ))))
transitionend=$(($(($odd*$totalframeforpicture ))- $(($(($(($odd-1 ))*$totalframefortransition ))))+$correction))
#randomeffectlumaoodd $transitionstart $transitionend $((2*$count))
dissolveodd $transitionstart $transitionend $((2*$count))
count=$(($count+1 ))
done
echo "" >>"$tempfolder"/automaticslide.kdenlive
#echo "" >>"$tempfolder"/automaticslide.kdenlive
#echo "" >>"$tempfolder"/automaticslide.kdenlive
#echo " " >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo " " >>"$tempfolder"/automaticslide.kdenlive
nlist=1
while read line
do
namepicture=$(basename "$line")
echo " " >>"$tempfolder"/automaticslide.kdenlive
nlist=$(($nlist+1))
done < "$listoffile"
if [[ ! "$5" ]] ; then #if therere is not audio then..
echo "no audio"
else
echo " " >>"$tempfolder"/automaticslide.kdenlive
fi
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo "" >>"$tempfolder"/automaticslide.kdenlive
echo ""
echo "file generated here $tempfolder/automaticslide.kdenlive"