How to make a screen recorder system?

Hi, I was having a problem. I want a system inside my game that can record gameplay without using any other screen recorder software. I want to make the system that a player can do that and have a mp4 file recorded to show others.
I can’t find any ways to do that no tutorials.
Can anyone please help me with it?