#!/bin/sh

# put file to /root, then
# chmod 755 /root/externremux.sh
# echo -r /root/externremux.sh > /etc/vdr/plugins/plugin.streamdev-server.conf
# /etc/init.d/vdr restart
# you can use any other postition too (just exchnage /root)
# usage
# xine http://127.0.0.1:3000/Extern/1

STREAMQUALITY="LAN10"

if [ -e /etc/vdr/sysconfig ]; then
 . /etc/vdr/sysconfig
fi

IN=-
OUT=/tmp/out-$RANDOM
rm -f $OUT.avi /tmp/out-*log
/usr/bin/mkfifo $OUT.avi

case "$STREAMQUALITY" in 
  "DSL1000")
    cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=100 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=160:104  -o $OUT.avi &>$OUT.log
  ;;
  "DSL2000")	
    cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=128 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=160:104  -o $OUT.avi &>$OUT.log
  ;;
  "DSL6000")	
    cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=350 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=320:208  -o $OUT.avi &>$OUT.log
  ;;
  "LAN10")
    cat $OUT.avi & /usr/bin/mencoder "$IN"  -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4096 -oac mp3lame -lameopts preset=standard -o $OUT.avi &>$OUT.log
  ;;
  "WLAN11")
    cat $OUT.avi & /usr/bin/mencoder "$IN"  -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=768 -oac mp3lame -lameopts preset=standard -vf scale=640:408 -o $OUT.avi &>$OUT.log
  ;;
  "WLAN54")
    cat $OUT.avi & /usr/bin/mencoder "$IN"  -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2048 -oac mp3lame -lameopts preset=standard -o $OUT.avi &>$OUT.log
  ;;
  "IPAQ")
    cat $OUT.avi & /usr/bin/mencoder "$IN" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=350 -oac mp3lame -lameopts preset=15:mode=3 -vf scale=320:208 -o $OUT.avi &>$OUT.log
  ;;
esac

rm -f $OUT.avi /tmp/$OUT.log

#usr/bin/mencoder -srate 44100 -ovc lavc -lavcopts vbitrate=1500 -oac mp3lame -lameopts cbr:br=128 -vf scale=400:300 -o /tmp/out.avi -- - &>/tmp/out.log
 