dotfiles/bin/screenrecord

28 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-10-21 06:15:28 -04:00
#!/bin/sh
PID_FILE="/tmp/screencast.pid"
SCREENCAST_FILE="$HOME/Video/$(date +'%Y-%m-%d_%H:%M').mp4"
if [ -e $PID_FILE ]; then
notify-send "Screen record was ended"
kill -s INT "$(cat $PID_FILE)"
dragon-drop "$(cat /tmp/screencast.filename)"
rm -- "${PID_FILE}"
else
geometry=$(slop -c 0.7411764705882353,0.5764705882352941,0.9764705882352941,0.1 \
-b 1.5 --color=255,0,255 -o -D -f "-video_size %wx%h -i :0.0+%x,%y")
#shellcheck disable=SC2181
if [ $? -eq 0 ] ;then
#shellcheck disable=SC2086
ffmpeg -y -thread_queue_size 65536 \
-f x11grab $geometry -i ~/.dummy.aac -c:a copy \
-c:v libx264 -vf "scale=force_original_aspect_ratio=decrease:force_divisible_by=2" -preset slow -crf 18 -pix_fmt yuv420p \
-fflags +bitexact -flags:v +bitexact -flags:a +bitexact \
"${SCREENCAST_FILE}" >/dev/null 2>/dev/null &
echo $! > $PID_FILE
echo "${SCREENCAST_FILE}" > /tmp/screencast.filename
notify-send "Screen recording started" -i "$HOME/.config/dunst/icons/record.png"
else
notify-send "Screen record was canceled" -i "$HOME/.config/dunst/icons/cancel.png"
fi
fi