I have researched/experimented with the video recording bug and I am pretty sure
this is the problem.
That is exactly what happens on CM13 based ROMs on Mi Max. I have replicated it by rebooting with usb connected and recording works... dies after usb disconnect and device wakes from deep sleep. I even did dirty remux of brocken recording on my PC and it proved all video frames were there but with incorrect duration.
So looks like we have to wait and hope Xiaomi to fix the device firmware/kernel? part that causes the deep sleep problem on CM(very unlikely) or release source code.
As you probably know the list of all vendor files pulled from miui to build CM is based on the official CM device tree for Note 3 Pro(kenzo) which has very similar hardware... They even pull many of those files for kenzo from Mi Max miui base(
android_device_xiaomi_kenzo/proprietary-files.txt). I compared the camera firmwares for both and it is exactly the same bit-by-bit. And yet kenzo CM13 don't have that problem. So it must be some other firmware part or kernel issue.
Also wondering why as far as I know miui doesn't have that problem using same firmware/kernel!? Must be something in the camera app or framework or something...
If I have time I will try to build xposed module to intercept the video and fix the first frame duration as dirty/temporary fix(as explained in the link).
EDIT: Ok... As prove of concept build xposed module for testing. It fixes recorded videos but needs some tuning... The first few audio samples are cut off in the repair process and audio gets out of sync. Have to figure out how to fix that...
Just install the attached apk, enable the module in xposed installer and reboot. That's it. Just record as usual. Works with CM and RR(not tested) build-in Camera apps only(for now...).