July 2011
I grab my home videos from tape using dvgrab, and have it automatically split scenes. This generates many .dv files, some of which I decide to not even process. I wanted to be able to press a key from mplayer in order to mark them for deletion. This is how I did it:
In /home/jurjen/.mplayer/input.conf
, put:
DEL run /home/jurjen/.mplayer/envlist
then, in /home/jurjen/.mplayer/envlist
put this little script:
#!/bin/sh OUTFILE=/tmp/delete-candidates # On multiuser machines, output and grep on $USER too MYPID=$(ps axo '%p %c'|grep [m]player$|awk '{print $1}') if [ "$(echo ${MYPID}|wc -w)" -ne 1 ] ; then echo "#no safe output: too many PIDs: \"${MYPID}\" ($(echo ${MYPID}|wc -c))" exit 1 fi IFS=' ' for FILE in $(lsof -p ${MYPID} -Ftn |grep -A1 ^tREG|grep ^n|sed 's/^n//g') ; do if test -w "${FILE}" ; then echo "${FILE}" >> ${OUTFILE} fi done
That does the trick: the file /tmp/delete-candidates gets filled with the filenames of the files playing while I pressed Delete Of course it would've been nicer if I wouldn't have had to fetch those filenames from /proc. Oh wel...