#!/bin/sh
set -e

# configuration
_vidfile="/home/sdk/rec-screen.mkv"
_outfile="/home/sdk/rec-encoded-$(date "+%Y-%m-%d_%H%M%S").mp4"

_res="2880x1800"
_fps="60"

printf 'Press q to stop.\n'
set -x

ffmpeg  -y -loglevel error -hide_banner \
        -vaapi_device /dev/dri/renderD128 \
        -framerate ${_fps} \
        -f x11grab \
        -video_size ${_res} \
        -i :0 \
        -vf 'hwupload,scale_vaapi=format=nv12' \
        -c:v h264_vaapi \
        -qp 24 \
        -framerate ${_fps} \
        "${_outfile}"
