6
# Part of the tovid suite
7
# =======================
8
# A bash script for testing the tovid suite.
10
# Project homepage: http://www.tovid.org
13
# Copyright (C) 2005 tovid.org <http://www.tovid.org>
15
# This program is free software; you can redistribute it and/or
16
# modify it under the terms of the GNU General Public License
17
# as published by the Free Software Foundation; either
18
# version 2 of the License, or (at your option) any later
21
# This program is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU General Public License for more details.
26
# You should have received a copy of the GNU General Public License
27
# along with this program; if not, write to the Free Software
28
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Or see:
30
# http://www.gnu.org/licenses/gpl.txt
32
# ******************************************************************************
33
# ******************************************************************************
36
# DEFAULTS AND GLOBALS
39
# ******************************************************************************
40
# ******************************************************************************
42
SEPARATOR="========================================================="
44
SCRIPT_NAME=`cat << EOF
45
--------------------------------
47
Part of the tovid suite, version $TOVID_VERSION
49
--------------------------------
53
Usage: tovid-test [OPTIONS] -in FILE
55
OPTIONS may be any of the following:
57
-basic Test VCD, SVCD, and DVD (Default)
58
-dvd Test DVD-compatible formats
59
-all Test all formats that tovid supports
60
-ffmpeg Test the ffmpeg backend
61
-keep Keep all output files
63
The input file may be any video file. Output
64
and logging go into a temporary directory
65
with a name like "tovid-test.1".
71
LOG_FILE="tovid-test.log"
72
DEFAULT_OUTFILE="outfile.default"
73
TEST_FORMATS="vcd svcd dvd"
78
while test $# -gt 0; do
86
# Run tovid in -debug mode and print all output
90
# Keep all output files, giving them unique names
95
TEST_FORMATS="dvd half-dvd svcd dvd-vcd vcd kvcd kdvd bdvd"
98
# Test three basic formats
99
TEST_FORMATS="vcd svcd dvd"
102
# Test the DVD-compatible formats
103
TEST_FORMATS="dvd half-dvd dvd-vcd kdvd bdvd"
106
# Test the ffmpeg backend
110
# Test the CD-compatible formats
111
TEST_FORMATS="vcd svcd"
114
usage_error "Unrecognized command-line option: '$1'"
121
# ******************************************************************************
122
# Y-echo: echo to two places at once (stdout and logfile)
123
# Output is preceded by the script name that produced it
124
# Args: $@ == any text string
125
# If no args are given, echo a separator bar
126
# Why echo when you can yecho?
127
# ******************************************************************************
130
if test $# -eq 0; then
131
printf "\n%s\n\n" "$SEPARATOR"
132
# If logfile exists, copy output to it (with pretty formatting)
133
test -e "$LOG_FILE" && \
134
printf "%s\n%s %s\n%s" "$ME" "$ME" "$SEPARATOR" "$ME" >> "$LOG_FILE"
137
test -e "$LOG_FILE" && \
138
printf "%s %s" "$ME" "$@" >> "$LOG_FILE"
142
# ******************************************************************************
143
# Print usage notes and optional error message, then exit.
144
# Args: $@ == text string containing error message
145
# ******************************************************************************
154
# ******************************************************************************
155
# Test the tovid script with the given options and infile
156
# Args: $@ = all options (including -in) to test
157
# -out filename will be ignored if provided
158
# ******************************************************************************
161
# If we're keeping every output file, generate a unique name
162
if $KEEP_OUTPUT; then
163
OUTFILE_UNIQUE=`echo $@ | sed 's/ //g'`
164
OUTFILE="$OUTFILE_UNIQUE"
166
OUTFILE="$DEFAULT_OUTFILE"
169
CMD="tovid $@ -overwrite -out $OUTFILE"
170
$TEST_FFMPEG && CMD="$CMD -ffmpeg"
173
eval "$CMD" | tee -a "$LOG_FILE"
175
eval "$CMD" >> "$LOG_FILE"
178
if test -e "$OUTFILE.mpg"; then
182
echo "$ME Detected a successful encoding" >> $LOG_FILE
184
# TODO: Verify that output specs match the target format
185
idvid "$OUTFILE" >> "$LOG_FILE"
187
# Count and log error
188
ERRORS=`expr $ERRORS \+ 1`
189
echo "$ME Detected an encoding failure" >> $LOG_FILE
191
echo "----------------"
192
echo "*** Failure! ***"
193
echo "Please see $LOG_FILE for error messages."
199
# ******************************************************************************
200
# Execution begins here
201
# ******************************************************************************
204
if test -z "$INFILE"; then
205
usage_error "Please provide the name of a video file to use as input."
208
# Remove any existing log file
209
test -f "$LOG_FILE" && rm -fv "$LOG_FILE"
211
# Test each format in the list
212
for FMT in `echo $TEST_FORMATS`
214
echo "Encoding to $FMT format"
215
test_tovid "-$FMT -in $INFILE"
218
echo "There were $ERRORS errors. Please see $LOG_FILE for a complete report."
219
echo "Done. Thanks for using tovid-test."