| 1 |
#!/usr/bin/env bash |
| 2 |
# dir2slideshow |
| 3 |
# Copyright 2004-2008 Scott Dylewski <scott at dylewski.com> |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 2 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 |
# |
| 19 |
|
| 20 |
version='0.8.4-2' |
| 21 |
# TODO: use exiftool instead of jhead! |
| 22 |
|
| 23 |
changes () |
| 24 |
{ |
| 25 |
echo 'Changes: |
| 26 |
0.8.4-2 |
| 27 |
There was a problem finding images... Should be fixed now. |
| 28 |
0.8.4 |
| 29 |
Fixes for file counts and uppercase extensions (thanks Eric Baplue) |
| 30 |
Allow reading of dvd-slideshowrc file to set variables (thanks Johan Kunnen) |
| 31 |
Reads .avi files for dvd-slideshow (thanks Guy Albertelli) |
| 32 |
Add -q (quiet mode) for less output on screen when calling from another script |
| 33 |
0.8.2 |
| 34 |
Write out pal option to output file if selected in dir2slideshow |
| 35 |
Recursive finds follow symbolic links and ignores hidden directories. |
| 36 |
Bug fix for spaces in filenames (thanks Ken Zutter) |
| 37 |
Fixed bug where .mp3 files were being treated as images (crossfade error) |
| 38 |
Fixed bug where other file formats would be included in the listing (thanks Mridul) |
| 39 |
Fixed bug where audio files were not included in output. |
| 40 |
Allow spaces in output files if spaces is used as filename |
| 41 |
0.8.0 |
| 42 |
Add audiobook option- looks for audio files and images & adds titles |
| 43 |
Allow wipe effect as default between images -w duration |
| 44 |
Allow decimals in crossfade duration. |
| 45 |
Allow two different subtitles -s or -s2 |
| 46 |
Add random kenburns effect (-k) |
| 47 |
Output file is copied to screen while running |
| 48 |
Full paths are specified to images in output .txt file. |
| 49 |
Start of themes being implemented. See theme documentation. |
| 50 |
Add subtitle options to add path and/or filename. (Thanks Kenneth Weinert) |
| 51 |
Add recursive directory search. -R and -r (Thanks Kenneth Weinert) |
| 52 |
Removed seq calls for compatibility with FreeBSD |
| 53 |
0.7.5 Allow spaces in filenames. |
| 54 |
0.7.4 No changes |
| 55 |
0.7.3 |
| 56 |
Passing -c 0 does not create crossfades. |
| 57 |
Added option -notitle |
| 58 |
Added option to specify background color or image -b image.jpg |
| 59 |
Fix output of "backgound:0:black" on first line. |
| 60 |
It should read "background:0::black" |
| 61 |
0.7.2 Added option to have all subtitles the same -s |
| 62 |
0.7.1 Reads .jpg .JPG .jpeg .png .PNG files in the specified directory |
| 63 |
0.1.0 Change version number |
| 64 |
0.0.1 Initial release' |
| 65 |
} |
| 66 |
|
| 67 |
help () |
| 68 |
{ |
| 69 |
echo "dir2slideshow $version" |
| 70 |
echo "dir2slideshow is part of the dvd-slideshow set of tools." |
| 71 |
echo 'Copyright 2004-2005 Scott Dylewski <scott at dylewski.com>' |
| 72 |
echo 'http://freshmeat.net/dvdslideshow' |
| 73 |
echo ' |
| 74 |
dir2slideshow description: |
| 75 |
Generates a listing of the pictures in a given directory for easy |
| 76 |
input to dvd-slideshow. |
| 77 |
|
| 78 |
Usage: |
| 79 |
dir2slideshow [-o <output_directory>] [-t time_per_picture] [-c duration] |
| 80 |
-n slideshow_name [-T] [-M] [-s subtitle_text] [-notitle] [-k] [-theme <themefile>] [-a <audiofile1>,<audiofile2>,...] <directory> |
| 81 |
|
| 82 |
Options: |
| 83 |
<directory> |
| 84 |
Input directory of pictures. |
| 85 |
|
| 86 |
-n slideshow_name |
| 87 |
Name of the slideshow. This will be used in the title slide |
| 88 |
as well as for the output file name. |
| 89 |
|
| 90 |
[-o output_directory] |
| 91 |
Path to the directory where you want to output file written. |
| 92 |
No output directory chooses current directory. |
| 93 |
|
| 94 |
[-t time_per_picture] |
| 95 |
Integer number of seconds that the picture will be visible |
| 96 |
on the dvd movie. You can edit the output file to make |
| 97 |
changes to specific lines. Default is 5 seconds. |
| 98 |
|
| 99 |
[-c duration] |
| 100 |
Add a crossfade between every picture for duration seconds. |
| 101 |
|
| 102 |
[-w duration] |
| 103 |
Add a wipe effect between every picture for duration seconds. |
| 104 |
|
| 105 |
[-T] Sort by the JPEG header picture taken date, then the file |
| 106 |
modified date, and then the filename. Default sorts by |
| 107 |
name only |
| 108 |
|
| 109 |
[-M] Sort by the the file modified date, and then the filename. |
| 110 |
Default sorts by name only. |
| 111 |
|
| 112 |
[-s "subtitle text"] |
| 113 |
Add default subtitle "subtitle_text" to every slide |
| 114 |
Use "-s filename" to display filename as the subtitle. |
| 115 |
Use "-s path" to display filename&path as the subtitle. |
| 116 |
|
| 117 |
[-s2 "subtitle text"] |
| 118 |
Same as -s option, but adds subtitles to subtitle track 2 |
| 119 |
|
| 120 |
[-b background.jpg] |
| 121 |
Use background.jpg as background image. Default is black. |
| 122 |
|
| 123 |
[-notitle] Do not create a title slide. |
| 124 |
|
| 125 |
[-nofades] Do not create fades at start and end of slideshow. |
| 126 |
|
| 127 |
[-r] Recursively search directories for images, |
| 128 |
creating one output file. |
| 129 |
|
| 130 |
[-R] (not working yet) |
| 131 |
Recursively search directories for images, |
| 132 |
creating one output file for each directory. |
| 133 |
|
| 134 |
[-k] Apply random kenburns effects to each slide |
| 135 |
|
| 136 |
[-p] Use PAL output video format instead of NTSC |
| 137 |
|
| 138 |
[-theme themefile.theme] BETA |
| 139 |
Use theme themefile.theme for consistent look & feel |
| 140 |
|
| 141 |
[-a <audiofile1>,<audiofile2>,...] |
| 142 |
Use the following audio files in the slideshow. |
| 143 |
Files will be played sequentially for the duration of |
| 144 |
the slideshow. Use quotes if you have spaces in filenames. |
| 145 |
|
| 146 |
[-B] Use audiobook format. This will look for individual audio files |
| 147 |
along with images, and also add titles. You wil probably have to |
| 148 |
modify the output to your liking, but this should give you a start. |
| 149 |
(alpha!) do not use yet. |
| 150 |
[-q] Quiet mode. Less on-scren output. |
| 151 |
|
| 152 |
-h or -help |
| 153 |
Prints this help. |
| 154 |
' |
| 155 |
} |
| 156 |
|
| 157 |
if [ $# -lt 1 ]; then |
| 158 |
help |
| 159 |
exit 1 |
| 160 |
fi |
| 161 |
|
| 162 |
myecho () ## create new echo to bounce things to files, etc. |
| 163 |
{ |
| 164 |
if [ "$quiet" == 0 ]; then echo "$1" ; fi |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
set_variables () |
| 169 |
{ |
| 170 |
## check for config variables: |
| 171 |
config1=`echo "$1" | cut -d= -f1 | tr -d [:blank:]` |
| 172 |
config2=`echo "$1" | tr '\t' ' ' | cut -d= -f2 | tr -d '\047' | tr -d '\042' | awk -F' #' '{print $1}' | tr -d [:blank:]` |
| 173 |
[ -n "$2" -a "$2" == 1 ] && noecho=1 || noecho=0 |
| 174 |
## check for global configuration variables: |
| 175 |
case "$config1" in |
| 176 |
# title |
| 177 |
debug) debug="$config2" ; [ "$noecho" -eq 0 ] && echo "debug=$debug" ;; |
| 178 |
# title_font) title_font="$config2" ; [ "$noecho" -eq 0 ] && echo "title_font=$title_font" ;; |
| 179 |
# subtitle_font) subtitle_font="$config2" ; [ "$noecho" -eq 0 ] && echo "subtitle_font=$subtitle_font" ;; |
| 180 |
title_font_size) title_font_size="$config2" ; [ "$noecho" -eq 0 ] && echo "title_font_size=$title_font_size" ;; |
| 181 |
title_font_color) title_font_color="$config2" ; [ "$noecho" -eq 0 ] && echo "title_font_color=$title_font_color" ;; |
| 182 |
# top title |
| 183 |
toptitle_font_size) toptitle_font_size="$config2" ; [ "$noecho" -eq 0 ] && echo "toptitle_font_size=$toptitle_font_size" ;; |
| 184 |
toptitle_font_color) toptitle_font_color="$config2" ; [ "$noecho" -eq 0 ] && echo "toptitle_font_color=$toptitle_font_color" ;; |
| 185 |
toptitle_bar_height) toptitle_bar_height="$config2" ; [ "$noecho" -eq 0 ] && echo "toptitle_bar_height=$toptitle_bar_height" ;; |
| 186 |
toptitle_text_location_x) toptitle_text_location_x="$config2" ; [ "$noecho" -eq 0 ] && echo "toptitle_text_location_x=$toptitle_text_location_x" ;; |
| 187 |
toptitle_text_location_y) toptitle_text_location_y="$config2" ; [ "$noecho" -eq 0 ] && echo "toptitle_text_location_y=$toptitle_text_location_y" ;; |
| 188 |
# bottom title |
| 189 |
bottomtitle_font_size) bottomtitle_font_size="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_font_size=$bottomtitle_font_size" ;; |
| 190 |
bottomtitle_font_color) bottomtitle_font_color="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_font_color=$bottomtitle_font_color" ;; |
| 191 |
bottomtitle_bar_location_y) bottomtitle_bar_location_y="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_bar_location_y=$bottomtitle_bar_location_y" ;; |
| 192 |
bottomtitle_bar_height) bottomtitle_bar_height="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_bar_height=$bottomtitle_bar_height" ;; |
| 193 |
bottomtitle_text_location_x) bottomtitle_text_location_x="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_text_location_x=$bottomtitle_text_location_x" ;; |
| 194 |
bottomtitle_text_location_y) bottomtitle_text_location_y="$config2" ; [ "$noecho" -eq 0 ] && echo "bottomtitle_text_location_y=$bottomtitle_text_location_y" ;; |
| 195 |
## dir2slideshow options: |
| 196 |
slideshow_background) background="$config2" ; [ "$noecho" -eq 0 ] && echo "background=$background" ;; |
| 197 |
title_background) title_background="$config2" ; [ "$noecho" -eq 0 ] && echo "title_background=$title_background" ;; |
| 198 |
crossfade) crossfade="$config2" ; [ "$noecho" -eq 0 ] && echo "crossfade=$crossfade" ;; |
| 199 |
wipe) wipe="$config2" ; [ "$noecho" -eq 0 ] && echo "wipe=$wipe" ;; |
| 200 |
kenburns) kenburns="$config2" ; [ "$noecho" -eq 0 ] && echo "kenburns=$kenburns" ;; |
| 201 |
pal) pal="$config2" ; [ "$noecho" -eq 0 ] && echo "pal=$pal" ;; |
| 202 |
slide_duration) slide_duration="$config2" ; [ "$noecho" -eq 0 ] && echo "slide_duration=$slide_duration" ;; |
| 203 |
title_type) title_type="$config2" ; [ "$noecho" -eq 0 ] && echo "title_type=$title_type" ;; |
| 204 |
slideshow_audio) audio_list="$config2" ; [ "$noecho" -eq 0 ] && echo "audio_list=$audio_list" ;; |
| 205 |
subtitle) subtitle="$config2" ; [ "$noecho" -eq 0 ] && echo "subtitle=$subtitle" ;; |
| 206 |
subtitle2) subtitle2="$config2" ; [ "$noecho" -eq 0 ] && echo "subtitle2=$subtitle2" ;; |
| 207 |
slideshow_end) slideshow_end[$end]="$config2" ; [ "$noecho" -eq 0 ] && echo "slideshow_end[$end]=${slideshow_end[$end]}"; end=$(($end+1)) ;; |
| 208 |
audiobook) audiobook="$config2" ; [ "$noecho" -eq 0 ] && echo "audiobook=$audiobook" ;; |
| 209 |
picture_files) picture_files="$config2" ; [ "$noecho" -eq 0 ] && echo "picture_files=$picture_files" ;; |
| 210 |
audio_files) audio_files="$config2" ; [ "$noecho" -eq 0 ] && echo "audio_files=$audio_files" ;; |
| 211 |
video_files) video_files="$config2" ; [ "$noecho" -eq 0 ] && echo "video_files=$video_files" ;; |
| 212 |
text_files) text_files="$config2" ; [ "$noecho" -eq 0 ] && echo "text_files=$text_files" ;; |
| 213 |
esac |
| 214 |
} |
| 215 |
|
| 216 |
full_path () # from Shea Martin with fix by Ken Zutter for spaces in filenames |
| 217 |
{ |
| 218 |
if [ -f "$1" ]; then |
| 219 |
DIR="$(dirname "$1")" |
| 220 |
DIR=$(cd "$DIR" && pwd) |
| 221 |
FILE="$(basename "$1")" |
| 222 |
RSLT=$? |
| 223 |
echo "$DIR/$FILE" |
| 224 |
return $RSLT |
| 225 |
|
| 226 |
elif [ -d "$1" ]; then |
| 227 |
cd "$DIR" && pwd && cd $OLDPWD |
| 228 |
return $? |
| 229 |
|
| 230 |
else |
| 231 |
echo "unknown file: $1" |
| 232 |
return 1 |
| 233 |
fi |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
## setup initial variables: |
| 239 |
#picture_files="-name *.JPG -o -name *.jpg -o -name *.png -o -name *.PNG -o -name *.jpeg -o -name *.JPEG" |
| 240 |
#audio_files="-name *.mp3 -o -name *.MP3 -o -name *.ogg -o -name *.OGG" |
| 241 |
#video_files="-name *.avi -o -name *.AVI" |
| 242 |
#text_files="-name *.txt -o -name *.TXT" |
| 243 |
LANG=POSIX |
| 244 |
debug=0 # 1 or 0 |
| 245 |
quiet=0 |
| 246 |
crossfade=0 |
| 247 |
wipe=0 |
| 248 |
slide_duration=5 |
| 249 |
output_dir="." |
| 250 |
input_dir="" |
| 251 |
name='' |
| 252 |
sortmethod='' |
| 253 |
title=1 |
| 254 |
fades=1 |
| 255 |
background='' |
| 256 |
title_background='' |
| 257 |
audiobook=0 |
| 258 |
kenburns=0 |
| 259 |
vcd=0; svcd=0 |
| 260 |
theme='' |
| 261 |
themedir='/opt/dvd-slideshow/themes' # LSB/FHS compliant. see http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES |
| 262 |
local_themedir=~/.dvd-slideshow/themes # location of local themes directory (do not use quotes) |
| 263 |
title_type='title' |
| 264 |
audio_list='' |
| 265 |
recursive_single=0 |
| 266 |
recursive_multiple=0 |
| 267 |
end=1 |
| 268 |
pal=0 # default to ntsc |
| 269 |
sortmethod="name" # sort by filename as default sort method |
| 270 |
|
| 271 |
|
| 272 |
######################################################### |
| 273 |
## read in command-line args: |
| 274 |
for arg |
| 275 |
do |
| 276 |
case "$arg" in |
| 277 |
-i) shift; commandline_input_dir="$1" ; shift ;; |
| 278 |
-n) shift; commandline_name="$1" ; shift ;; |
| 279 |
-s) shift; commandline_subtitle="$1" ; shift ;; |
| 280 |
-s2) shift; commandline_subtitle2="$1" ; shift ;; |
| 281 |
-b) shift; commandline_background="$1" ; shift ;; |
| 282 |
-tb) shift; commandline_title_background="$1" ; shift ;; |
| 283 |
-notitle) commandline_title=0 ; shift ;; |
| 284 |
-nofades) commandline_fades=0 ; shift ;; |
| 285 |
-B) commandline_audiobook=1 ; shift ;; |
| 286 |
-k) commandline_kenburns=1 ; shift ;; |
| 287 |
-r) commandline_recursive_single=1 ; shift ;; |
| 288 |
-R) commandline_recursive_multiple=1 ; shift ;; |
| 289 |
-vcd) commandline_vcd=1 ; shift ;; |
| 290 |
-svcd) commandline_svcd=1 ; shift ;; |
| 291 |
-p) commandline_pal=1 ; shift ;; # required if -k specified. |
| 292 |
-n) commandline_pal=0 ; shift ;; # required if -k specified. |
| 293 |
-q) quiet=1; shift ;; # enable quiet mode |
| 294 |
-o) shift; output_dir="$1"; shift ;; |
| 295 |
-t) shift; commandline_duration="$1"; shift ;; |
| 296 |
-T) commandline_sortmethod="taken_date"; shift ;; |
| 297 |
-M) commandline_sortmethod="modified_date"; shift ;; |
| 298 |
-S) commandline_sortmethod="normal"; shift ;; |
| 299 |
-c) shift; commandline_crossfade="$1"; shift ;; |
| 300 |
-w) shift; commandline_wipe="$1"; shift ;; |
| 301 |
-theme) shift; theme="$1"; shift ;; |
| 302 |
-a) shift; commandline_audio_list="$1"; shift ;; |
| 303 |
-h) help ; exit 0 ; shift ;; |
| 304 |
-?) help ; exit 0 ; shift ;; |
| 305 |
-help) help ; exit 0 ; shift ;; |
| 306 |
esac |
| 307 |
done |
| 308 |
|
| 309 |
myecho "[dir2slideshow] dir2slideshow version $version" |
| 310 |
|
| 311 |
############################################################# |
| 312 |
## Now, read in the ~/.dvd-slideshow/dvd-slideshowrc file if it exists: |
| 313 |
if [ -f "${HOME}/.dvd-slideshow/dvd-slideshowrc" ] ; then |
| 314 |
myecho "[dir2slideshow] Reading default variables in ${HOME}/.dvd-slideshow/dvd-slideshowrc" |
| 315 |
while read thisline |
| 316 |
do |
| 317 |
it=`set_variables "${thisline}" 0` |
| 318 |
if [ -n "$it" ] ; then |
| 319 |
myecho "[dir2slideshow] Set variable $it" |
| 320 |
continue |
| 321 |
fi |
| 322 |
done < "$HOME/.dvd-slideshow/dvd-slideshowrc" |
| 323 |
fi |
| 324 |
########################################################### |
| 325 |
## read in theme file: |
| 326 |
if [ -n "$theme" ] && [ "$theme" != 'default' ] ; then |
| 327 |
# check if directory |
| 328 |
if [ -d "$theme" ] ; then |
| 329 |
themedir="$theme" |
| 330 |
themefile="`ls -1 "$theme"/*.theme 2> /dev/null | tail -n 1`" |
| 331 |
if [ -z "$themefile" ] ; then |
| 332 |
myecho "[dir2slideshow] Found theme directory: $themedir" |
| 333 |
echo "[dir2slideshow] ERROR: theme directory does not contain a .theme file!" |
| 334 |
exit 1 |
| 335 |
else |
| 336 |
myecho "[dir2slideshow] setting theme file to $theme" |
| 337 |
fi |
| 338 |
elif [ -f "$theme" ] ; then |
| 339 |
themefile="`full_path "$theme"`" |
| 340 |
themedir="`dirname "$theme"`" |
| 341 |
myecho "[dir2slideshow] using theme file $theme" |
| 342 |
else |
| 343 |
# check in default theme directory: |
| 344 |
if [ -d "$themedir"/"$theme" ] ; then |
| 345 |
themedir="$themedir"/"$theme" |
| 346 |
themefile="`ls -1 "$themedir"/*.theme 2> /dev/null | tail -n 1`" |
| 347 |
if [ -z "$themefile" ] ; then |
| 348 |
myecho "[dir2slideshow] Found theme directory: $themedir" |
| 349 |
echo "[dir2slideshow] ERROR: theme directory does not contain a .theme file!" |
| 350 |
exit 1 |
| 351 |
else |
| 352 |
myecho "[dir2slideshow] setting theme file to $themefile" |
| 353 |
fi |
| 354 |
# check in local theme directory |
| 355 |
elif [ -d "$local_themedir"/"$theme" ] ; then |
| 356 |
themedir="$local_themedir"/"$theme" |
| 357 |
themefile="`ls -1 "$themedir"/*.theme 2> /dev/null | tail -n 1`" |
| 358 |
if [ -z "$themefile" ] ; then |
| 359 |
myecho "[dir2slideshow] Found theme directory: $themedir" |
| 360 |
echo "[dir2slideshow] ERROR: theme directory does not contain a .theme file!" |
| 361 |
exit 1 |
| 362 |
else |
| 363 |
myecho "[dir2slideshow] setting theme file to $themefile" |
| 364 |
fi |
| 365 |
else |
| 366 |
echo "[dir2slideshow] ERROR! Bad theme name (not found)" |
| 367 |
exit 1 |
| 368 |
fi |
| 369 |
fi |
| 370 |
myecho "[dir2slideshow] Reading theme file..." |
| 371 |
while read thisline |
| 372 |
do |
| 373 |
set_variables "${thisline}" 1 |
| 374 |
it=`set_variables "${thisline}" 0` |
| 375 |
if [ -n "$it" ] ; then |
| 376 |
myecho "[dir2slideshow] Set variable $it" |
| 377 |
fi |
| 378 |
done < "$themefile" |
| 379 |
fi |
| 380 |
|
| 381 |
## over-ride theme file with command-line options: |
| 382 |
[ -n "$commandline_input_dir" ] && input_dir="$commandline_input_dir" |
| 383 |
[ -n "$commandline_name" ] && name="$commandline_name" |
| 384 |
[ -n "$commandline_subtitle" ] && subtitle="$commandline_subtitle" |
| 385 |
[ -n "$commandline_subtitle2" ] && subtitle2="$commandline_subtitle2" |
| 386 |
[ -n "$commandline_background" ] && background="$commandline_background" |
| 387 |
[ -n "$commandline_title_background" ] && title_background="$commandline_title_background" |
| 388 |
[ -n "$commandline_title" ] && title="$commandline_title" |
| 389 |
[ -n "$commandline_fades" ] && fades="$commandline_fades" |
| 390 |
[ -n "$commandline_kenburns" ] && kenburns="$commandline_kenburns" |
| 391 |
[ -n "$commandline_pal" ] && pal="$commandline_pal" |
| 392 |
[ -n "$commandline_duration" ] && slide_duration="$commandline_duration" |
| 393 |
[ -n "$commandline_crossfade" ] && crossfade="$commandline_crossfade" |
| 394 |
[ -n "$commandline_wipe" ] && wipe="$commandline_wipe" |
| 395 |
[ -n "$commandline_audio_list" ] && audio_list="$commandline_audio_list" |
| 396 |
[ -n "$commandline_recursive_single" ] && recursive_single="$commandline_recursive_single" |
| 397 |
[ -n "$commandline_recursive_multiple" ] && recursive_multiple="$commandline_recursive_multiple" |
| 398 |
[ -n "$commandline_vcd" ] && vcd="$commandline_vcd" |
| 399 |
[ -n "$commandline_svcd" ] && svcd="$commandline_svcd" |
| 400 |
[ -n "$commandline_audiobook" ] && audiobook="$commandline_audiobook" |
| 401 |
[ -n "$commandline_sortmethod" ] && sortmethod="$commandline_sortmethod" |
| 402 |
|
| 403 |
|
| 404 |
if [ -z "$input_dir" ] ; then |
| 405 |
input_dir="$1" |
| 406 |
fi |
| 407 |
if [ -z "$input_dir" ] ; then |
| 408 |
echo '[dir2slideshow] Error: No input directory specified' |
| 409 |
elif [ ! -d "$input_dir" ] ; then |
| 410 |
echo "[dir2slideshow] Error: Input directory is not a real directory: $input_dir" |
| 411 |
fi |
| 412 |
|
| 413 |
## check_rm checks to see if the file exists before it's deleted: |
| 414 |
check_rm () |
| 415 |
{ |
| 416 |
if [ -f "$1" ] ; then |
| 417 |
rm "$1" |
| 418 |
fi |
| 419 |
} |
| 420 |
|
| 421 |
## check for the necessary programs: |
| 422 |
checkforprog () |
| 423 |
{ |
| 424 |
it=`which "$1"` |
| 425 |
if [ -z "$it" ] ; then |
| 426 |
echo "[dir2slideshow] ERROR: $1 not found! " |
| 427 |
echo "[dir2slideshow] Check the dependencies and make sure everything is installed." |
| 428 |
exit 1 |
| 429 |
fi |
| 430 |
} |
| 431 |
|
| 432 |
cleanup () |
| 433 |
{ |
| 434 |
## clean up temporary files |
| 435 |
check_rm "$output_dir/imagelist.txt" |
| 436 |
check_rm "$output_dir/filelist_sorted.txt" |
| 437 |
check_rm "$output_dir/txtlist.txt" |
| 438 |
check_rm "$output_dir/audiolist.txt" |
| 439 |
check_rm "$output_dir/videolist.txt" |
| 440 |
check_rm "$output_dir/directory_list.txt" |
| 441 |
myecho "[dir2slideshow] Done!" |
| 442 |
} |
| 443 |
|
| 444 |
forcequit () ## function gets run when we have some sort of forcequit... |
| 445 |
{ |
| 446 |
## clean up temporary files |
| 447 |
cleanup |
| 448 |
exit 1 |
| 449 |
} |
| 450 |
|
| 451 |
imagewidth () |
| 452 |
{ |
| 453 |
it="`identify -format %w "$1"`" |
| 454 |
it="$(( $it * $sq_pixel_multiplier / 1000 ))" |
| 455 |
echo "$it" |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
imagewidth_sq () |
| 460 |
{ |
| 461 |
it="`identify -format %w "$1"`" |
| 462 |
echo "$it" |
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
imageheight () |
| 467 |
{ |
| 468 |
it="`identify -format %h "$1"`" |
| 469 |
echo "$it" |
| 470 |
} |
| 471 |
|
| 472 |
fileecho () |
| 473 |
{ |
| 474 |
echo "$*" >> "$outfile" |
| 475 |
if [ "$quiet" == 0 ] ; then |
| 476 |
echo "$*" |
| 477 |
fi |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
autocrop_percent () |
| 482 |
{ |
| 483 |
# figure out whether to autocrop the image or not |
| 484 |
image_width=`imagewidth "$1"` |
| 485 |
image_height=`imageheight "$1"` |
| 486 |
ratio="$(( 1000* $image_width / $image_height ))" |
| 487 |
out_ratio="$(( 1000* $dvd_width / $dvd_height ))" |
| 488 |
if [ "$ratio" -lt "$out_ratio" ] ; then |
| 489 |
# image too tall, crop top/bottom |
| 490 |
# calculate new height based on existing width: |
| 491 |
new_image_height=$(( $image_width * $dvd_height / $dvd_width )) |
| 492 |
# echo "new_image_height=$new_image_height" |
| 493 |
percent=$(( 100 * $new_image_height / $image_height )) |
| 494 |
elif [ "$ratio" -gt "$out_ratio" ] ; then |
| 495 |
# image too wide, crop sides |
| 496 |
# calculate new width based on existing height: |
| 497 |
new_image_width=$(( $image_height * $dvd_width / $dvd_height )) |
| 498 |
# echo "new_image_width=$new_image_width" |
| 499 |
percent=$(( 100 * $new_image_width / $image_width )) |
| 500 |
else |
| 501 |
# no cropping of image needed! |
| 502 |
percent=100 |
| 503 |
fi |
| 504 |
# echo "image_width=$image_width image_height=$image_height ratio=$ratio out_ratio=$out_ratio percent=$percent" |
| 505 |
echo "$percent" |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
trap 'forcequit' INT |
| 510 |
trap 'forcequit' KILL |
| 511 |
trap 'forcequit' TERM |
| 512 |
|
| 513 |
if [ "$kenburns" != "0" ] ; then |
| 514 |
kenburns=1 |
| 515 |
if [ -z "$pal" ] ; then |
| 516 |
echo "[dir2slideshow] WARNING: you must specify pal or ntsc" |
| 517 |
echo "[dir2slideshow] with the -p 1/0 option when using -k" |
| 518 |
echo "[dir2slideshow] assuming NTSC." |
| 519 |
pal=0 |
| 520 |
fi |
| 521 |
fi |
| 522 |
|
| 523 |
if [ "$pal" == 1 ] ; then |
| 524 |
framerate='25' |
| 525 |
frames_per_sec=25000 # in ms |
| 526 |
if [ "$vcd" -eq 1 ] ; then |
| 527 |
dvd_width='352' ; dvd_height='288' |
| 528 |
resolution='352x288' |
| 529 |
elif [ "$svcd" -eq 1 ] ; then |
| 530 |
dvd_width='480' ; dvd_height='576' |
| 531 |
resolution='480x576' |
| 532 |
else |
| 533 |
dvd_width='720' ; dvd_height='576' |
| 534 |
resolution='720x576' |
| 535 |
fi |
| 536 |
else ## NTSC |
| 537 |
framerate='29.97' |
| 538 |
frames_per_sec=29970 # in ms |
| 539 |
if [ "$vcd" -eq 1 ] ; then |
| 540 |
dvd_width='352' ; dvd_height='240' |
| 541 |
resolution='352x240' |
| 542 |
elif [ "$svcd" -eq 1 ] ; then |
| 543 |
dvd_width='480' ; dvd_height='480' |
| 544 |
resolution='480x480' |
| 545 |
else |
| 546 |
dvd_width='720' ; dvd_height='480' |
| 547 |
resolution='720x480' |
| 548 |
fi |
| 549 |
fi |
| 550 |
aspect_ratio="4:3" |
| 551 |
resize_factor=`awk -vw=$dvd_width -vh=$dvd_height -var=$aspect_ratio 'BEGIN{if (ar=="4:3"){ar=4/3} else {ar=16/9};printf "%0.2f", (100/((h/w)*(ar)));exit;}'` |
| 552 |
sq_to_dvd_pixels="${resize_factor}x100%" |
| 553 |
sq_pixel_multiplier=$( printf %5.0f $( echo "scale=0; 10 * $resize_factor" | bc ) ) |
| 554 |
|
| 555 |
|
| 556 |
# sanity checking |
| 557 |
# did the user give us a valid input file to work with? |
| 558 |
if [ ! -d "$input_dir" ]; then |
| 559 |
# it's not a directory! |
| 560 |
echo "[dir2slideshow] ERROR: Bogus input directory (-i $input_dir)!" |
| 561 |
exit 1; |
| 562 |
fi |
| 563 |
if [ -z "$name" ]; then |
| 564 |
myecho "[dir2slideshow] WARNING: No slideshow name specified using -n <name>" |
| 565 |
name="$( dirname "$input_dir"/. )" |
| 566 |
name="$( echo $name | awk -F/ '{print $NF}')" |
| 567 |
myecho "[dir2slideshow] Using slideshow name= $name" |
| 568 |
fi |
| 569 |
|
| 570 |
# make sure $input_dir has no trailing slash |
| 571 |
input_dir=`echo "$input_dir" | sed -e 's/\/$//'`; |
| 572 |
|
| 573 |
## check to make sure the "album" name is ok? |
| 574 |
if [ -z "$output_dir" ]; then |
| 575 |
# no output directory specified! |
| 576 |
echo "[dir2slideshow] WARNING: Invalid output destination (-o $output_dir)!"; |
| 577 |
echo "[dir2slideshow] Using `pwd` instead."; |
| 578 |
output_dir="`pwd`"; |
| 579 |
fi |
| 580 |
if [ ! -d "$output_dir" ]; then |
| 581 |
# I'm sure it was a simple typo. |
| 582 |
echo "[dir2slideshow] WARNING: Invalid output destination (-o $output_dir)!"; |
| 583 |
echo "[dir2slideshow] Using $input_dir instead."; |
| 584 |
output_dir="$input_dir"; |
| 585 |
fi |
| 586 |
|
| 587 |
# make sure $output_dir has no trailing slash |
| 588 |
output_dir=`echo "$output_dir" | sed -e 's/\/$//'`; |
| 589 |
|
| 590 |
#outfile="$output_dir"/"`echo "$name" | sed -e 's/ /_/g'`.txt" |
| 591 |
outfile="$output_dir"/"$name".txt |
| 592 |
|
| 593 |
myecho "[dir2slideshow] Input directory = $input_dir" |
| 594 |
myecho "[dir2slideshow] Slideshow name = $name" |
| 595 |
myecho "[dir2slideshow] Output file = $outfile" |
| 596 |
|
| 597 |
## now, summarize settings: |
| 598 |
if [ "$quiet" == 0 ] ; then |
| 599 |
echo [dir2slideshow] subtitle="$subtitle" |
| 600 |
echo [dir2slideshow] subtitle2="$subtitle2" |
| 601 |
echo [dir2slideshow] background="$background" |
| 602 |
echo [dir2slideshow] title_background="$title_background" |
| 603 |
echo [dir2slideshow] title="$title" |
| 604 |
echo [dir2slideshow] kenburns="$kenburns" |
| 605 |
echo [dir2slideshow] pal="$pal" |
| 606 |
echo [dir2slideshow] output_dir="$output_dir" |
| 607 |
echo [dir2slideshow] slide_duration="$slide_duration" |
| 608 |
echo [dir2slideshow] sortmethod="$sortmethod" |
| 609 |
echo [dir2slideshow] crossfade="$crossfade" |
| 610 |
echo [dir2slideshow] wipe="$wipe" |
| 611 |
echo [dir2slideshow] title_type="$title_type" |
| 612 |
echo [dir2slideshow] themefile="$themefile" |
| 613 |
echo [dir2slideshow] audio_list="$audio_list" |
| 614 |
fi |
| 615 |
|
| 616 |
## cleanup the workfiles |
| 617 |
check_rm "$output_dir"/imagelist.txt |
| 618 |
check_rm "$output_dir"/audiolist.txt |
| 619 |
check_rm "$output_dir"/videolist.txt |
| 620 |
# check_rm "$output_dir"/txtlist.txt |
| 621 |
|
| 622 |
## find all files: |
| 623 |
if [ "$recursive_single" == 1 ] ; then |
| 624 |
# need to list all images under this directory. |
| 625 |
# put them all in one slideshow |
| 626 |
# do not display images under .thumbs or .thumbnails directories |
| 627 |
|
| 628 |
# first, get list of directories: |
| 629 |
find "$input_dir" -type d | grep --invert-match -e '\.' | grep --invert-match -e '\/tn$' | sort > "$output_dir"/directory_list.txt |
| 630 |
|
| 631 |
while read directory |
| 632 |
do |
| 633 |
# find "$directory" -maxdepth 1 -type f -prune \( $picture_files \) | sort >> "$output_dir"/imagelist.txt |
| 634 |
# find "$directory" -maxdepth 1 -type f -prune \( $audio_files \) | sort >> "$output_dir"/audiolist.txt |
| 635 |
# find "$directory" -maxdepth 1 -type f -prune \( $video_files \) | sort >> "$output_dir"/videolist.txt |
| 636 |
# find "$directory" -maxdepth 1 -type f \( $text_files \) -exec ls -1 {} \; | sort >> "$output_dir"/txtlist.txt |
| 637 |
find "$directory" -maxdepth 1 -type f -prune \( -name \*.JPG -o -name \*.jpg -o -name \*.png -o -name \*.PNG -o -name \*.jpeg -o -name \*.JPEG \) | sort >> "$output_dir"/imagelist.txt |
| 638 |
find "$directory" -maxdepth 1 -type f -prune \( -name \*.mp3 -o -name \*.MP3 -o -name \*.ogg -o -name \*.OGG \) | sort >> "$output_dir"/audiolist.txt |
| 639 |
find "$directory" -maxdepth 1 -type f -prune \( -name \*.avi -o -name \*.AVI \) | sort >> "$output_dir"/videolist.txt |
| 640 |
done < "$output_dir"/directory_list.txt |
| 641 |
|
| 642 |
elif [ "$recursive_multiple" == 1 ] ; then |
| 643 |
echo "[dir2slideshow] -R not supported yet"; exit 1 |
| 644 |
# do find, then check each file if it is a directory: |
| 645 |
else # default case |
| 646 |
# ok, we need to follow links, but don't do recursive directory searching |
| 647 |
# find "$input_dir" -maxdepth 1 \( -type f -o -type l \) \( $picture_files \) | sort > "$output_dir"/imagelist.txt |
| 648 |
# find "$input_dir" -maxdepth 1 \( -type f -o -type l \) \( $audio_files \) | sort > "$output_dir"/audiolist.txt |
| 649 |
# find "$input_dir" -maxdepth 1 -type f -prune \( $video_files \) | sort > "$output_dir"/videolist.txt |
| 650 |
# find "$input_dir" -maxdepth 1 -type f \( $text_files \) -exec ls -1 {} \; | sort > "$output_dir"/txtlist.txt |
| 651 |
find "$input_dir" -maxdepth 1 \( -type f -o -type l \) \( -name \*.JPG -o -name \*.jpg -o -name \*.png -o -name \*.PNG -o -name \*.jpeg -o -name \*.JPEG \) | sort > "$output_dir"/imagelist.txt |
| 652 |
find "$input_dir" -maxdepth 1 \( -type f -o -type l \) \( -name \*.mp3 -o -name \*.MP3 -o -name \*.ogg -o -name \*.OGG \) | sort > "$output_dir"/audiolist.txt |
| 653 |
find "$input_dir" -maxdepth 1 -type f -prune \( -name \*.avi -o -name \*.AVI \) | sort > "$output_dir"/videolist.txt |
| 654 |
fi |
| 655 |
|
| 656 |
# count the different media |
| 657 |
picture_count=`wc -l "$output_dir"/imagelist.txt | awk '{print $1}'` |
| 658 |
audio_count=`wc -l "$output_dir"/audiolist.txt | awk '{print $1}'` |
| 659 |
video_count=`wc -l "$output_dir"/videolist.txt | awk '{print $1}'` |
| 660 |
# text_count=`wc -l "$output_dir"/txtlist.txt | awk '{print $1}'` |
| 661 |
image_count=$( echo "$picture_count + $video_count" | bc ) |
| 662 |
echo "[dir2slideshow] Total pictures found = $picture_count" |
| 663 |
echo "[dir2slideshow] Total audio files found = $audio_count" |
| 664 |
echo "[dir2slideshow] Total video files found = $video_count" |
| 665 |
# echo "[dir2slideshow] Total text files found = $text_count" |
| 666 |
## now, join the audio files and images: |
| 667 |
if [ "$audiobook" == 1 ] ; then |
| 668 |
cat "$output_dir"/imagelist.txt "$output_dir"/audiolist.txt | sort > "$output_dir"/filelist.txt |
| 669 |
mv "$output_dir"/filelist.txt "$output_dir"/imagelist.txt |
| 670 |
sortmethod='' |
| 671 |
fi |
| 672 |
|
| 673 |
# make sure we found some images: |
| 674 |
if [ "$image_count" -eq 0 ] ; then |
| 675 |
echo "[dir2slideshow] ERROR: No pictures or videos found. Check your settings and try again." |
| 676 |
exit 1 |
| 677 |
fi |
| 678 |
|
| 679 |
## sort the pictures: |
| 680 |
|
| 681 |
myecho "[dir2slideshow] Sorting pictures..." |
| 682 |
if [ "$sortmethod" == 'taken_date' ] ; then |
| 683 |
## sort by taken date: |
| 684 |
checkforprog jhead |
| 685 |
check_rm "$output_dir"/filelist_date.txt |
| 686 |
for (( i=1 ; i<=picture_count ; i++ )) ; do |
| 687 |
file=`sed -n "$i"p "$output_dir"/imagelist.txt` |
| 688 |
taken=`jhead "$file" | grep 'Date/Time' | awk -F': ' '{print $2}'` |
| 689 |
modified=`jhead "$file" | grep 'File date' | awk -F': ' '{print $2}'` |
| 690 |
if [ -n "$taken" ] ; then |
| 691 |
echo "$file: $taken" >> "$output_dir"/filelist_date.txt |
| 692 |
else |
| 693 |
myecho "[dir2slideshow] No picture taken date in $file." |
| 694 |
# echo "[dir2slideshow] Using modification date!" |
| 695 |
echo "$file: $modified" >> "$output_dir"/filelist_date.txt |
| 696 |
fi |
| 697 |
done |
| 698 |
for (( i=1 ; i<=video_count ; i++ )) ; do |
| 699 |
file=`sed -n "$i"p "$output_dir"/videolist.txt` |
| 700 |
modified=`basename $file|awk -F_ '{printf "%s %s", $1, $2}'|sed s/-/:/g` |
| 701 |
echo "$file: $modified" >> "$output_dir"/filelist_date.txt |
| 702 |
done |
| 703 |
## sort: |
| 704 |
sort -k 2,3 -d "$output_dir"/filelist_date.txt > "$output_dir"/filelist_sorted.txt |
| 705 |
|
| 706 |
elif [ "$sortmethod" == 'modified_date' ] ; then |
| 707 |
## sort by modified date |
| 708 |
check_rm "$output_dir"/filelist_date.txt |
| 709 |
for (( i=1 ; i<=picture_count ; i++ )) ; do |
| 710 |
file=`sed -n "$i"p "$output_dir"/imagelist.txt` |
| 711 |
modified_day=`ls -l --full-time "$file" | awk '{print $6}'` |
| 712 |
modified_time=`ls -l --full-time "$file" | awk '{print $7}'` |
| 713 |
# echo "modified_day=$modified_day" |
| 714 |
# echo "modified_time=$modified_time" |
| 715 |
echo "$file: $modified_day $modified_time" >> "$output_dir"/filelist_date.txt |
| 716 |
done |
| 717 |
for (( i=1 ; i<=video_count ; i++ )) ; do |
| 718 |
file=`sed -n "$i"p "$output_dir"/videolist.txt` |
| 719 |
modified=`basename $file|awk -F_ '{printf "%s %s", $1, $2}'|sed s/-/:/g` |
| 720 |
echo "$file: $modified" >> "$output_dir"/filelist_date.txt |
| 721 |
done |
| 722 |
## sort: |
| 723 |
sort -k 2,3 -d "$output_dir"/filelist_date.txt > "$output_dir"/filelist_sorted.txt |
| 724 |
else |
| 725 |
## sort by name (should be done by ls -l) |
| 726 |
cat "$output_dir"/imagelist.txt "$output_dir"/videolist.txt > "$output_dir"/filelist_date.txt |
| 727 |
sort -k 1 -d "$output_dir"/filelist_date.txt > "$output_dir"/filelist_sorted.txt |
| 728 |
fi |
| 729 |
check_rm "$output_dir"/filelist_date.txt |
| 730 |
|
| 731 |
## main loop: |
| 732 |
# kenburns constants: |
| 733 |
# now, it seems the kenburns effect isn't very smooth if we zoom |
| 734 |
# and pan at the same time. So, we'll have two different versions: |
| 735 |
# 1. zoom only (random center and amount) |
| 736 |
# 2. pan only (random locations and amount) |
| 737 |
# 3. scroll? up/down for panoramas? (not yet) |
| 738 |
|
| 739 |
min_kb_size_percent=80 |
| 740 |
|
| 741 |
myecho "#########################################" |
| 742 |
if [ -n "$background" ] && [ -f "$background" ] ; then |
| 743 |
background="`full_path "$background"`" |
| 744 |
elif [ -n "$background" ] ; then # either color local file |
| 745 |
if [ -f "$themedir/$background" ] ; then |
| 746 |
background="$themedir/$background" |
| 747 |
fi |
| 748 |
elif [ -z "$background" ] ; then |
| 749 |
background=black |
| 750 |
fi |
| 751 |
if [ -n "$title_background" ] && [ -f "$title_background" ] ; then |
| 752 |
title_background="`full_path "$title_background"`" |
| 753 |
elif [ -n "$title_background" ] ; then # either color local file |
| 754 |
if [ -f "$themedir/$title_background" ] ; then |
| 755 |
title_background="$themedir/$title_background" |
| 756 |
fi |
| 757 |
fi |
| 758 |
|
| 759 |
check_rm "$outfile" |
| 760 |
if [ "$pal" == "1" ] ; then |
| 761 |
fileecho "pal=1" |
| 762 |
fi |
| 763 |
if [ -n "$themefile" ] ; then |
| 764 |
fileecho "theme=$themefile" |
| 765 |
fi |
| 766 |
if [ "$kenburns" == "1" ] ; then |
| 767 |
fileecho "high_quality=1" # force high-quality mode for slow kenburns effects? |
| 768 |
fi |
| 769 |
|
| 770 |
## set system variables |
| 771 |
if [ -n "$title_background" ] ; then |
| 772 |
# set title background separate from slideshow background: |
| 773 |
fileecho "background:0::$title_background" |
| 774 |
else |
| 775 |
fileecho "background:0::$background" |
| 776 |
fi |
| 777 |
|
| 778 |
#[ -n "$title_font" ] && fileecho "title_font=$title_font" |
| 779 |
#[ -n "$subtitle_font" ] && fileecho "subtitle_font=$subtitle_font" |
| 780 |
|
| 781 |
name_converted="$( echo $name | sed -e 's/_/ /g' )" |
| 782 |
#name_converted="$name" |
| 783 |
|
| 784 |
## if title is wanted: |
| 785 |
if [ "$title" -eq 1 ] ; then |
| 786 |
[ -n "$title_font_color" ] && fileecho "title_font_color=$title_font_color" |
| 787 |
[ -n "$title_font_size" ] && fileecho "title_font_size=$title_font_size" |
| 788 |
if [ "$fades" -eq 1 ] ; then |
| 789 |
fileecho "background:1" |
| 790 |
fileecho "fadein:1" |
| 791 |
fi |
| 792 |
if [ "$title_type" == 'titlebar' ] ; then |
| 793 |
fileecho "bottomtitle_bar_height=0" # no bottom title for now |
| 794 |
fileecho "titlebar:$slide_duration:$name_converted" |
| 795 |
else |
| 796 |
fileecho "title:$slide_duration:$name_converted" |
| 797 |
fi |
| 798 |
fileecho "background:0::$background" # set the background back to the non-title background |
| 799 |
fi |
| 800 |
if [ "$fades" -eq 1 ] && [ "$title" -eq 1 ] ; then |
| 801 |
fileecho "fadeout:1" |
| 802 |
fileecho "background:2" |
| 803 |
fi |
| 804 |
|
| 805 |
## write audio list to file: |
| 806 |
# audio_list is passed via the command-line or input file |
| 807 |
# audiolist.txt is created from the directory searching |
| 808 |
if [ -n "$audio_list" ] ; then |
| 809 |
echo "$audio_list" | sed -e 's/,/\n/g' | |
| 810 |
while read file |
| 811 |
do |
| 812 |
if [ -f "$file" ] ; then |
| 813 |
audio_file="$( full_path "$file" )" |
| 814 |
else |
| 815 |
# assume it's in the theme direcotry: |
| 816 |
audio_file="$themedir"/"$file" |
| 817 |
if [ ! -f "$audio_file" ] ; then |
| 818 |
echo "[dir2slideshow] ERROR! Audio file not found:" |
| 819 |
echo "[dir2slideshow] $file" |
| 820 |
fi |
| 821 |
fi |
| 822 |
fileecho "$audio_file"':1:fadein:2:fadeout:2' |
| 823 |
done |
| 824 |
elif [ -f "$output_dir/audiolist.txt" ] ; then |
| 825 |
# command-line audio supercedes audio in directory at this point! |
| 826 |
while read file |
| 827 |
do |
| 828 |
if [ -f "$file" ] ; then |
| 829 |
audio_file="$( full_path "$file" )" |
| 830 |
else |
| 831 |
# assume it's in the theme direcotry: |
| 832 |
audio_file="$themedir"/"$file" |
| 833 |
if [ ! -f "$audio_file" ] ; then |
| 834 |
echo "[dir2slideshow] ERROR! Audio file not found:" |
| 835 |
echo "[dir2slideshow] $file" |
| 836 |
fi |
| 837 |
fi |
| 838 |
fileecho "$audio_file"':1:fadein:2:fadeout:2' |
| 839 |
done < "$output_dir/audiolist.txt" |
| 840 |
|
| 841 |
fi |
| 842 |
if [ "$fades" -eq 1 ] ; then |
| 843 |
fileecho "fadein:1" |
| 844 |
fi |
| 845 |
|
| 846 |
total_lines=`wc -l "$output_dir"/filelist_sorted.txt | awk '{print $1}'` |
| 847 |
j=0 |
| 848 |
chapter=1 |
| 849 |
for (( i=1 ; i<=total_lines ; i++ )) ; do |
| 850 |
file="`sed -n "$i"p "$output_dir"/filelist_sorted.txt | awk -F: '{print $1}'`" |
| 851 |
file="`full_path "$file"`" |
| 852 |
filetype=$( echo "$file" | awk -F. '{print $NF}') |
| 853 |
## write to file: |
| 854 |
if [ "$filetype" == 'mp3' ] ; then |
| 855 |
if [ "$audiobook" == 1 ] ; then |
| 856 |
fileecho "$file:1" |
| 857 |
book_title="$name_converted" |
| 858 |
fileecho "titlebar:audio:$book_title:Chapter $chapter" |
| 859 |
chapter=$(( $chapter + 1 )) |
| 860 |
# else |
| 861 |
# fileecho "$file:1" |
| 862 |
fi |
| 863 |
elif [ "$filetype" == 'avi' ] ; then |
| 864 |
if [ -n "$subtitle" ] ; then |
| 865 |
if [ "$subtitle" == 'filename' ] ; then |
| 866 |
# use name as the subtitle |
| 867 |
subtitle_text="$( basename "$file" )" |
| 868 |
elif [ "$subtitle" == 'path' ] ; then |
| 869 |
# use full filename and path as subtitle (truncate?) |
| 870 |
subtitle_text="$file" |
| 871 |
else |
| 872 |
subtitle_text="$subtitle" |
| 873 |
fi |
| 874 |
else |
| 875 |
subtitle_text='' |
| 876 |
fi |
| 877 |
|
| 878 |
if [ -n "$subtitle2" ] ; then |
| 879 |
if [ "$subtitle2" == 'filename' ] ; then |
| 880 |
# use name as the subtitle2 |
| 881 |
subtitle2_text="$( basename "$file" )" |
| 882 |
elif [ "$subtitle2" == 'path' ] ; then |
| 883 |
# use full filename and path as subtitle2 (truncate?) |
| 884 |
subtitle2_text="$file" |
| 885 |
else |
| 886 |
subtitle2_text="$subtitle2" |
| 887 |
fi |
| 888 |
else |
| 889 |
subtitle2_text='' |
| 890 |
fi |
| 891 |
if [ -n "$subtitle_text" ] && [ -n "$subtitle2_text" ] ; then |
| 892 |
fileecho "$file:$slide_duration:$subtitle_text"';'"$subtitle2_text" |
| 893 |
elif [ -n "$subtitle_text" ] && [ -z "$subtitle2_text" ] ; then |
| 894 |
fileecho "$file:$slide_duration:$subtitle_text" |
| 895 |
else |
| 896 |
fileecho "$file:$slide_duration" |
| 897 |
fi |
| 898 |
elif [ "$filetype" == 'txt' ] ; then |
| 899 |
echo "found text file" |
| 900 |
else |
| 901 |
if [ "$kenburns" == "1" ] ; then |
| 902 |
autocrop_size_percent=`autocrop_percent "$file"` |
| 903 |
if [ "$autocrop_size_percent" -lt "$min_kb_size_percent" ] ; then |
| 904 |
# probably a portrait image, don't do auto kenburns? |
| 905 |
kenburns_args="" |
| 906 |
# echo "autocrop_size_percent=$autocrop_size_percent" |
| 907 |
else |
| 908 |
# use autocrop as largest crop possible |
| 909 |
large_kb_size_percent="$autocrop_size_percent" |
| 910 |
if [ "$large_kb_size_percent" -gt "$min_kb_size_percent" ] ; then |
| 911 |
delta_kb_size_percent=$(( $large_kb_size_percent - $min_kb_size_percent )) |
| 912 |
small_kb_size_percent=$min_kb_size_percent |
| 913 |
else |
| 914 |
delta_kb_size_percent=1 |
| 915 |
small_kb_size_percent=$min_kb_size_percent |
| 916 |
fi |
| 917 |
# generate random start and end between these two limits: |
| 918 |
myrand="$RANDOM" |
| 919 |
# echo "$(( $myrand % $delta_kb_size_percent ))" |
| 920 |
# note $(( $RANDOM % number )) gives a random number (reminder) |
| 921 |
# between 0 and number |
| 922 |
kb_start=$(( $myrand % $delta_kb_size_percent + $small_kb_size_percent )) |
| 923 |
|
| 924 |
# zoom doesn't look that smooth, so don't use it! |
| 925 |
# randomly choose between zoom and pan: |
| 926 |
# zoom_or_pan=$(( $RANDOM % 2 )) |
| 927 |
# echo "zoom_or_pan=$zoom_or_pan" |
| 928 |
zoom_or_pan=0 |
| 929 |
if [ $zoom_or_pan -eq 1 ] ; then |
| 930 |
# do zoom |
| 931 |
kb_end=$(( $RANDOM % $delta_kb_size_percent + $small_kb_size_percent )) |
| 932 |
kenburns_args="kenburns:$kb_start%;50%,50%;$kb_end%;50%,50%" |
| 933 |
else |
| 934 |
# do pan |
| 935 |
# now get horizontal and vertical movement for START: |
| 936 |
if [ "$autocrop_size_percent" -gt "$kb_start" ] ; then |
| 937 |
range=$(( $autocrop_size_percent - $kb_start )) |
| 938 |
else |
| 939 |
range=$(( $kb_start - $autocrop_size_percent )) |
| 940 |
fi |
| 941 |
# echo "autocrop=$autocrop_size_percent range=$range" |
| 942 |
small_kb_percent=$(( 50 - $range/2 )) |
| 943 |
kb_x_start=$(( $RANDOM % $range + $small_kb_percent )) |
| 944 |
kb_x_end=$(( $RANDOM % $range + $small_kb_percent )) |
| 945 |
kb_y_start=$(( $RANDOM % $range + $small_kb_percent )) |
| 946 |
kb_y_end=$(( $RANDOM % $range + $small_kb_percent )) |
| 947 |
xrange=$(( $kb_x_start - $kb_x_end )) |
| 948 |
[ "$xrange" -lt 0 ] && xrange=$(( -1 * $xrange )) |
| 949 |
yrange=$(( $kb_y_start - $kb_y_end )) |
| 950 |
[ "$yrange" -lt 0 ] && yrange=$(( -1 * $yrange )) |
| 951 |
# make sure values are not the same? |
| 952 |
#echo "trying: kenburns:$kb_start%;$kb_x_start%,$kb_y_start%;$kb_start%;$kb_x_end%,$kb_y_end%" |
| 953 |
if [ $kb_x_start -eq $kb_x_end ] && [ $kb_y_start -eq $kb_y_end ] ; then |
| 954 |
kenburns_args='' |
| 955 |
elif [ $(( $kb_x_start - $kb_x_end )) -le 1 ] && [ $(( $kb_y_start - $kb_y_end )) -le 1 ] ; then |
| 956 |
kenburns_args='' |
| 957 |
else |
| 958 |
kenburns_args="kenburns:$kb_start%;$kb_x_start%,$kb_y_start%;$kb_start%;$kb_x_end%,$kb_y_end%" |
| 959 |
fi |
| 960 |
fi |
| 961 |
fi |
| 962 |
else |
| 963 |
kenburns_args="" |
| 964 |
fi |
| 965 |
if [ -n "$subtitle" ] ; then |
| 966 |
if [ "$subtitle" == 'filename' ] ; then |
| 967 |
# use name as the subtitle |
| 968 |
subtitle_text="$( basename "$file" )" |
| 969 |
elif [ "$subtitle" == 'path' ] ; then |
| 970 |
# use full filename and path as subtitle (truncate?) |
| 971 |
subtitle_text="$file" |
| 972 |
else |
| 973 |
subtitle_text="$subtitle" |
| 974 |
fi |
| 975 |
else |
| 976 |
subtitle_text='' |
| 977 |
fi |
| 978 |
|
| 979 |
if [ -n "$subtitle2" ] ; then |
| 980 |
if [ "$subtitle2" == 'filename' ] ; then |
| 981 |
# use name as the subtitle2 |
| 982 |
subtitle2_text="$( basename "$file" )" |
| 983 |
elif [ "$subtitle2" == 'path' ] ; then |
| 984 |
# use full filename and path as subtitle2 (truncate?) |
| 985 |
subtitle2_text="$file" |
| 986 |
else |
| 987 |
subtitle2_text="$subtitle2" |
| 988 |
fi |
| 989 |
else |
| 990 |
subtitle2_text='' |
| 991 |
fi |
| 992 |
if [ -n "$subtitle2_text" ] && [ -n "$kenburns_args" ] ; then |
| 993 |
fileecho "$file:$slide_duration:$subtitle_text"';'"$subtitle2_text:$kenburns_args" |
| 994 |
elif [ -z "$subtitle2_text" ] && [ -n "$kenburns_args" ] ; then |
| 995 |
fileecho "$file:$slide_duration:$subtitle_text:$kenburns_args" |
| 996 |
elif [ -n "$subtitle_text" ] && [ -z "$subtitle2_text" ] && [ -z "$kenburns_args" ] ; then |
| 997 |
fileecho "$file:$slide_duration:$subtitle_text" |
| 998 |
elif [ -n "$subtitle2_text" ] && [ -z "$kenburns_args" ] ; then |
| 999 |
fileecho "$file:$slide_duration:$subtitle_text"';'"$subtitle2_text" |
| 1000 |
else |
| 1001 |
fileecho "$file:$slide_duration" |
| 1002 |
fi |
| 1003 |
if [ "$crossfade" != "0" ] && [ "$i" -lt "$image_count" ] ; then |
| 1004 |
fileecho "crossfade:$crossfade" |
| 1005 |
elif [ "$wipe" != "0" ] && [ "$i" -lt "$image_count" ] ; then |
| 1006 |
fileecho "wipe:$wipe" |
| 1007 |
fi |
| 1008 |
let j=$j+1 |
| 1009 |
fi # end of if statement for different file types |
| 1010 |
done |
| 1011 |
|
| 1012 |
if [ "$fades" -eq 1 ] ; then |
| 1013 |
## fade out at end |
| 1014 |
fileecho "fadeout:1" |
| 1015 |
fileecho "background:2" |
| 1016 |
fi |
| 1017 |
#if [ "$title" -eq 1 ] && [ -n "$title_background" ] ; then |
| 1018 |
# # if we use a title, then fade back in to title_background? |
| 1019 |
# fileecho "fadein:1" |
| 1020 |
# fileecho "$title_background":3 |
| 1021 |
#fi |
| 1022 |
myecho "#########################################" |
| 1023 |
|
| 1024 |
cleanup |
| 1025 |
|
| 1026 |
myecho "[dir2slideshow] Output file is $outfile" |
| 1027 |
myecho |