So, sway is an awesome window manager, but to stream/screenrecord correctly without black flashes... you need to disable something called direct scanout.
To do this, you must pass an environment variable in the config file used by login managers to start sway.
It is located at /usr/share/wayland-sessions/sway.desktop
Here is what works :
[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=env WLR_RENDERER=vulkan WLR_SCENE_DISABLE_DIRECT_SCANOUT=1 sway
Type=Application
As you can see, I also force the renderer for the desktop to be vulkan instead of OpenGL, but that shouldn't be needed to fix the issue when screen recording.