#!/bin/bash # make mplayer dump rawvideo to stdout, so it can be opened using # open-program in pf # mplayer/mencoder is obviously not made to do this, since it dumps # status info both to stdout and stderr, so we work around it. # note, it is possible to dump out yuv4mpeg, using mplayer -vo # yuv4mpeg:file= which can be imported in pf, but this has # mplayer as the sync master, which is not what i want to do # here. therefore, mencoder is used instead. # need at least one arg [ -z "$1" ] && echo "usage $0 [ ]" >&2 && exit 1 # check if file exists, and is readable [ ! -f "$1" ] && echo "$0: \"$1\" not found" >&2 && exit 1 FIFO=`tempfile -p pf-` rm $FIFO mkfifo $FIFO # fill defaults if [ -z "$5" ]; then FORMAT=i420 WIDTH=320 HEIGHT=240 else FORMAT=$3 WIDTH=$4 HEIGHT=$5 fi # spawn 'reader' # cat $FIFO & bash -c "cat $FIFO ; rm $FIFO" & # make mencoder shut up exec 1>/dev/null exec 2>/dev/null # convert exec mencoder -quiet \ -ovc raw \ -of rawvideo \ -vf format=$FORMAT,crop=$WIDTH:$HEIGHT \ $1 -o $FIFO