#!/bin/bash
#                       /usr/local/bin/video2music
# https://crystalfaeries.net/posix/bin/video2music
# celeste:crystalfaery VIDEO2MUSIC 2016-10-31 01:34:16+00:00
# got videos that are really just music with useless video of static images?
# convert them to .ogg audio files and prompt interactively to delete video.
# by default with no arguments, we process the the first item in our playlist.

# CONFIGURATION: ( see also local BASH script: /usr/local/bin/monitor )
playlist="${HOME}/documents/playlists/txt/monitor.txt"	# text format listing of input file_paths
oggdir="/home/audio/ogg/"				# output .ogg 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).
		shift				 # iterate next argument to command	*giggles* :-)
	fi
fi
while [ $# -ne 0 ]
do	# extract audio then prompt to delete source video file(s):
	nice ionice -c 3 ffmpeg2theora --novideo -o "${oggdir}"/`basename "$1"`.ogg	"$1" || exit $? \
&&	/usr/local/bin/delete -i							"$1" || exit $?
	# output filename of resulting audio .ogg file.
	echo					    "${oggdir}"/`basename "$1"`.ogg	\
						1>&2	# output filename of resulting audio .ogg file.
	shift				 	  # iterate next argument to command
done


syntax highlighted by Code2HTML, v. 0.9.1