#!/bin/bash
#                       /usr/local/bin/video2video
# https://crystalfaeries.net/posix/bin/video2video
# celeste:crystalfaery VIDEO2VIDEO 2020-07-11 00:42:18+00:00
# convert videos to .ogv video files and prompt interactively to delete video.
# by default with no arguments, we process the first item in our playlist.

# CONFIGURATION: ( see also local BASH script: /usr/local/bin/monitor )
playlist="${HOME}/documents/playlists/.monitor.txt"	# text format listing of input file_paths
  oggdir="${HOME}/crystalfaeries.net/video/ogv/"	# output .ogv files to this directory

if    [ $# -eq 0 ]
then	# no arguments provided therefore process the top item of our playlist
	if [ -s "${playlist}" ]
	then	# playlist is not empty
		exec $0 $(head -n 1 ${playlist}) # recursive call (with default (no) argument implying playlist).
	fi
fi
while [ $# -ne 0 ]
do	# translate video then prompt to delete source video file(s):
	nice ionice -c 3 ffmpeg2theora -o "${oggdir}"/`basename "$1"`.ogv	"$1" || exit $? \
&&	/usr/local/bin/delete -i				"$1" || exit $?
	# output filename of resulting video .ogv file.
	echo	"${oggdir}"/`basename "$1"`.ogv	1>&2
	shift	# iterate next argument to command
done
