commit 4c7c6aae680c374352fe38906d93ff4a6fdbf31c parent 83302f20e4294641c037d44381864a189419dc3b Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 4 Nov 2020 16:00:22 +0100 screenrecord: offer to encode and delay audio in output file after recording Diffstat:
M | .local/bin/screenrecord | | | 26 | +++++++++++++++++++++++--- |
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/.local/bin/screenrecord b/.local/bin/screenrecord @@ -28,7 +28,7 @@ startrecording() { -r 30 \ -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \ "$out" >/dev/null 2>&1 & - printf '%s' "$!" > "$lockfile" + printf '%s\n%s\n' "$!" "$out" > "$lockfile" sleep 1 if [ ! -f "$out" ]; then @@ -40,9 +40,9 @@ startrecording() { } stoprecording() { - kill "$(cat "$lockfile")" + out="$(tail -1 "$lockfile")" + kill "$(head -1 "$lockfile")" rm -f "$lockfile" - #notify "${0##*/}" 'recording ended' if ! pgrep spoon; then pkill stopwatch @@ -50,6 +50,26 @@ stoprecording() { fi xrandr --output "$screen" --auto + + c="$(printf 'encode\ncancel\ndelete\n' | dmenu -i -p "${out}")" + case "$c" in + encode) + ffmpeg -y \ + -i "${out}" \ + -itsoffset 0.300 -i "${out}" \ + -map 0:v -map 1:a \ + -c:v libx264 -threads 0 -preset faster -pix_fmt yuv420p \ + -c:a aac -crf 23 \ + "${out%.mkv}.mp4" + notify "${0##*}" "encoding complete: ${out%.mkv}.mp4";; + delete) + rm -f "${out}";; + cancel) + break;; + *) + notify -u CRITICAL "${0##*/}" "choice ${c} not understood" + exit 1;; + esac } if [ -f "$lockfile" ]; then