-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreencast
More file actions
70 lines (59 loc) · 1.92 KB
/
screencast
File metadata and controls
70 lines (59 loc) · 1.92 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
## Copyright (C) 2020-2022 Aditya Shakya <adi1090x@gmail.com>
## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3
## Record Screen with slop and ffmpeg
time=`date +%Y-%m-%d-%H-%M-%S`
screen=`xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'`
dir="`xdg-user-dir VIDEOS`/Screenrecorder"
file="Capture_${time}.mp4"
# notify
notify_user () {
if [[ -e "$dir/$file" ]]; then
dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/video.png "Saved in $dir"
else
dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/video.png "Video Deleted."
fi
}
# countdown
countdown () {
for sec in `seq $1 -1 1`; do
dunstify -t 1000 --replace=699 -i /usr/share/archcraft/icons/dunst/timer.png "Starting in : $sec"
sleep 1
done
}
# capture
rec_screen() {
countdown '3'
if [[ "$1" == "noaudio" ]]; then
ffmpeg -video_size ${screen} -framerate 25 -f x11grab -i :0.0+0,0 ${dir}/${file}
else
ffmpeg -video_size ${screen} -framerate 25 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i default ${dir}/${file}
fi
notify_user
}
rec_area() {
get_win_data=$(slop -f "%x %y %w %h %g %i") || exit 1
read -r X Y W H G ID < <(echo $get_win_data)
countdown '3'
if [[ "$1" == "noaudio" ]]; then
ffmpeg -video_size ${W}x${H} -framerate 25 -f x11grab -i :0.0+${X},${Y} ${dir}/${file}
else
ffmpeg -video_size ${W}x${H} -framerate 25 -f x11grab -i :0.0+${X},${Y} -f pulse -ac 2 -i default ${dir}/${file}
fi
notify_user
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
if [[ "$1" == "--screen" ]]; then
rec_screen
elif [[ "$1" == "--area" ]]; then
rec_area
elif [[ "$1" == "--screen-na" ]]; then
rec_screen noaudio
elif [[ "$1" == "--area-na" ]]; then
rec_area noaudio
else
echo -e "Available Options : --screen --screen-na --area --area-na"
fi
exit 0