Screenrec: Use h264 for partial rec and av1 for fullscreen.

This commit is contained in:
Dmitry Voronin 2024-12-22 06:50:15 +03:00
parent f98d53834d
commit 968899c410
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -24,6 +24,7 @@ let
container = "mp4";
format = "%Y-%m-%d_%H-%M-%S";
framerate = 30;
keyint = framerate * 5;
opacity = "26";
pixfmt = "yuv420p10le";
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
@ -80,13 +81,35 @@ let
[[ "''${scrTransform}" = "normal" ]] && scrTransform=""
'';
vidStart = ''
vidStart = extra: ''
wf-recorder \
--codec h264_vaapi \
--device /dev/dri/renderD128 \
--no-damage \
--codec ${codec} \
--file "''${scrFile}" \
--framerate ${toString framerate} \
--pixel-format ${pixfmt} \
--file "''${scrFile}" \
${extra} ||
wf-recorder \
--codec libx264 \
--no-damage \
--framerate ${toString framerate} \
--file "''${scrFile}" \
${extra}
'';
# NOTE: Only fullscreen rec is re-encoded.
vidEncode = ''
ffmpeg \
-i "''${scrFile}" \
-c:v ${codec} \
-svtav1-params "tune=0" \
-pix_fmt ${pixfmt} \
-g ${toString keyint} \
-f ${container} \
-vf "fps=${toString framerate}" \
"''${scrFile}_" \
&& mv "''${scrFile}_" "''${scrFile}" \
|| rm "''${scrFile}_"
'';
vidMuxAudio = ''
@ -123,7 +146,7 @@ let
${vidPrepFile}
${notifyStart}
${updateWaybar}
${vidStart} ${vidSelected}
${vidStart vidSelected}
${notifyEnd}
${updateWaybar}
${vidMuxAudio}
@ -138,9 +161,10 @@ let
${vidPrepFile}
${notifyStart}
${updateWaybar}
${vidStart} ${vidFull}
${vidStart vidFull}
${notifyEnd}
${updateWaybar}
${vidEncode}
${vidMuxAudio}
${vidTransform}
${vidRefLatestFile}