2021-12-09 21:51:57 +01:00
|
|
|
#!/bin/sh
|
2020-07-22 14:43:23 +02:00
|
|
|
|
2021-12-09 21:51:57 +01:00
|
|
|
record() {
|
2023-03-07 18:20:06 +01:00
|
|
|
if test "$1" = "-s"; then
|
|
|
|
geometry=$(hacksaw -f 'crop=%w:%h:%x:%y,scale_vaapi=%w:%h')
|
|
|
|
else
|
|
|
|
geometry='scale_vaapi=1920:1080'
|
|
|
|
fi
|
|
|
|
|
2020-07-22 14:43:23 +02:00
|
|
|
sleep 2
|
2021-07-27 17:49:48 +02:00
|
|
|
withcap sys_admin -- ffmpeg -f alsa -i recorder \
|
|
|
|
-vaapi_device /dev/dri/renderD128 -f kmsgrab -i - -r 60 \
|
2023-03-07 18:20:06 +01:00
|
|
|
-vf "hwmap=derive_device=vaapi,$geometry:format=nv12" \
|
|
|
|
-c:v hevc_vaapi -qp 21 -rc_mode 1 \
|
2020-07-22 14:43:23 +02:00
|
|
|
-c:a libopus -b:a 96k -ac 2 -ar 48000 \
|
2021-12-09 21:51:57 +01:00
|
|
|
-y recording.mkv >/dev/null 2>&1
|
|
|
|
}
|
2020-07-22 14:43:23 +02:00
|
|
|
|
2021-12-09 21:51:57 +01:00
|
|
|
if test ! -f recording.mkv; then
|
2022-06-29 12:10:09 +02:00
|
|
|
echo recording in 2s...
|
2023-03-07 18:20:06 +01:00
|
|
|
record "$@" &
|
2020-07-22 14:43:23 +02:00
|
|
|
else
|
|
|
|
pkill ffmpeg
|
2022-06-29 12:10:09 +02:00
|
|
|
echo stopped recording
|
2021-12-09 21:51:57 +01:00
|
|
|
fi
|