Using MPlayer to Play a Video on a Wall Display

Given:

  • a wall display made of 35 displays
  • 3 display PCs (each PC drives up to 12 displays)
  • each display is configured as a separated X-Screen
  • each display PC is able to connect to another display PC over ssh without a password

Requirements:

  • mplayer
  • socat
  • ssh

Approach:

MPlayer synchronizes master and slave instances by sending UDP packages with a frame number to the port 23867. Thus, we have to configure port forwarding on each display PC to be able to run multiple slave instances on a single PC. We use socat to achieve that.

$ socat -u UDP4-RECVFROM:23867,fork - | 
tee >(socat -u - UDP4-SENDTO:192.168.1.XXX:24800) 
>(socat -u - UDP4-SENDTO:192.168.1.XXX:24801) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24802) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24803) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24804) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24805) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24806) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24807) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24808) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24809) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24810) 
>(socat -u - uDP4-SENDTO:192.168.1.XXX:24811) 
> /dev/null
 

Next, we start mplayer slaves on each display PC.

$ mplayer -display :0.6 -vf crop=384:204:0:204 -noborder -geometry 1920x1080 -udp-slave -udp-port 24800 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &
$ mplayer -display :0.7 -vf crop=384:204:0:408 -noborder -geometry 1920x1080 -udp-slave -udp-port 24801 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &
$ mplayer -display :0.9 -vf crop=384:204:0:612 -noborder -geometry 1920x1080 -udp-slave -udp-port 24802 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &
$ mplayer -display :0.10 -vf crop=384:204:384:612 -noborder -geometry 1920x1080 -udp-slave -udp-port 24803 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &
$ mplayer -display :0.11 -vf crop=384:204:768:612 -noborder -geometry 1920x1080 -udp-slave -udp-port 24804 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &

We can use ssh to start mplayer slaves remotely on display PCs

$ ssh 10.20.152.32 'mplayer -display :0.4 -vf crop=384:204:384:0 -noborder -geometry 1920x1080 -udp-slave -udp-port 24800 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.1 -vf crop=384:204:768:0 -noborder -geometry 1920x1080 -udp-slave -udp-port 24801 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.9 -vf crop=384:204:1152:0 -noborder -geometry 1920x1080 -udp-slave -udp-port 24802 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.5 -vf crop=384:204:384:204 -noborder -geometry 1920x1080 -udp-slave -udp-port 24803 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.3 -vf crop=384:204:768:204 -noborder -geometry 1920x1080 -udp-slave -udp-port 24804 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.10 -vf crop=384:204:1152:204 -noborder -geometry 1920x1080 -udp-slave -udp-port 24805 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.6 -vf crop=384:204:384:408 -noborder -geometry 1920x1080 -udp-slave -udp-port 24806 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.8 -vf crop=384:204:768:408 -noborder -geometry 1920x1080 -udp-slave -udp-port 24807 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.32 'mplayer -display :0.11 -vf crop=384:204:1152:408 -noborder -geometry 1920x1080 -udp-slave -udp-port 24808 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.33 'mplayer -display :0.5 -vf crop=384:204:1536:0 -noborder -geometry 1920x1080 -udp-slave -udp-port 24800 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.33 'mplayer -display :0.6 -vf crop=384:204:1536:204 -noborder -geometry 1920x1080 -udp-slave -udp-port 24801 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.33 'mplayer -display :0.7 -vf crop=384:204:1536:408 -noborder -geometry 1920x1080 -udp-slave -udp-port 24802 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.33 'mplayer -display :0.9 -vf crop=384:204:1536:612 -noborder -geometry 1920x1080 -udp-slave -udp-port 24803 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'
$ ssh 10.20.152.33 'mplayer -display :0.10 -vf crop=384:204:1152:612 -noborder -geometry 1920x1080 -udp-slave -udp-port 24804 c01-global-home/video/Sintel.2010.1080p.mkv /dev/null 2>&1 &'

Of course, we can wrap all these commands in a single bash script.

Next, we start mplayer master instance.

$ mplayer -display :0.5 -vf crop=384:204:0:0 -noborder -geometry 1920x1080 -udp-master -udp-ip 192.168.1.255 -udp-port 23867 c01-global-home/video/Sintel.2010.1080p.mkv

 

%d