vega / vl-convert

Utilities for converting Vega-Lite specs from the command line and Python
BSD 3-Clause "New" or "Revised" License
100 stars 12 forks source link

Support video / GIF export #111

Open jonmmease opened 1 year ago

jonmmease commented 1 year ago

As inspired by a question from @mattijn. Could VlConvert export videos or GIFs of charts?

Here's an idea:

Input:

VlConvert would render the spec, then sweep through the signal values, exporting each frame to an SVG, then use resvg to convert each frame to a PNG, then convert these PNG frames to GIF / MP4.

The Rust image crate supports a GIF encoder (https://docs.rs/image/latest/image/codecs/gif/struct.GifEncoder.html). And it looks like there is an mp4 crate as well: https://github.com/alfg/mp4-rust

jonmmease commented 1 year ago

Question for @jonathanzong or @joshpoll. For the Vega specs that will be produced by Vega-Lite with animation support in the future, will there be a top-level time signal that can be advanced programmatically like view.signal('time', 0.0), view.signal('time', 0.1), etc.? Will it be possible to look at a Vega spec and automatically determine the appropriate start, stop, and step time values?

I want to make sure than any approach we come up with for exporting Vega charts to videos works well with the future Vega-Lite architecture.