scripts/rec: allow selecting a screen region

This commit is contained in:
Michele Guerini Rocco 2023-03-07 18:20:06 +01:00
parent 8916cd5ad6
commit c7b68ee90d
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -1,18 +1,24 @@
#!/bin/sh #!/bin/sh
record() { record() {
if test "$1" = "-s"; then
geometry=$(hacksaw -f 'crop=%w:%h:%x:%y,scale_vaapi=%w:%h')
else
geometry='scale_vaapi=1920:1080'
fi
sleep 2 sleep 2
withcap sys_admin -- ffmpeg -f alsa -i recorder \ withcap sys_admin -- ffmpeg -f alsa -i recorder \
-vaapi_device /dev/dri/renderD128 -f kmsgrab -i - -r 60 \ -vaapi_device /dev/dri/renderD128 -f kmsgrab -i - -r 60 \
-vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' \ -vf "hwmap=derive_device=vaapi,$geometry:format=nv12" \
-c:v hevc_vaapi -qp 21 \ -c:v hevc_vaapi -qp 21 -rc_mode 1 \
-c:a libopus -b:a 96k -ac 2 -ar 48000 \ -c:a libopus -b:a 96k -ac 2 -ar 48000 \
-y recording.mkv >/dev/null 2>&1 -y recording.mkv >/dev/null 2>&1
} }
if test ! -f recording.mkv; then if test ! -f recording.mkv; then
echo recording in 2s... echo recording in 2s...
record & record "$@" &
else else
pkill ffmpeg pkill ffmpeg
echo stopped recording echo stopped recording