Clipinc.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
Zeile 9: Zeile 9:
 
# folgende zeilen in die reccmds.conf eintragen:
 
# folgende zeilen in die reccmds.conf eintragen:
 
#
 
#
# Run clipinc        : /usr/local/bin/clipinc.sh -start
+
# Run clipinc        : /path_to_this_script/clipinc.sh -start
# Run clipinc + 2mp3 : /usr/local/bin/clipinc.sh -start -2mp3
+
# Run clipinc + 2mp3 : /path_to_this_script/clipinc.sh -start -2mp3
# Stop clipinc?      : /usr/local/bin/clipinc.sh -kill
+
# Stop clipinc?      : /path_to_this_script/clipinc.sh -kill
  
 
# CONFIG START
 
# CONFIG START
Zeile 20: Zeile 20:
 
# CONFIG END
 
# CONFIG END
  
PATH=/usr/local/bin:$PATH
+
PATH=/usr/local/bin:$PATH:$PREFIX/bin
  
 
case "$1" in
 
case "$1" in
 
     -start)
 
     -start)
at now <<EOF
+
at now <<EOT
 
PID=`pidof -x clipinc.pl`
 
PID=`pidof -x clipinc.pl`
 
if [ -n "\$PID" ] ; then
 
if [ -n "\$PID" ] ; then
Zeile 32: Zeile 32:
 
clipinc.pl "$2"
 
clipinc.pl "$2"
 
    elif [ -e "$3/recinfo.conf" ] ; then
 
    elif [ -e "$3/recinfo.conf" ] ; then
if [ $(ldd $(which ffmpeg) | grep -c libmp3lame.so) -lt 1 ] ; then
+
clipinc.pl "$3"
    echo "Unsupported codec, 'configure' ffmpeg with ('--enable-mp3lame')..."
+
SESSION="$CLIPINC2DIR/$(date +%c)"
else
+
find "$CLIPINCDIR" -name "001.vdr" | sed '/\.rec\/001\.vdr/!d' | while read i ; do
    clipinc.pl "$3"
+
    cd "\$(echo \$i | sed -e 's/.\{8\}$//g')"
    find "$CLIPINCDIR" -name "001.vdr" | sed '/\.rec\/001\.vdr/!d' | while read i ; do
+
    LABEL=\$(dirname "\$(pwd)")
cd "\$(echo \$i | sed -e 's/.\{8\}$//g')"
+
    NAME="\${LABEL##*/}"
LABEL=\$(dirname "\$(pwd)")
+
    mkdir -p "$SESSION"
NAME="\${LABEL##*/}"
+
    find "\$SESSION" -type f -empty -exec rm -f '{}' ';'
find "\$CLIPINC2DIR" -type f -empty -exec rm -f '{}' ';'
+
    if [ ! -e "\$SESSION/\$NAME.mp3" -a -f 001.vdr ] ; then
if [ ! -e "\$CLIPINC2DIR/\$NAME.mp3" -a -f 001.vdr ] ; then
+
TITLE="\${NAME##*_-_}"
    TITLE="\${NAME##*_-_}"
+
AUTHOR="\${NAME%%_-_*}"
    AUTHOR="\${NAME%%_-_*}"
+
case $2 in
    ffmpeg \
+
    -mp3)
-i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \
+
if [ $(ldd $(which ffmpeg) | grep -c libmp3lame.so) -lt 1 ] ; then
\${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "$CLIPINC2DIR/\$NAME.mp3" &
+
    echo "Unsupported codec, 'configure' ffmpeg with ('--enable-mp3lame')..."
    wait
+
    break
fi
+
fi
    done
+
ffmpeg \
fi
+
    -i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \
 +
\${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "$SESSION/\$NAME.mp3" &
 +
;;
 +
    -2avi)
 +
:
 +
;;
 +
    -2mpg)
 +
:
 +
;;
 +
esac
 +
wait
 +
    fi
 +
done
 
    else
 
    else
 
svdrpsend.pl MESG "recinfo.conf not found..."
 
svdrpsend.pl MESG "recinfo.conf not found..."
Zeile 56: Zeile 68:
 
fi \
 
fi \
 
> $CLIPINC_LOGFILE 2>&1
 
> $CLIPINC_LOGFILE 2>&1
EOF
+
EOT
 
;;
 
;;
 
     -kill)
 
     -kill)

Version vom 16. April 2005, 12:31 Uhr

#!/bin/sh
#
# clipinc.sh
#
# Required: at, clipinc.pl, lame, ffmpeg ('--enable-mp3lame')
#
# add this lines to your reccmds.conf:
# folgende zeilen in die reccmds.conf eintragen:
#
# Run clipinc        : /path_to_this_script/clipinc.sh -start
# Run clipinc + 2mp3 : /path_to_this_script/clipinc.sh -start -2mp3
# Stop clipinc?      : /path_to_this_script/clipinc.sh -kill

# CONFIG START
  AUDIO_CODEC=""     # force audio codec ('copy' to copy stream) -> default ('mp3')
  AUDIO_BITRATE=""   # set audio bitrate (in kbit/s)		 -> default ('192')
  AUDIO_SAMPLING=""  # set audio sampling rate (in Hz)		 -> default ('44100')
  CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
# CONFIG END

PATH=/usr/local/bin:$PATH:$PREFIX/bin

case "$1" in
    -start)
	at now <<EOT
	PID=`pidof -x clipinc.pl`
	if [ -n "\$PID" ] ; then
	    svdrpsend.pl MESG "Sorry, but clipinc.pl is running with pid (\$PID)..."
	else
	    if [ -e "$2/recinfo.conf" ] ; then
		clipinc.pl "$2"
	    elif [ -e "$3/recinfo.conf" ] ; then
		clipinc.pl "$3"
		SESSION="$CLIPINC2DIR/$(date +%c)"
		find "$CLIPINCDIR" -name "001.vdr" | sed '/\.rec\/001\.vdr/!d' | while read i ; do
		    cd "\$(echo \$i | sed -e 's/.\{8\}$//g')"
		    LABEL=\$(dirname "\$(pwd)")
		    NAME="\${LABEL##*/}"
		    mkdir -p "$SESSION"
		    find "\$SESSION" -type f -empty -exec rm -f '{}' ';'
		    if [ ! -e "\$SESSION/\$NAME.mp3" -a -f 001.vdr ] ; then
			TITLE="\${NAME##*_-_}"
			AUTHOR="\${NAME%%_-_*}"
			case $2 in
			    -mp3)
				if [ $(ldd $(which ffmpeg) | grep -c libmp3lame.so) -lt 1 ] ; then
				    echo "Unsupported codec, 'configure' ffmpeg with ('--enable-mp3lame')..."
				    break
				fi
				ffmpeg \
				    -i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \
					\${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "$SESSION/\$NAME.mp3" &
				;;
			    -2avi)
				:
				;;
			    -2mpg)
				:
				;;
			esac
			wait
		    fi
		done
	    else
		svdrpsend.pl MESG "recinfo.conf not found..."
	    fi
	fi \
	> $CLIPINC_LOGFILE 2>&1
EOT
	;;
    -kill)
	PID=`pidof -x clipinc.pl`
	eval ${PID:+kill -9 $PID}
	;;
esac