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