How can I force portrait mode in files recorded with WebRTC on mobile browsers?

During the step of saving the stream to a file WebRTC switches from 9:16 portrait resolution to 16:9 landscape resolution on mobile browsers The issue does not affect the locally stored files to replay in a users browser but once the file gets saved to the server instead of portrait mode it gets saved in landscape mode. This only happens on mobile devices. Is there maybe mobile related syntax that might fix this?

I tried to force portrait mode but it did not affect the resolution when recording on mobile browsers and storing the files on the server. The problem persists regardless if I use record.js or WebRTC.