-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreencast.sh
executable file
·41 lines (34 loc) · 955 Bytes
/
screencast.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# start|stop screencast
set -o errexit
set -o pipefail
PIDFILE="${HOME}/.screencast.pid"
OUTFILE="/tmp/out.avi"
FINALFILE="${HOME}/Videos/screencast--$(date +'%Y-%m-%d--%H-%M-%S').avi"
# check if this script is already running
if [ -s $PIDFILE ] && [ -d "/proc/$(cat $PIDFILE)" ]; then
echo "Proses exists..."
# send SIG_TERM to screen recorder
kill $(cat $PIDFILE)
# clear the pidfile
rm $PIDFILE
# move the screencast into the user's video directory
mv $OUTFILE $FINALFILE
else
echo "Try to run ..."
# screen resolution
SCREENRES=$(xrandr -q --current | grep '*' | awk '{print$1}')
# write to the pidfile
echo $$ > $PIDFILE &&
# let the recording process take over this pid
exec ffmpeg \
-f pulse \
-i default \
-ac 2 \
-acodec vorbis \
-f x11grab \
-r 25 \
-s ${SCREENRES} \
-i :0.0 \
-vcodec libx264 ${OUTFILE}
fi