Last active
September 24, 2018 15:59
-
-
Save jeanparpaillon/b7ea7aae590ec3e2f4b12e9afc3621ba to your computer and use it in GitHub Desktop.
ffmpeg screen casting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function at_exit { | |
sudo rmmod v4l2loopback 2> /dev/null | |
} | |
function usage { | |
echo "Usage: $0 [<screen>]" | |
} | |
trap at_exit EXIT | |
video_nr=$(( $(ls /dev/video* | sort -nr | head -n1 | sed -e 's#/dev/video##') + 1 )) | |
sudo modprobe v4l2loopback video_nr=$video_nr 'card_label=screenShare' exclusive_caps=1 | |
SCREEN=${1:-0} | |
monitor=$(xrandr --listmonitors | awk -e '/^\s+'$SCREEN':/ { print $3 }') | |
screen_w=$(echo $monitor | awk -Fx '{ print $1 }' | awk -F/ '{ print $1 }') | |
screen_h=$(echo $monitor | awk -Fx '{ print $2 }' | awk -F/ '{ print $1 }') | |
screen_x=$(echo $monitor | awk -F+ '{ print $2 }') | |
screen_y=$(echo $monitor | awk -F+ '{ print $3 }') | |
ffmpeg -loglevel error -f x11grab -r 20 -s ${screen_w}x${screen_h} -i :0.0+${screen_x},${screen_y} -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video${video_nr} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment