-
Notifications
You must be signed in to change notification settings - Fork 1
/
capwin-pulse
executable file
·24 lines (19 loc) · 1.03 KB
/
capwin-pulse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# USES PULSE ONLY, you might need to check and set the recording device in pavucontrol
# see https://qubodup.wordpress.com/2012/01/03/this-is-how-i-record-my-screen-on-linux/
#!/usr/bin/env bash
echo "Click a window to record it"
# 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
if [[ $1 != "" ]]; then
NAME="$1"
else
NAME="$(date +%Y%m%d@%H%M%S)"
fi
# do not set `-r 30` to avoid audio desynchronization. This comes at the cost of lagging being recorded.
ffmpeg -f alsa -sample_rate 44100 -i pulse -f x11grab -acodec pcm_s16le -s $CAPWIN_DIM -i :0.0+$CAPWIN_XPOS,$CAPWIN_YPOS -vcodec libx264 -crf 0 -preset ultrafast -threads 0 capwin-$NAME.mkv