File: dvdwizard_test

package info (click to toggle)
dvdwizard 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 872 kB
  • ctags: 220
  • sloc: sh: 4,699; makefile: 343
file content (204 lines) | stat: -rwxr-xr-x 6,063 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env bash
#
#   dvdwizard_test
#     - create test movies, menu backgrounds and run dvdwizard
#
#   Copyright (c) 2010-2011 Markus Kohm <kohm at users.sf.net>
#   Copyright (c) 2012 Joo Martin <joomart2009 at users.sf.net>
#
#   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 package 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 <http://www.gnu.org/licenses/>.
#
# Changes:
#
#   2011-07-11  Markus Kohm
#               * better usage of sox to increase speed a lot
#   2011-01-02  Markus Kohm
#               * gcalctool repaced by bc and bash calculations
#               * test movies with sound
#   2012-03-18  Joo Martin
#               * user config file always in $HOME/.config/dvdwizard/
#
# -------------------------------------------------------------------------


CLAPPERBOARD="Clapperboard.svg"
hz=1200

#
# i18n
#
export TEXTDOMAIN=dvdwizard
export TEXTDOMAINDIR="@LOCALEDIR@"

# We need some sub-routines from dvdwizard_common.
# This file must be found at PATH.
#
. dvdwizard_common || {
    echo $"FATAL ERROR: could not execute common function file \`dvdwizard_common'!
You have to install \`dvdwizard_common' somewhere at PATH." >&2
    exit 1
}

# ------------------------------
# Function specification
#
usagetext=$"
Usage: ${thisscript} [-C|--config-file <filename>] [...]
       ${thisscript} -h|--help
       ${thisscript} -v|--version

general processing:
-------------------
-C  | --config-file     filename of dvdwizard-configuration file.
                        [~/.config/dvdwizard/dvdwizard.conf]
-h  | --help            print this help and exit.
-v  | --version         print version infromation only and exit.      

All options and arguments but -h or --help and -v or --version will be passed 
to dvdwizard before the first title option.
${thisscript} needs the additional file \`Clapperboard.svg' either at the
current working directory or at @DATADIR@.  You may also set 
variable CLAPPERBOARD to the path and name of that file at the config file.
"

# ------------------------------
# Main Processing
#

#
# Is help wanted?
#
test_versionhelp "$@"

set_defaults "$@"
check_tools

if ! [ -r "${CLAPPERBOARD}" ]; then
    if [ -r "${PWD}/Clapperboard.svg" ]; then
	eval CLAPPERBOARD=\"${PWD}/Clapperboard.svg\"
    elif [ -r "@DATADIR@/dvdwizard/Clapperboard.svg" ]; then
	CLAPPERBOARD="@DATADIR@/dvdwizard/Clapperboard.svg"
    fi
fi

if ! [ -r "${CLAPPERBOARD}" ]; then
    error_help $"File \`Clapperboard.svg' not found"!
fi

ext="wav"
if sox -h | grep "AUDIO FILE FORMATS" | grep mp2 >/dev/null; then
    ext="mp2"
fi

printf $"Creating 0.08s %sHz: " ${hz} >&2
sox -n sound008.${ext} synth 0.08 sine ${hz}
echo $"done." >&2
printf $"Creating 0.92s silence: " >&2
sox -n silence092.${ext} synth 0.92 sine 0
echo $"done." >&2
printf $"Creating 1.00s %sHz: " ${hz} >&2
sox -n sound100.${ext} synth 1.00 sine ${hz}
echo $"done." >&2

echo -n $"Combining sounds: " >&2
sox sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound008.${ext} silence092.${ext} \
    sound100.${ext} \
    sound1000.${ext}
echo $"done." >&2

for movie in A B; do
    printf $"Creating movie %s: " ${movie} >&2

    pushd ${DVDWIZARD_TMPDIR}

    printf $"\tPicture" >&2
    pn=0
    seconds=10
    while [ ${seconds} -ge 0 ]; do
	frac=0
	while [ ${frac} -lt 25 ]; do
	    printf " ${pn}" >&2
	    angle=$(( ((10-$seconds)*36+($frac*36)/25) ))
	    large="0"
	    [ $angle -ge 180 ] && large=1
	    x=$(echo 'scale=10;s('$angle'/45*a(1))*192+360' | bc -l)
	    y=$(echo 'scale=10;-c('$angle'/45*a(1))*192+288' | bc -l)
	    
	    pns=$((pn++)); while [ ${#pns} -lt 4 ];do pns="0$pns";done
	    
	    convert -size 720x576 xc:white -depth 8 \
		-density 75x80 \
		-gravity NorthWest \
		-stroke black -strokewidth 2 \
		-fill white \
		-draw "circle 360,288 360,480" \
		-fill DarkGray \
		-stroke DarkGray -strokewidth 0 \
		-draw "path 'M 360,288 v -192 A 192,192 0 ${large},1 ${x},${y} z'" \
		-fill black \
		-stroke black -strokewidth 2 \
		-draw "line 360,60 360,516" \
		-draw "line 132,288 588,288" \
		-stroke none \
		-fill DeepSkyBlue3 -font Helvetica -pointsize 20 \
		-draw "gravity NorthEast text 40,30 \"DVDwizard test movie ${movie}\"" \
		-fill DimGray -pointsize 200 \
		-draw "gravity Center text 0,20 \"${seconds}\"" \
		ppm:"countdown${movie}${pns}.ppm"
	    
	    frac=$((frac+1))
	    [ ${seconds} -eq 0 ] && frac=25
	done
	seconds=$((seconds-1))
    done

    echo >&2
    popd

    printf "\t"$"Encoding movie %s: " "${movie}" >&2

    avconv -i ${DVDWIZARD_TMPDIR}/countdown${movie}%04d.ppm \
	-i sound1000.${ext} \
	-target pal-dvd countdown${movie}.mpg -aspect "4:3"

    rm -rf ${DVDWIZARD_TMPDIR}/*.ppm

    echo $"done." >&2

    printf $"Creating menue background movie %s:\n" "${movie}" >&2
    sed -e "s/Test movie A/Test movie ${movie}/g" \
	${CLAPPERBOARD} \
	>${DVDWIZARD_TMPDIR}/Clapperboard.svg

    convert -size 640x510 xc:transparent -depth 8 \
	-gravity Center \
	-draw "gravity Center image src-over 0,0 0,0 \"${DVDWIZARD_TMPDIR}/Clapperboard.svg\"" \
	png:"menue${movie}.png"
    echo $"done." >&2
    
done

dvdwizard -T "DVDwizard" "$@" \
    -t countdownA.mpg -b menueA.png -ar 4:3 \
    -t countdownB.mpg -b menueB.png -ar 4:3

# cleanup_tmpdir not needed because done by dvdwizard if no error occured.