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