I made a small script to convert some mpegs to a more portable format
I feed the script with a file like this
Testrun
However when I ommit '-d', ffmpeg runs only once and then the script exits silently
Does anyone see something obviously stupid I'm doing, or otherwise have an explanation for this behaviour?
Code:
#!/bin/sh
usage () {
echo "usage: $0 [-f file] [-dvh]"
}
help () {
usage
echo " -f <file>
-d dryrun
-v verbose
-h help
"
exit
}
trap "exit 1" 0 1 2 15
system () {
test -z $verbose || echo "+ $*" 1>&2
test -z $dryrun || return
eval "$@"
}
while [ x"$1" != x"" ]
do
case $1 in
-f) file=$2; shift;;
-v) verbose=1;;
-d) dryrun=1;;
-h) help;exit;;
esac
shift
done
test -z "$file" && help;
test -f "$file" || help
grep -v '^#' $file | \
while read a b
do
cmd="fmpeg -i $a -ac 2 -ar 48000 -b 1000k -s cif $b.m4v"
system $cmd
done
I feed the script with a file like this
Code:
gong:/medialib/tc# cat infile.txt
#/medialib/teapot/3150_20091012215900.mpg file-1
/medialib/teapot/2150_20091026215900.mpg file-2
/medialib/teapot/3150_20091102215900.mpg file-3
/medialib/teapot/3150_20091110215900.mpg file-4
Testrun
Code:
gong:/medialib/tc# ./trans.sh -v -d -f infile.txt
+ fmpeg -i /medialib/teapot/2150_20091026215900.mpg -ac 2 -ar 48000 -b 1000k -s cif file-2.m4v
+ fmpeg -i /medialib/teapot/3150_20091102215900.mpg -ac 2 -ar 48000 -b 1000k -s cif file-3.m4v
+ fmpeg -i /medialib/teapot/3150_20091110215900.mpg -ac 2 -ar 48000 -b 1000k -s cif file-4.m4v
However when I ommit '-d', ffmpeg runs only once and then the script exits silently
Code:
gong:/medialib/tc# ./trans.sh -f infile.txt -v
+ fmpeg -i /medialib/teapot/2150_20091026215900.mpg -ac 2 -ar 48000 -b 1000k -s cif file-2.m4v
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
.... plenty of output as ffmpeg does it's job
gong:/medialib/tc#
Does anyone see something obviously stupid I'm doing, or otherwise have an explanation for this behaviour?