deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

pydeck: Export to image, animated gif, or mp4 file

Open owenlamont opened this issue 5 years ago • 11 comments

Target Use case

Being able to export images or animated gif/movies would be extremely useful when incorporating pydeck visuals into static reports or presentations and much more convenient than screen or video capturing them using a separate app.

Proposed feature

Ideally I imagine Deck would implement some additional "to_*" methods for to_img or to_mov and in the case of to_mov to take a parameter for the desired format. I was hoping these features could be implemented with a similar API to the equivalent features in ipyvolumes API.

To Do List

  • [ ] Add label and assign to milestone
  • [ ] Coding
  • [ ] Doc update
  • [ ] What’s new update
  • [ ] Test

owenlamont avatar Jul 26 '20 14:07 owenlamont

There's a recent JavaScript library that allows you to do this for deck.gl from JS: https://hubble.gl/. (thanks @chrisgervang!) I've played with it a bit but I don't see an easy way to integrate it into Pydeck.

kylebarron avatar Jul 27 '20 16:07 kylebarron

@kylebarron yes, agreed on Hubble at least for video—seems like the right choice for this use case. Not sure it’d be too hard to integrate with pydeck but we shall see.

Static images of the canvas are easier—we’ve addressed this before in #4436.

ajduberstein avatar Jul 27 '20 17:07 ajduberstein

Thanks for looking into this - I'd be happy with just static images if that meant I could iterate some updates and save images for ffmpeg to animate. If static images could be saved or returned as numpy arrays / PIL images to be integrated with other visualisation packages that would be really useful too.

owenlamont avatar Jul 28 '20 13:07 owenlamont

Happy to help with hubble integration for pydeck. Right off the bat you may find the PNG and JPEG sequence encoders we have helpful. With them you can capture a canvas, and download all of the captures in an archive.

Hubble uses these in its VideoCapture class, which is for animating “keyframe” definitions.

Can I get some pointers to how the deck instance is used in pydeck? Is it a “standalone” style of using deck?

chrisgervang avatar Jul 28 '20 18:07 chrisgervang

@chrisgervang would love the help! Yes, pydeck uses the standalone style of deck.

ajduberstein avatar Jul 28 '20 20:07 ajduberstein

@owenlamont Did you end up finding any stop-gap solutions in the meantime?

6A61736F6E206E61646572 avatar Jun 29 '21 01:06 6A61736F6E206E61646572

Afraid not... I haven't invested anytime to look for an alternative though. That use case of being able to export images or videos for presentations would still be useful to me but if there isn't much demand I'll understand if we close this.

owenlamont avatar Jun 29 '21 01:06 owenlamont

I've recently made good progress on a standalone version of hubble.gl. Removed the last react reference last week, so I'm targeting the next version (1.4) to have standalone deck.gl support, which could then work with pydeck.

The DeckAnimation in hubble supports viewState and layer keyframe animation. I think an animation constructor could be wired into pydeck, though more work to be done.

chrisgervang avatar Jun 29 '21 02:06 chrisgervang

@chrisgervang Regarding deck.gl support, is there a tracker one could follow or is it more of an ad-hoc process?

6A61736F6E206E61646572 avatar Sep 28 '21 01:09 6A61736F6E206E61646572

We don't have a tracker for standalone support or for pydeck integration at the moment. Do people typically use a basemap with pydeck, like mapbox? That adds a layer of complexity to the implementation and maintenance of a export feature.

I'm also curious, would people want to define keyframe animations for pydeck animations? Or is there some other animation definition of interest?

chrisgervang avatar Sep 28 '21 05:09 chrisgervang

@chrisgervang I am new to this kind of stuff but I did end up using mapbox since I could tweak the visuals for presenting to others. If it came between having to record the screen or having native video export, I would probably skip the basemap and accept what I can get.

If by keyframe animations you mean something like this: https://stackoverflow.com/questions/65865145/animating-tripslayer-in-deck-gl-with-python, then in my case, yes.

6A61736F6E206E61646572 avatar Oct 01 '21 07:10 6A61736F6E206E61646572

If this feature is ever looked examined again maybe Plotly's Kaleido package is worth a look - they created that for the exact same purpose of being able to programmatically export screenshots from browser visuals from Python. They claim it was designed to allow other browser visualisation libraries to integrate with it too.

owenlamont avatar Jun 06 '23 11:06 owenlamont