-
Notifications
You must be signed in to change notification settings - Fork 1
/
capwin
executable file
·22 lines (17 loc) · 1.09 KB
/
capwin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# USES ALSA ONLY
#!/usr/bin/env bash
echo "Click a window to record it, press 'q' in this window to stop."
# xwininfo is being used to get target window position and geometry
CAPWIN=`xwininfo`
CAPWIN_GEOMETRY=`echo $CAPWIN | grep geometry`
CAPWIN_CORNERS=`echo $CAPWIN | grep Corners:`
CAPWIN_DIM=`echo $CAPWIN_GEOMETRY | sed -e 's/^.*y //' | sed -e 's/+.*$//'`
CAPWIN_XPOS=`echo $CAPWIN_CORNERS | sed -e 's/^[^+]*+//;s/+.*$//'`
CAPWIN_YPOS=`echo $CAPWIN_CORNERS | sed -e 's/^[^+]*+[^+]*+//;s/ .*$//'`
# date for file name, to auto-increment file names
DATE="$(date +%Y%m%d@%H%M%S)"
# debug position/geometry test
# echo DIM $CAPWIN_DIM XPOS $CAPWIN_XPOS YPOS $CAPWIN_YPOS
# do not set `-r 30` to avoid audio desynchronization. This comes at the cost of lagging being recorded.
ffmpeg -f alsa -i hw:0,0 -acodec pcm_s16le -f x11grab -s $CAPWIN_DIM -i :0.0+$CAPWIN_XPOS,$CAPWIN_YPOS -vcodec libx264 -crf 0 -preset ultrafast -threads 0 capwin-$DATE.mkv
#ffmpeg -f alsa -f x11grab -acodec pcm_s16le -s $CAPWIN_DIM -i :0.0+$CAPWIN_XPOS,$CAPWIN_YPOS -vcodec libx264 -crf 0 -preset ultrafast -threads 0 capwin-$DATE.mkv