deck.gl
deck.gl copied to clipboard
pydeck: Export to image, animated gif, or mp4 file
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
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 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.
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.
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 would love the help! Yes, pydeck uses the standalone style of deck.
@owenlamont Did you end up finding any stop-gap solutions in the meantime?
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.
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 Regarding deck.gl support, is there a tracker one could follow or is it more of an ad-hoc process?
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 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.
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.