If you have Megapixels working, you can try to open it, make a touch click in the preview to set focus, and close it, then run the recording script.
Thanks, that's what I wanted to try next and it worked. However I needed to start Megapixels after starting ffmpeg. Then Megapixels will auto-close its GUI but autofocus will work!
Ah thanks, that trick in that form is news even to me.