refactor(hypr): make screen cap use hardware accel from gpu, record in mp4

This commit is contained in:
Price Hiller 2023-02-26 19:56:16 -06:00
parent 7a10989303
commit a91a79cb50
No known key found for this signature in database

View File

@ -2,7 +2,6 @@
# Dependencies: # Dependencies:
# - wf-recorder: https://github.com/ammen99/wf-recorder # - wf-recorder: https://github.com/ammen99/wf-recorder
# - ffmpeg: https://ffmpeg.org/download.html
# - notification daemon: https://archlinux.org/packages/?name=notification-daemon # - notification daemon: https://archlinux.org/packages/?name=notification-daemon
# - wl-clipboard: https://github.com/bugaevc/wl-clipboard # - wl-clipboard: https://github.com/bugaevc/wl-clipboard
# #
@ -29,12 +28,10 @@ mk-gif() {
tmp_dir="$(mktemp -d)" tmp_dir="$(mktemp -d)"
cd "${tmp_dir}" cd "${tmp_dir}"
input_tmpfile="${tmp_dir}/$(mktemp wf-recorder.XXXXXXXXXXX)" input_tmpfile="${tmp_dir}/$(mktemp wf-recorder.XXXXXXXXXXX)"
wf-recorder -g "$(slurp)" -f "${input_tmpfile}.mp4" --framerate 10 -- & wf-recorder -g "$(slurp)" -f "${input_tmpfile}.mp4" -c h264_vaapi -d /dev/dri/renderD128 --framerate 24 -- &
printf "%s" $! >"${pid_file}" printf "%s" $! >"${pid_file}"
wait wait
ffmpeg -i "${input_tmpfile}.mp4" -filter_complex "[0:v] palettegen" palette.png wl-copy --type video/mp4 <"${input_tmpfile}.mp4"
ffmpeg -i "${input_tmpfile}.mp4" -i palette.png -filter_complex "[0:v][1:v] paletteuse" "${input_tmpfile}.gif"
wl-copy --type image/gif <"${input_tmpfile}.gif"
rm -f "${pid_file}" rm -f "${pid_file}"
) )
fi fi