2 #testcommand for media player
3 #parameters: command [filename] [...]
5 # play filename xsize ysize
6 #return -1 if any error (no output!)
7 #this script is prepared for tools writing to stdout or requiring a file name
8 # for tools writing to stdout simple create a new convertXXX function
9 # that sends the tool to background and sets MPID to the pid
10 # for tools requiring a filename call createFifo first, then
11 # also create a function that sends the tool in background
12 # after starting the conversion tool call waitFkt, this will kill the conversion
13 # tool and the fifo reader if we are killed or if one of the tools finishes
21 #echo "$$:`date `:$*" >> /tmp/test1.log
26 if [ "$MPID" != "" ] ; then
27 kill $MPID > /dev/null 2>&1
28 kill -9 $MPID > /dev/null 2>&1
30 if [ "$FPID" != "" ] ; then
31 kill $FPID > /dev/null 2>&1
32 kill -9 $FPID > /dev/null 2>&1
34 if [ -p $FIFO ] ; then
39 #create a fifo and start a cat
41 mkfifo $FIFO >/dev/null 2>&1 || exit 1
46 #convert AVI to mpeg2, suing mencoder see
47 #http://www.wiki.csoft.at/index.php/MEncoder_Scripts
49 #mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=mp2:abitrate=192 $RTOP -o $FIFO $1 > /dev/null 2>&1 &
50 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=5000:vbitrate=3000:keyint=15:acodec=mp2:abitrate=192 $RTOP -o $FIFO $1 > /dev/null 2>&1 &
54 #convert WAV to mpeg using lame
56 lame -v -b 192 -S $1 - - 2>&1 &
60 #convert pictures using GraphicsMagic
62 if [ "$2" != "" -a "$3" != "" ] ; then
63 fopt="-geometry ${2}x$3"
65 gm convert $fopt "$1" jpeg:- 2>&1 &
76 #handle http:// as audio-url
78 cat "$1" 2>&1 | sed 's?^ *http:\(.*\)?/http:\1.http-audio?'
81 #get a HTTP url via wget
83 wget -q -O - "$1" 2>&1 &
91 #wait until the cat or the converter have been stopped
96 if [ "$MPID" != "" ] ; then
97 kill -0 $MPID >/dev/null 2>&1 || dokill=1
99 if [ "$FPID" != "" ] ; then
100 kill -0 $FPID >/dev/null 2>&1 || dokill=1
102 if [ $dokill = 1 ] ; then
103 log "killing MPID=$MPID FPID=$FPID"
104 kill -9 $MPID > /dev/null 2>&1
106 kill -9 $FPID > /dev/null 2>&1
109 if [ "$FPID" = "" -a "$MPID" = "" ] ; then
119 log started with param "$*"
120 if [ "$1" = "" ] ; then
124 trap trapfkt 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15
130 exts=`echo "$2" | sed 's/.*\.//'`
131 if [ "$exts" = "" ] ; then
134 fname=`echo "$2" | sed 's/\.[^.]*$//'`
146 [ "$nname" = "" ] && exit 1
147 [ ! -f "$nname" ] && exit 1
148 convertPicture "$nname" $3 $4
158 #real converting functions
159 bmp|BMP|tiff|TIFF|png|PNG)
160 convertPicture "$2" $3 $4
165 convertAVI "$2" $3 $4
181 fn=`echo "$2" | sed 's/\.[^.]*$//' | sed 's?^ */??'`