Record /play inps like in Mame

Im trying to find here , in the options or on forums if retroarch has a function to save inps for games like regular Mame has, so I can record the games ( not the video ) and pass it to friends, move it to my computer when I could replay it in 4K with all overlays (as im plannig to build a cabinet for the living room but less powerfull)… Do that thing exists in retroarch???

RetroArch has its own input recording, but if you can do it in standalone MAME, you can probably do it somehow using the up-to-date MAME core in RetroArch.

I want the own retroarch input recording. How i make it work?