From 6c1422aa535441bb8f00227dec3f7812c5edf99e Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 2 Dec 2016 12:54:20 +0100 Subject: [PATCH] Add gst-screencast.sh --- shell/gst-screencast.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 shell/gst-screencast.sh diff --git a/shell/gst-screencast.sh b/shell/gst-screencast.sh new file mode 100755 index 0000000..1902f49 --- /dev/null +++ b/shell/gst-screencast.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +# gst-screencast - screencasting of a window using GStreamer +# +# Copyright (C) 2015 Antonio Ospite +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What The Fuck You Want +# To Public License, Version 2, as published by Sam Hocevar. See +# http://sam.zoy.org/wtfpl/COPYING for more details. + +set -e +set -x + +[ "x" = "x$1" ] && { echo "usage: $(basename $0) []" 1>&2; exit 1; } + +[ -f "$1" ] && { echo "ERROR: file already exists!" 1>&2; exit 2; } + +FILENAME="$1" + +if [ "x" = "x$2" ]; +then + # uncomment to capure the whole frame with window manager border and decorations + XWININFO_OPTIONS="-frame" + + WIN_INFO="$(xwininfo $XWININFO_OPTIONS)" + + #XID=$(echo "$WIN_INFO" | grep "Window id" | cut -d ' ' -f 4) + #XIMAGESRC_ARGS="xid=$XID" + + X=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Absolute upper-left X:[[:space:]]*/s///p") + Y=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Absolute upper-left Y:[[:space:]]*/s///p") + WIDTH=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Width:[[:space:]]*/s///p") + HEIGHT=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Height:[[:space:]]*/s///p") + + BORDER_SIZE=27 + XIMAGESRC_ARGS="startx=$(($X - $BORDER_SIZE)) starty=$(($Y - $BORDER_SIZE)) endx=$(($X + $WIDTH + $BORDER_SIZE)) endy=$(($Y + $HEIGHT + $BORDER_SIZE))" + + XIMAGESRC_ARGS="startx=$(($X - $BORDER_SIZE - 1)) starty=$(($Y - $BORDER_SIZE - 7)) endx=$(($X + $WIDTH + $BORDER_SIZE)) endy=$(($Y + $HEIGHT + $BORDER_SIZE + 7))" +else + XIMAGESRC_ARGS="$2" +fi + +VIDEO_CODEC="video/x-raw,format=I420 ! jpegenc quality=90" +#VIDEO_CODEC="openjpegenc" + +gst-launch-1.0 -v \ + ximagesrc use-damage=0 show-pointer=0 $XIMAGESRC_ARGS ! video/x-raw,framerate=25/1 ! \ + videoconvert ! videorate ! $VIDEO_CODEC ! queue ! mux. \ + matroskamux name=mux ! filesink location="$FILENAME" + #pulsesrc ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. \ -- 2.1.4