commit 893180d1343494a80b453aa862045ab405b18b9b parent ebca4a8da3fdd4d1e5553dae5e3f6fe124a6c473 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Thu, 12 Mar 2020 17:48:15 +0100 Add script to record screen and mic Diffstat:
A | .local/bin/screenrecord | | | 36 | ++++++++++++++++++++++++++++++++++++ |
1 file changed, 36 insertions(+), 0 deletions(-)
diff --git a/.local/bin/screenrecord b/.local/bin/screenrecord @@ -0,0 +1,36 @@ +#!/bin/sh +lockfile=/tmp/screenrecord.pid + +startrecording() { + out="$HOME/tmp/screencast-$(date '+%Y-%m-%d_%H:%M:%S').mkv" + ffmpeg -y \ + -f x11grab \ + -framerate 60 \ + -s "$(xdpyinfo | grep dimensions | awk '{print $2}')" \ + -i $DISPLAY \ + -f sndio -i default \ + -r 30 \ + -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \ + "$out" >/dev/null 2>&1 & + printf '%s' "$!" > "$lockfile" + + sleep 2 + if [ ! -f "$out" ]; then + echo 'error: ffmpeg recording did not start' >&2 + notify-send -u CRITICAL "${0##*/}" 'ffmpeg recording did not start' + rm -f "$lockfile" + exit 1 + fi +} + +stoprecording() { + kill "$(cat "$lockfile")" + rm -f "$lockfile" + notify-send "${0##*/}" 'recording ended' +} + +if [ -f "$lockfile" ]; then + stoprecording +else + startrecording +fi