vim, gitconfig, update.sh
[dotfiles_afify.git] / .scripts / record_screen
blobfda90628dcfb11b1bb96215159ebbdedbfc5aec2
1 #!/bin/sh
3 save_at="/mnt/data/recorded_screen"
4 time_date=$(date +'%Y_%m_%d_%H_%M_%S')
5 fullscreen=0
6 frate="25"
7 hide_mouse="-draw_mouse 0"
8 encoding="libx264 -preset ultrafast"
9 # encoding="ffvhuff"
10 ms=$(xrandr | grep -w connected | awk -F'[ \+]' '{print $4}')
11 mh=$(echo "$ms" | awk -Fx '{print $1}')
12 mw=$(echo "$ms" | awk -Fx '{print $2}')
13 hms="$(( $mh / 2))x$mw"
14 is_running=$(pgrep -f "ffmpeg -f" | wc -l)
16 [ -d "$save_at" ] || mkdir "$save_at"
17 [ $fullscreen -eq 1 ] && monitor_size=$ms || monitor_size=$hms
19 if [ "$is_running" -eq 0 ]; then
20 ffmpeg -f x11grab -video_size $monitor_size -framerate $frate \
21 $hide_mouse -i $DISPLAY -c:v $encoding $save_at/$time_date.mkv
22 else
23 pkill ffmpeg