Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robert-wallis/28f7502d8a28ccd045d8027977cef106 to your computer and use it in GitHub Desktop.
Save robert-wallis/28f7502d8a28ccd045d8027977cef106 to your computer and use it in GitHub Desktop.
Raspberry PI 4; 4" 480x800 viewfinder; Webcam mirrored on HDMI-2
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name[en_US]=Mirror Webcam 1080p
Type=Application
Exec=/home/pi/mirror-1080p-mplayer.sh
Categories=AudioVideo;Player
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name[en_US]=Mirror Webcam 720p
Type=Application
Exec=/home/pi/mirror-720p-mplayer.sh
Categories=AudioVideo;Player
#!/bin/sh
if ! grep -q 'Raspberry Pi' /proc/device-tree/model \
|| (grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null \
|| grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null \
|| grep -q okay /proc/device-tree/v3dbus/v3d@7ec04000/status 2> /dev/null) ; then
if xrandr --output HDMI-2 --mode 1280x720 --primary \
--output HDMI-1 --mode 480x800 --scale-from 768x1280 --rotate left --same-as HDMI-2 \
--dryrun ; then
xrandr --output HDMI-2 --mode 1280x720 --primary \
--output HDMI-1 --mode 480x800 --scale-from 768x1280 --rotate left --same-as HDMI-2
elif xrandr --output HDMI-2 --mode 1280x720 --rate 60.00 --pos 0x0 --rotate normal \
--output HDMI-1 --primary --mode FIXED_MODE --rate 59.78 --pos 0x0 --rotate left \
--dryrun ; then
xrandr --output HDMI-2 --mode 1280x720 --rate 60.00 --pos 0x0 --rotate normal \
--output HDMI-1 --primary --mode FIXED_MODE --rate 59.78 --pos 0x0 --rotate left
fi
fi
if [ -e /usr/share/tssetup.sh ] ; then
. /usr/share/tssetup.sh
fi
exit 0
#!/bin/bash
echo setting HDMI-2 to 1080p
echo setting HDMI-1 to mirror and scale to 1080p
xrandr --fb 1920x1080 \
--output HDMI-2 --mode 1920x1080 --primary \
--output HDMI-1 --mode 480x800 --scale-from 1152x1920 --rotate left --same-as HDMI-2
sleep 1
echo displaying webcam at 1080p full-screen
mplayer tv:// -tv driver=v4l2:width=1920:height=1080:device=/dev/video0 -fs
#!/bin/bash
echo setting HDMI-2 to 720p
echo setting HDMI-1 to mirror and scale to 720p
xrandr --fb 1280x720 \
--output HDMI-2 --mode 1280x720 --primary \
--output HDMI-1 --mode 480x800 --scale-from 768x1280 --rotate left --same-as HDMI-2
sleep 1
echo displaying webcam at 720p full-screen
mplayer tv:// -tv driver=v4l2:width=1280:height=720:device=/dev/video0 -fs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment