diff options
author | nikolaus <nikolaus@fishbox.fritz.box> | 2022-09-07 13:53:07 +0200 |
---|---|---|
committer | nikolaus <nikolaus@fishbox.fritz.box> | 2022-09-07 13:53:07 +0200 |
commit | afe087c85da7bd8456cb7df9f60759242ec41c44 (patch) | |
tree | 5b83aa332a149dbaf6a2315df08956afbf841d81 /dmenurecord |
Initial commit & first scripts.
Diffstat (limited to 'dmenurecord')
-rwxr-xr-x | dmenurecord | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/dmenurecord b/dmenurecord new file mode 100755 index 0000000..8702a3e --- /dev/null +++ b/dmenurecord @@ -0,0 +1,79 @@ +#!/bin/sh + +# Usage: +# `$0`: Ask for recording type via dmenu +# `$0 screencast`: Record both audio and screen +# `$0 video`: Record only screen +# `$0 audio`: Record only audio +# `$0 kill`: Kill existing recording +# +# If there is already a running instance, user will be prompted to end it. + + +killrecording() { + recpid="$(cat /tmp/recordingpid)" + # kill with SIGTERM, allowing finishing touches. + kill -15 "$recpid" + rm -f /tmp/recordingpid + pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + sleep 3 + kill -9 "$recpid" + exit + } + +screencast() { \ + +ffmpeg -y \ + -f x11grab -probesize 32M -thread_queue_size 32 -i :0 \ + -f sndio -thread_queue_size 128 -i snd/1 \ + -codec:v libx264rgb -crf 0 -preset ultrafast \ + -codec:a pcm_s16le \ + "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" & +# ffmpeg -y \ +# -f x11grab \ +# -framerate 60 \ +# -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ +# -i "$DISPLAY" \ +# -f sndio -i snd/1 \ +# -r 30 \ +# -c:v h264 -crf 0 -preset ultrafast -c:a aac \ +# "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" & + echo $! > /tmp/recordingpid + } + + +audio() { \ + ffmpeg \ + -f sndio -i snd/1 \ + -c:a flac \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! > /tmp/recordingpid + } + +askrecording() { \ + #choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:") + choice=$(printf "screencast\\naudio" | dmenu -i -p "Select recording style:") + case "$choice" in + screencast) screencast;; + audio) audio;; + video) video;; + # *selected) videoselected;; + # webcam) webcam;; + # "webcam (hi-def)") webcamhidef;; + esac + } + +asktoend() { \ + response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") && + [ "$response" = "Yes" ] && killrecording + } + + +case "$1" in + screencast) screencast;; + audio) audio;; + video) video;; + kill) killrecording;; + *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; +esac |