What is the best screen recorder?
OBS Studio + some mechanism to connect it to your compositor.
For wlroots-based compositors like sway here's the most lightweight solution: https://hg.sr.ht/~scoopta/wlrobs
For mutter (GNOME): https://github.com/flatpak/xdg-desktop-portal + pipewire