Thanks to the initial work submitted by igorinov via a pull request (https://github.com/Genymobile/scrcpy/pull/292), scrcpy now provides an option to record the device screen to a video file:
scrcpy --record file.mp4
The device is mirrored on the computer and can be controlled via keyboard and mouse, as usual.
If the device is rotated during recording, the recorded video is also rotated (its dimensions change). It seems to work correctly in video players (vlc, mpv and even firefox).
If the device is rotated during recording, the recorded video is also rotated (its dimensions change). It seems to work correctly in video players (vlc, mpv and even firefox).