Skip to content

Instantly share code, notes, and snippets.

@xevz
Created March 26, 2010 02:27
Show Gist options
  • Select an option

  • Save xevz/344407 to your computer and use it in GitHub Desktop.

Select an option

Save xevz/344407 to your computer and use it in GitHub Desktop.
MPlayer wrapper script for VDPAU
#!/bin/sh
# Video filters: dsize=1280:1024:0,scale=0:0,expand=::::1:1280/1024:,harddup
MPLAYER=$HOME/bin/mplayer-bin
CLEAR_FILTERS='-vf-del 0,1,2,3'
ARGUMENTS=
FILE=
for arg in "$*"; do
[ -f "$arg" ] && FILE="$arg"
done
CODEC=$($MPLAYER -identify -frames 0 "$FILE" 2>&1 | grep ID_VIDEO_CODEC | cut -d= -f2)
if [ "$CODEC" ]; then
FOUND_CODEC=$($MPLAYER -vc help 2> /dev/null | grep working | egrep "${CODEC}.*vdpau" | cut -d' ' -f1)
fi
# The graphics card running the third monitor does not support VDPAU
if [ "$DISPLAY" = ':0.2' ]; then
$MPLAYER $ARGUMENTS "$@"
exit 0;
fi
if [ "$FOUND_CODEC" ]; then
# Don't use my filters with VDPAU on the main monitor
ARGUMENTS="$ARGUMENTS -vo vdpau -vc $FOUND_CODEC $CLEAR_FILTERS"
# Use fullscreen on the main monitor
if [ "$DISPLAY" = ':0.0' ]; then
ARGUMENTS="$ARGUMENTS -fs"
fi
fi
# Don't use video filters on other monitors than the main monitor
if [ ! "$DISPLAY" = ':0.0' ]; then
ARGUMENTS="$ARGUMENTS $CLEAR_FILTERS"
fi
$MPLAYER $ARGUMENTS "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment