Video record in Unity (Android/IOS)

I need to video record from the webcam device but I can’t find any concrete code. The project must run at least on android but ideally I’d like to test it on windows (editor) and ios devices as well.
If it helps I already have a method that successfully passes webcam frames into a texture to show them in the scene but I don’t know how to convert this to an mp4 video.

Thanks for any help.

the easy way without headache is just use NatCorder asset. and also UnityNativeCamera.for free.