I chose "game recording" in OBS and entered Minecraft as the window, but it is not recognized (background remains black)
You can't just enter the name. You must have MC ofden, then click on 'Add recording source' / Game recording / Capture specific window / Minecraft.
(I don't know the exact wording by heart. Could be slightly different.)