How to capture screen and export as video during runtime on Unity exe

Hello Unity Talents,
Hope everyone is doing well

I made a 3D logo animation mechanism with Unity, but I need to modify it so that when I put a 3D object in it, it automatically exports a video file of that animation (not manual control)
So I think I need to capture the camera screen during runtime and export it to mp4 or webm file via script, but I still haven’t found a solution
Anyone with a similar experience, please help
Thank you!