From 4b72d75490e51c2fd443b0254827bc40bdaf1e0c Mon Sep 17 00:00:00 2001 From: deflax Date: Sun, 11 Feb 2018 15:35:04 +0200 Subject: [PATCH] x11record.sh script to capture a window by name (works on main screen only atm) and write the output to file (or youtube) --- x11record.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 x11record.sh diff --git a/x11record.sh b/x11record.sh new file mode 100644 index 0000000..af04cc9 --- /dev/null +++ b/x11record.sh @@ -0,0 +1,36 @@ +#! /bin/bash +# +# afx + +VBR="1500k" +FPS="30" +#QUAL="medium" +QUAL="veryfast" +YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" +KEY="..." + +WINNAME="Minecraft 1.12.2" + +##################### +offset_x=`xwininfo -name "$WINNAME" | grep geometry | cut -d '+' -f2` +offset_y=`xwininfo -name "$WINNAME" | grep geometry | cut -d '+' -f3` +width=`xwininfo -name "$WINNAME" | grep Width | cut -d ':' -f2 | tail -c +2 | head -c -1` +height=`xwininfo -name "$WINNAME" | grep Height | cut -d ':' -f2 | tail -c +2 | head -c -1` + +echo "x11 to youtube capture" +echo "-=-=-=-=-=-=-=-=-=-=-=" +echo $WINNAME resolution: $width x $height +echo $WINNAME X offset: $offset_x +echo $WINNAME Y offset: $offset_y +echo " " +echo "Ready?" +read + +ffmpeg \ + -video_size "$width"x"$height" -f x11grab -s "$width"x"$height" -i :0.0+"$offset_x","$offset_y" \ + -f pulse -ac 2 -i default \ + -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \ + -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \ + test.mp4 +# -f "$YOUTUBE_URL/$KEY" +