Basic design is pretty similar to what we do with photo taking: we save raw frames to disk, then external script is used to turn that into video.
To enable audio recording, script is called both when starting and when finishing a recording. Frames are saved with timestamps. I considered just writing raw sensor data to the disk, but it turns out existing dng export is fast enough for this.
I'm not sure what to do with the helpers (movie_audio_rec.c, mpegize.py, movie.sh). There's more work to be done there, but it is hard to test the C parts without them.