Created
March 27, 2010 15:02
-
-
Save ion1/346132 to your computer and use it in GitHub Desktop.
Scripts from my screencast workflow
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/sh | |
set -e | |
x=200 | |
y=100 | |
w=768 | |
h=432 | |
cd "$(dirname "$0")" | |
out="$1"; shift | |
col_info="$(tput setaf 4 2>/dev/null; tput bold 2>/dev/null)" | |
col_def="$(tput sgr0 2>/dev/null)" | |
info() { | |
local fmt="$1"; shift | |
printf "%s$fmt\n%s" "$col_info" "$@" "$col_def" | |
} | |
tempfiles= | |
trap 'rm -f -- $tempfiles' 0 1 2 13 15 | |
# Record | |
info 'Hit return to stop recording.' | |
recorded="$(mktemp ./record.avi.XXXXXXXXXX)" | |
tempfiles="$tempfiles $recorded" | |
gst-launch \ | |
istximagesrc startx="$x" starty="$y" \ | |
endx="$(($w+$x))" endy="$(($h+$y))" \ | |
use-damage=false do-timestamp=true ! \ | |
video/x-raw-rgb,framerate=15/1 ! videorate ! ffmpegcolorspace ! \ | |
ffenc_huffyuv ! queue ! progressreport name=record ! mux. \ | |
pulsesrc do-timestamp=true ! audioconvert ! audioresample ! \ | |
audio/x-raw-int,rate=44100,channels=1 ! queue ! mux. \ | |
avimux name=mux ! filesink location="$recorded" & | |
gst_pid="$!" | |
read _ | |
kill "$gst_pid" | |
wait | |
# XXX Fix the video. For some reason, this seems to be needed. | |
info 'Fixing the video.' | |
fixed="$(mktemp ./fix.avi.XXXXXXXXXX)" | |
tempfiles="$tempfiles $fixed" | |
gst-launch \ | |
filesrc location="$recorded" ! \ | |
avidemux name=demux \ | |
demux. ! queue ! 'video/x-huffyuv' ! progressreport name=fix ! mux. \ | |
demux. ! queue ! 'audio/x-raw-int' ! mux. \ | |
avimux name=mux ! filesink location="$fixed" | |
mv -f "$fixed" "$out" | |
info 'Done: %s' "$out" | |
# vi:set et sw=2 sts=2: |
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/sh | |
set -e | |
target_x=200 | |
target_y=100 | |
target_w=768 | |
target_h=432 | |
id= | |
eval "$( | |
xwininfo | \ | |
sed -nre 's/^xwininfo: Window id: (0x[0-9a-fA-F]+) .*/id=\1;/p' | |
)" | |
if [ -z "$id" ]; then >&2 printf "No id found\n"; exit 1; fi | |
fl=; fr=; ft=; fb= # Frame extents | |
rix=; riy= # Resize increment | |
bw=; bh= # Base size | |
eval "$( | |
xprop -notype -id "$id" \ | |
0c '=$0,$1,$2,$3\n' _NET_FRAME_EXTENTS \ | |
0c '=$9,$10,$15,$16\n' WM_NORMAL_HINTS | \ | |
sed -nr \ | |
-e 's/^_NET_FRAME_EXTENTS=([0-9]+),([0-9]+),([0-9]+),([0-9]+)$/fl=\1; fr=\2; ft=\3; fb=\4;/p' \ | |
-e 's/^WM_NORMAL_HINTS=([0-9]+),([0-9]+),([0-9]+),([0-9]+)$/rix=\1; riy=\2; bw=\3; bh=\4;/p' | |
)" | |
for v in "$fl" "$fr" "$ft" "$fb" "$rix" "$riy" "$bw" "$bh"; do | |
if [ -z "$v" ]; then | |
>&2 printf "No frame extents or window hints found\n"; exit 1 | |
fi | |
done | |
if [ "$rix" -eq 0 ]; then rix=1; fi | |
if [ "$riy" -eq 0 ]; then riy=1; fi | |
x="$target_x"; y="$target_y"; w="$target_w"; h="$target_h" | |
# Take the resize increment into account. | |
w="$(( ((($w-$bw)/$rix)*$rix)+$bw ))" | |
h="$(( ((($h-$bh)/$riy)*$riy)+$bh ))" | |
# Move to the center of the target area. | |
x="$(( $x + ($target_w-$w)/2 ))" | |
y="$(( $y + ($target_h-$h)/2 ))" | |
# Take the frame extents into account. | |
x="$(($x - $fl))" | |
y="$(($y - $ft))" | |
printf "0x%x: %d,%d %d×%d\n" "$id" "$x" "$y" "$w" "$h" | |
wmctrl -i -r "$id" -e "0,$x,$y,$w,$h" | |
# vi:set et sw=2 sts=2: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment