Skip to content

Instantly share code, notes, and snippets.

@djaney
Last active July 8, 2020 08:22
Show Gist options
  • Save djaney/0e16172a58b5415dfd28050b48a41829 to your computer and use it in GitHub Desktop.
Save djaney/0e16172a58b5415dfd28050b48a41829 to your computer and use it in GitHub Desktop.
#!/bin/bash
# intall
# curl https://gist.githubusercontent.com/djaney/0e16172a58b5415dfd28050b48a41829/raw/8f447171e880a2d82d031ef1ecacde4f52e343d3/djane.sh > ~/.local/bin/djane && chmod +x ~/.local/bin/djane
function install {
sudo apt-get update -y
sudo apt-get install -y v4l-utils
sudo apt-get install -y gphoto2
sudo apt-get install -y v4l2loopback-utils
}
function configure {
# do not minimize games when out of focus
if ! cat /etc/environment | grep SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS -q; then
echo "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0" >> /etc/environment
fi
}
function arcanysvpn {
sudo openvpn --config /home/djane/vpn/arcanys/Arcanys.ovpn --auth-user-pass /home/djane/vpn/arcanys/pass.txt
}
function iphonecam {
sudo modprobe v4l2loopback
ffmpeg -i rtsp://$1:8554/live.sdp -f v4l2 /dev/video0
}
function iphonecambg {
W=640
H=360
CAMIP=$1
BG=$2
TMP_IMG=$(mktemp /tmp/birtualbg.XXXXXX.jpg)
sudo modprobe v4l2loopback
ffmpeg -i rtsp://$CAMIP:8554/live.sdp -vframes 1 -f image2 $TMP_IMG
ffmpeg \
-i $BG \
-i rtsp://$CAMIP:8554/live.sdp \
-i $TMP_IMG \
-filter_complex \
"
color=#00ff00:size=${W}x${H} [matte];
[1:0] format=rgb24, scale=${W}:${H},setdar=16/9, split[mask][video];
[2:0] format=rgb24, scale=$W:$H,setdar=16/9 [ref];
[ref][mask] blend=all_mode=difference,
curves=m='0/0 .1/0 .2/1 1/1',
format=gray,
smartblur=1,
eq=brightness=30:contrast=3,
eq=brightness=50:contrast=2,
eq=brightness=-10:contrast=50,
smartblur=3,
format=rgb24 [mask];
[matte][video][mask] maskedmerge,format=rgb24
" \
-shortest \
-pix_fmt yuv422p \
-t "00:00:03" \
-f v4l2 /dev/video0
rm $TMP_IMG
}
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment