I know it's been a while since you asked, but have a look at https://github.com/PetrVys/MotionPhoto2. You'll need to port it from python, but the files created are working in most viewers, and HEIC files are supported too - and Google Photos is the primary target.