Revisions
-
hickscorp revised this gist
Sep 24, 2018 . 1 changed file with 30 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,37 @@ #!/bin/bash if [[ $EUID -ne 0 ]]; then exec sudo $0 $* exit 0 fi function at_exit { echo "Removing capture module..." rmmod v4l2loopback 2> /dev/null } trap at_exit EXIT SCREEN=${1:-0} MONITOR=$(xrandr --listmonitors | awk -e '/^\s+'$SCREEN':/ { print $3 }') VIDEO_NR=$(( $(find /dev -name 'video*' | sort -nr | head -n1 | sed -e 's#/dev/video##') + 1 )) DEVICE="/dev/video$VIDEO_NR" echo "Loading module v4l2loopback over video $DEVICE..." modprobe v4l2loopback video_nr=$VIDEO_NR 'card_label=screenCap' exclusive_caps=1 echo "Calculating capture geometry for monitor $MONITOR" X=$(echo $MONITOR | awk -F+ '{ print $2 }') Y=$(echo $MONITOR | awk -F+ '{ print $3 }') WIDTH=$(echo $MONITOR | awk -Fx '{ print $1 }' | awk -F/ '{ print $1 }') HEIGHT=$(echo $MONITOR | awk -Fx '{ print $2 }' | awk -F/ '{ print $1 }') echo "Starting capture with geometry ${WIDTH}x${HEIGHT}@${X},${Y} to device $DEVICE..." ffmpeg -loglevel error \ -f x11grab \ -r 30 \ -s ${WIDTH}x${HEIGHT} \ -i :0.0+${X},${Y} \ -vcodec rawvideo \ -pix_fmt yuv420p \ -threads 0 \ -f v4l2 $DEVICE -
Jean Parpaillon revised this gist
Aug 3, 2018 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,11 @@ #!/bin/bash function at_exit { sudo rmmod v4l2loopback 2> /dev/null } function usage { echo "Usage: $0 [<screen>]" } trap at_exit EXIT @@ -17,6 +14,14 @@ video_nr=$(( $(ls /dev/video* | sort -nr | head -n1 | sed -e 's#/dev/video##') + 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 -
Jean Parpaillon created this gist
Aug 3, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #!/bin/bash SCREEN_W=1920 SCREEN_H=1080 function at_exit { sudo rmmod v4l2loopback 2> /dev/null } function usage { echo "Usage: $0" } 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 ffmpeg -loglevel error -f x11grab -r 20 -s ${SCREEN_W}x${SCREEN_H} -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video${video_nr} exit 0