media-sucker/scripts/encoder.sh

32 lines
777 B
Bash
Raw Normal View History

2022-01-06 12:31:30 -07:00
#! /bin/sh
2022-01-09 16:26:12 -07:00
. $(dirname $0)/common.sh
2022-01-06 12:31:30 -07:00
while sleep 2; do
2022-01-09 19:50:31 -07:00
echo "idle" > $OUTDIR/status.encoder
2022-01-06 12:31:30 -07:00
for mtype in audio video; do
ls $mtype | while read d; do
encode=$SCRIPTS/$mtype.encode.sh
2022-01-06 12:31:30 -07:00
workdir=$mtype/$d
2022-01-09 19:50:31 -07:00
status=$(cd $workdir && getenv status)
case "$status" in
"encoding")
(cd $workdir && setenv status "encode interrupted")
;;
"read finished")
echo "encoding" > $OUTDIR/status.encoder
(cd $workdir && setenv status "encoding")
if ! (cd $workdir && $encode); then
log "$encode failed"
(cd $workdir && setenv status "encode failed")
else
rm -rf $workdir
fi
;;
esac
2022-01-06 12:31:30 -07:00
done
done
done
# vi: ts=2 sw=2 et ai