I'm also working on solving a similar problem - how to export web animations to mp4 videos.
I'm building an API that takes any URL, and using Headless Chrome; I record a screen and export the video to mp4. I would appreciate any feedback if you would find something like this useful.