2022-10-21 06:15:28 -04:00
|
|
|
#!/bin/sh
|
|
|
|
PID_FILE="/tmp/screencast.pid"
|
2022-12-04 15:08:04 -05:00
|
|
|
SCREENCAST_FILE="$HOME/Videos/$(date +'%Y-%m-%d_%H:%M').mp4"
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -e ~/.dummy.aac ]; then
|
|
|
|
ffmpeg -f lavfi -i anullsrc=r=11025:cl=mono -t 1 -acodec aac ~/.dummy.aac
|
|
|
|
echo "[+] dummy.aac generated"
|
|
|
|
fi
|
2022-10-21 06:15:28 -04:00
|
|
|
|
|
|
|
if [ -e $PID_FILE ]; then
|
|
|
|
kill -s INT "$(cat $PID_FILE)"
|
2022-12-04 15:08:04 -05:00
|
|
|
notify-send "Screen record was ended" -t 2000
|
2022-12-17 16:40:36 -05:00
|
|
|
# https://github.com/mwh/dragon
|
2022-12-04 15:08:04 -05:00
|
|
|
dragon "$(cat /tmp/screencast.filename)"
|
2022-10-21 06:15:28 -04:00
|
|
|
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")
|
2022-12-04 15:08:04 -05:00
|
|
|
|
2022-10-21 06:15:28 -04:00
|
|
|
if [ $? -eq 0 ] ;then
|
2022-12-04 15:08:04 -05:00
|
|
|
notify-send "Screen recording started" -i "$HOME/.config/dunst/icons/record.png" -t 1000
|
2022-10-21 06:15:28 -04:00
|
|
|
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
|
|
|
|
else
|
2022-12-04 15:08:04 -05:00
|
|
|
notify-send "Screen record was canceled" -i "$HOME/.config/dunst/icons/cancel.png" -t 2000
|
2022-10-21 06:15:28 -04:00
|
|
|
fi
|
|
|
|
fi
|