examples/mplayer.sh.example
author nathan
Sat, 24 Oct 2009 11:20:45 +0800
branchtrunk
changeset 31 566c0f412764
parent 0 474a1293c3c0
permissions -rw-r--r--
set environment variable with DVB device number
     1 #!/bin/bash
     2 #
     3 # This script is called from VDR to start MPlayer
     4 #
     5 # argument 1: the file to play
     6 # argument 2: (optional) the phrase SLAVE if SlaveMode is enabled
     7 # argument 3: (optional) the phrase AID x to select audio stream x
     8 
     9 # where to find mplayer
    10 MPLAYER="mplayer"
    11 
    12 # mplayer options, -vc will be added below
    13 # add "-lircconf <lircrc>" to enable LIRC support
    14 OPTS="-vo mpegpes"
    15 if [ "aa$DVB_DEVICE" != "aa" ]; then
    16   OPTS="-vo mpegpes:card=$DVB_DEVICE -ao mpegpes:card=$DVB_DEVICE"
    17 fi
    18 
    19 # mplayer options for SlaveMode
    20 SLAVE="-slave -quiet -nolirc"
    21 
    22 #####################
    23 
    24 FILE=$1
    25 case "$FILE" in
    26 *.pls | *.m3u)
    27   popt="-playlist"
    28   first=`grep -v -m1 "^#" $FILE`
    29   type=`file "$first"`
    30   ;;
    31 *)
    32   type=`file "$FILE"`
    33   ;;
    34 esac
    35 
    36 while shift; do
    37   if [ "$1" = "SLAVE" ]; then
    38     sopt=$SLAVE
    39   elif [ "$1" = "AID" ]; then
    40     aopt="-aid $2"
    41     shift
    42   fi
    43 done
    44 
    45 case "$type" in
    46 *AVI*)
    47   VC="ffdivx"
    48   ;;
    49 *MPEG*)
    50   VC="mpegpes"
    51   ;;
    52 *)
    53   echo "Unknown video file format $type"
    54   echo "Edit mplayer.sh to support this file type"
    55   exit 1
    56   ;;
    57 esac
    58 
    59 exec $MPLAYER $OPTS -vc $VC $sopt $aopt $popt "$FILE"
    60