add all the things

This commit is contained in:
kageru 2019-08-01 13:45:24 +02:00
parent c1470a1103
commit d46bffcd23
2 changed files with 52 additions and 0 deletions

41
encode.sh Normal file
View File

@ -0,0 +1,41 @@
#!/bin/sh
sleep $(dc -e "$RANDOM 1000 / p")
lockfile="/tmp/auto-encode-x264"
if [ -f "$lockfile" ]; then
exit 0
fi
touch "$lockfile"
notify() {
python "$script_dir/notify.py" '171327453212573696' "$1"
}
script=$1
script_dir=$(pwd)
base_dir=$(dirname $script)
done_dir="/home/sftp/kaleido/auto-encode/done"
cd "$base_dir"
if [ ! -f 'settings' ]; then
notify "Could not start encode, expected file ‘settings’ in `pwd`."
rm "$lockfile"
exit 0
fi
settings=$(cat 'settings')
notify "Starting encode $script."
output_file=$(basename $script .vpy).264
output=$( { nice -n 17 vspipe $(basename $script) -y - | x264 --demuxer y4m - $settings --output-depth 10 --threads 1 -o $output_file; } 2>&1 )
ok=$?
output_filtered=$( echo $output | sed -E 's/(x264)?\s?\[/\n\[/g' | grep -v ' ' )
if [ $ok -ne 0 ]; then
notify "Encode $script failed"
notify "$output_filtered"
rm "$lockfile"
exit 0
else
mv "$output_file" "$done_dir"
mv "$script" "$done_dir"
notify "$script successfully encoded."
notify "$output_filtered"
fi
rm -f "$lockfile"
rm -f /tmp/auto-encode

11
watch.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
if [ -f '/tmp/auto-encode' ]; then
exit 1
fi
touch /tmp/auto-encode
fd .vpy$ /home/sftp/kaleido/auto-encode/queue --exec /home/kageru/auto-encode/encode.sh {}
rm -f /tmp/auto-encode
exit 0