Comfortable Screen Recording
All-in-one screen recording solutions always lacked some configuration option:
- OBS: Awkward selection of area to record, output size has to be changed every time
- ffmpeg: Area to record has to be passed as a string
- Others: Ancient output formats, missing quality configurations
I just replaced simple screen recording tasks with a combination of these tools:
- slop: Interactive selection of the area to record
- ffmpeg: Recording the selected area in any imaginable format
- yad: Extremely simple tray icon
The Result
scrrec
command executable from anywhere after placing the script in a PATH directory (e.g.~/.local/bin
)- A tray icon that stops the recording when clicking on it
The Script
#!/bin/bash
set -euo pipefail
# Description: Prompt for area selection, record screen, provide tray icon
# Dependencies: slop, yad, ffmpeg
# OPTIONS
OUT_FILENAME="$HOME/Videos/scrrec_$(date --iso-8601=seconds).mp4"
# SCRIPT
# prompt for area selection
# -b 5
# 5px border for selection
# -c 1,0.5,0.5,0.8
# translucent red for selection
# -l
# fill the background on selection
# -k
# disable keyboard events cancelling the selection, this
# allows switching to other windows. the selection can be
# cancelled with RMB
# -f
# define the output format
SELECTED_AREA=$(slop -b 5 -c 1,0.5,0.5,0.8 -l -k -f "%x %y %w %h %g %i")
# store selection into variables
read -r X Y W H G ID < <(echo $SELECTED_AREA)
# record the selected are using ffmpeg
ffmpeg -f x11grab -s "$W"x"$H" -framerate 30 -i :1.0+$X,$Y -c:v libx264 -crf 0 -preset ultrafast "$OUT_FILENAME" &
FFMPEG_PID=$!
# wait for click event on the tray icon
yad --notification --command="quit" --image="media-record"
# end the recording
kill $FFMPEG_PID
yad
allows for using arbitrary tray icons.
To list all available icons on your system use find /usr/share/icons/ | less
or gtk3-icon-browser
.