code: def anim_to_html(anim):
      
      if not hasattr(anim, '_encoded_video'):
          with NamedTemporaryFile(suffix='.mp4') as f:
              anim.save(f.name, fps=20, extra_args=['-vcodec', 'libx264'])
              video = open(f.name, "rb").read()
          anim._encoded_video = video.encode("base64")
  
      return VIDEO_TAG.format(anim._encoded_video)
docs: adapted from: http://jakevdp.github.io/blog/2013/05/12/embedding-matplotlib-animations/
  
      This function converts and animation object from matplotlib into HTML which can then
      be embedded in an IPython notebook.
  
      This requires ffmpeg to be installed in order to build the intermediate mp4 file
  
      To get these to display automatically, you need to set animation.Animation._repr_html_ = plotlib.anim_to_html
      (this is done on your behalf by PHOEBE)