Merge pull request #4 from DavidVentura/master

Handle errors properly
This commit is contained in:
Graeme Nordgren 2015-09-03 10:38:19 -07:00
commit 2af971eb86

23
dve
View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
set -e set -e
@ -8,13 +8,20 @@ OPTS="-c:v libx265 -preset fast -x265-params crf=24 -c:a libvorbis -aq 5 -c:s co
SUFFIX="_new.mkv" SUFFIX="_new.mkv"
SERVERS=":" SERVERS=":"
LEN=60 LEN=60
OUTDIR="$HOME/.dve" OUTDIR="/tmp/.dve" #ram
VERBOSE="error" VERBOSE="error"
# override defaults in a ~/.dverc file # override defaults in a ~/.dverc file
if [ -f ~/.dverc ]; then if [ -f ~/.dverc ]; then
source ~/.dverc source ~/.dverc
fi fi
function on_finish() {
echo "Cleaning up temporary working files"
rm -f "${OUTDIR}"/*
cd "$CWD"
echo "Finished cleaning"
}
function usage() { function usage() {
cat << EOF cat << EOF
usage: $0 [options] filename usage: $0 [options] filename
@ -76,6 +83,9 @@ if [ $# -lt 1 ]; then
exit 1 exit 1
fi fi
CWD=`pwd`
trap on_finish EXIT
checkpaths checkpaths
if ! mkdir -p ${OUTDIR}; then if ! mkdir -p ${OUTDIR}; then
@ -89,13 +99,10 @@ if [[ "$1" == *".AVI" || "$1" == *".avi" ]]; then
else else
$ENC -i "$1" -map 0 -codec copy -f segment -segment_time $LEN -segment_format matroska -v ${VERBOSE} "${OUTDIR}/chunk-%03d.orig" $ENC -i "$1" -map 0 -codec copy -f segment -segment_time $LEN -segment_format matroska -v ${VERBOSE} "${OUTDIR}/chunk-%03d.orig"
fi fi
CWD=`pwd`
cd "$OUTDIR" cd "$OUTDIR"
echo "Running parallel encoding jobs" echo "Running parallel encoding jobs"
PAR_OPTS="--gnu -j 1 -S ${SERVERS} --eta --retries 2 --nice 10" PAR_OPTS="--no-notice --gnu -j 1 -S ${SERVERS} --eta --retries 2 --nice 10"
#PAR_OPTS="$PAR_OPTS --workdir ... --trc {.}.enc"
PAR_OPTS="$PAR_OPTS --workdir ... --transfer --return {.}.enc" PAR_OPTS="$PAR_OPTS --workdir ... --transfer --return {.}.enc"
ENC_OPTS="-y -v ${VERBOSE} -i {} ${OPTS} -f matroska {.}.enc" ENC_OPTS="-y -v ${VERBOSE} -i {} ${OPTS} -f matroska {.}.enc"
@ -110,7 +117,3 @@ done
BASE=`basename "$1"` BASE=`basename "$1"`
OUTFILE="${CWD}"/"${BASE%.*}${SUFFIX}" OUTFILE="${CWD}"/"${BASE%.*}${SUFFIX}"
${ENC} -y -v ${VERBOSE} -f concat -i concat.txt -f matroska -map 0 -c copy "${OUTFILE}" ${ENC} -y -v ${VERBOSE} -f concat -i concat.txt -f matroska -map 0 -c copy "${OUTFILE}"
echo "Cleaning up temporary working files"
rm -f "${OUTDIR}"/*
cd "$CWD"