Apologies I assumed you were using the latest version of OpenCV, support for FFmpeg 5 was not added until
try upgrading to the latest (4.8.0).