So, I've had a first (and second) look at this.
What I learned up until now;
* wp_enqueue_media adds a huge amount of JS (and inline script of type "text/html"!) to a page.
* I have not yet been able to autoptimize a page with it, although I'm pretty sure I'll crack that later.
* but even when succeeding in doing so, there'll be a huge amount of JS you'll have to exclude, which will most probably make the page perform poorly anyhow.
So my advice; don't do wp_enqueue_media on each page, but do it on one page (or a limited number of pages) instead and exclude that/ those page(s) from being autoptimized (using the API).
I'll look into this some more and will report back here if I have more findings to share :-)
frank