Tweaks for issue #3.
This commit is contained in:
parent
1fdbba0fed
commit
f5e125047a
45
dve
45
dve
@ -1,13 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# defaults for all configuration values
|
||||||
ENC="ffmpeg"
|
ENC="ffmpeg"
|
||||||
ENCPATH=""
|
|
||||||
OPTS="-c:v libx265 -preset fast -x265-params crf=24 -c:a libvorbis -aq 5 -c:s copy"
|
OPTS="-c:v libx265 -preset fast -x265-params crf=24 -c:a libvorbis -aq 5 -c:s copy"
|
||||||
SUFFIX="_new.mkv"
|
SUFFIX="_new.mkv"
|
||||||
SERVERS="localhost"
|
SERVERS=":"
|
||||||
LEN=60
|
LEN=60
|
||||||
OUTDIR="$HOME/.dve"
|
OUTDIR="$HOME/.dve"
|
||||||
VERBOSE="error"
|
VERBOSE="error"
|
||||||
|
# override defaults in a ~/.dverc file
|
||||||
|
if [ -f ~/.dverc ]; then
|
||||||
|
source ~/.dverc
|
||||||
|
fi
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
@ -18,7 +24,6 @@ multiple hosts.
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h this help message.
|
-h this help message.
|
||||||
-e ffmpeg binary to use. (default=${ENC})
|
|
||||||
-l comma separated list of hosts to use to encode. (default=${SERVERS})
|
-l comma separated list of hosts to use to encode. (default=${SERVERS})
|
||||||
-t rough length of individual video chunks, in seconds. (default=${MINLEN})
|
-t rough length of individual video chunks, in seconds. (default=${MINLEN})
|
||||||
-o encoding options. (default=${OPTS})
|
-o encoding options. (default=${OPTS})
|
||||||
@ -29,36 +34,20 @@ EOF
|
|||||||
|
|
||||||
# check all required helper utils
|
# check all required helper utils
|
||||||
function checkpaths() {
|
function checkpaths() {
|
||||||
for cmd in parallel; do
|
for cmd in parallel ffmpeg; do
|
||||||
if ! CMD=`which $cmd`; then
|
if ! CMD=`which $cmd`; then
|
||||||
echo "$cmd not found."
|
echo "$cmd not found in local path."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# check as absolute path first
|
|
||||||
if [ -x "$ENC" ]; then
|
|
||||||
ENCPATH="$ENC"
|
|
||||||
else
|
|
||||||
# then check for something in $PATH
|
|
||||||
ENCPATH="`which $ENC`"
|
|
||||||
if ! [ -x "$ENCPATH" ]; then
|
|
||||||
echo "$ENC not found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkpaths
|
while getopts “hl:t:o:s:v” OPTION; do
|
||||||
|
|
||||||
while getopts “he:l:t:o:s:v” OPTION; do
|
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
e)
|
|
||||||
ENC="$OPTARG"
|
|
||||||
;;
|
|
||||||
l)
|
l)
|
||||||
SERVERS="$OPTARG"
|
SERVERS="$OPTARG"
|
||||||
;;
|
;;
|
||||||
@ -87,13 +76,19 @@ if [ $# -lt 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
checkpaths
|
||||||
|
|
||||||
if ! mkdir -p ${OUTDIR}; then
|
if ! mkdir -p ${OUTDIR}; then
|
||||||
echo "Couldn't create temp chunk output dir ${OUTDIR}."
|
echo "Couldn't create temp chunk output dir ${OUTDIR}."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating chunks to encode"
|
echo "Creating chunks to encode"
|
||||||
$ENCPATH -i "$1" -map 0 -codec copy -f segment -segment_time $LEN -segment_format matroska -v ${VERBOSE} "${OUTDIR}/chunk-%03d.orig"
|
if [[ "$1" == *".AVI" || "$1" == *".avi" ]]; then
|
||||||
|
$ENC -fflags +genpts -i "$1" -map 0 -codec copy -f segment -segment_time $LEN -segment_format matroska -v ${VERBOSE} "${OUTDIR}/chunk-%03d.orig"
|
||||||
|
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`
|
CWD=`pwd`
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
@ -105,7 +100,7 @@ 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"
|
||||||
|
|
||||||
echo "parallel ${PAR_OPTS} ${ENCPATH} ${ENC_OPTS} ::: chunk-*.orig"
|
echo "parallel ${PAR_OPTS} ${ENCPATH} ${ENC_OPTS} ::: chunk-*.orig"
|
||||||
parallel ${PAR_OPTS} ${ENCPATH} ${ENC_OPTS} ::: chunk-*.orig
|
parallel ${PAR_OPTS} ${ENC} ${ENC_OPTS} ::: chunk-*.orig
|
||||||
|
|
||||||
echo "Combining chunks into final video file"
|
echo "Combining chunks into final video file"
|
||||||
echo "ffconcat version 1.0" > concat.txt
|
echo "ffconcat version 1.0" > concat.txt
|
||||||
@ -114,7 +109,7 @@ for f in `ls chunk-*.enc | sort`; do
|
|||||||
done
|
done
|
||||||
BASE=`basename "$1"`
|
BASE=`basename "$1"`
|
||||||
OUTFILE="${CWD}"/"${BASE%.*}${SUFFIX}"
|
OUTFILE="${CWD}"/"${BASE%.*}${SUFFIX}"
|
||||||
${ENCPATH} -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"
|
echo "Cleaning up temporary working files"
|
||||||
rm -f "${OUTDIR}"/*
|
rm -f "${OUTDIR}"/*
|
||||||
|
Loading…
Reference in New Issue
Block a user