All pastes #738126 Raw Edit

mplayer fs x11

public text v1 · immutable
·published 2007-10-16 01:03 UTC
rendered paste body
#!/bin/bash

SCREEN_WIDTH=1280
SCREEN_HEIGHT=800
DISPLAY=:0.0

###################################################################
# Make playing fullscreen video using the x11 output less painful
# by: nikosapi :)
###################################################################

for app in mplayer bc; do
    if ! which $app > /dev/null; then
        echo "Install $app and try again."
        exit 1
    fi
done

video="$@"

video_width=`mplayer -identify -nolirc -frames 0 -vo null -ao null "$video" | grep ID_VIDEO_WIDTH | cut -f 2 -d "="`
video_height=`mplayer -identify -nolirc -frames 0 -vo null -ao null "$video" | grep ID_VIDEO_HEIGHT | cut -f 2 -d "="`

video_ratio=`echo "scale=4; i = $video_width / $video_height * 1000; scale=0; i / 1" | bc`
screen_ratio=`echo "scale=4; i = $SCREEN_WIDTH / $SCREEN_HEIGHT * 1000; scale=0; i / 1" | bc`

if [ $video_ratio -ge $screen_ratio ]; then
    scale_width=$SCREEN_WIDTH
    scale_height=`echo "scale=4; i = $SCREEN_WIDTH / $video_ratio * 1000; scale=0; i / 1" | bc`
else
    scale_width=`echo "scale=4; i = $SCREEN_HEIGHT * $video_ratio / 1000; scale=0; i / 1" | bc`
    scale_height=$SCREEN_HEIGHT
fi

mplayer -fs -vo x11 -vf scale="$scale_width":"$scale_height" "$video"