StreamJoy - 🌈 Enjoy animating images into GIFs and MP4s in parallel!

I’ve been working on a package that turns images into animations, using sensible defaults for fun, hassle-free creation. Built atop dask, imageio, and param.

Docs here: streamjoy (ahuang11.github.io)

It cuts down the boilerplate and time to work on animations; for example you can create GOES animations in just a few lines of code.

from streamjoy import stream

if __name__ == "__main__":
    URL_FMT = "https://www.goes.noaa.gov/dimg/jma/fd/vis/{i}.gif"
    resources = [URL_FMT.format(i=i) for i in range(1, 11)]
    stream(resources, uri="goes.gif")  # .gif and .mp4 supported

313555955-190ab753-00cf-4a0d-b8be-8a0b9b9e4443

It does this blazingly fast because it saturates all the processors on your machine (or whatever you set on the Dask client).

1711255885187

Also, note that it simply reads from the URLs so you don’t have to manually download the files!

Another highlight is that you can add an intro to provide context:

from streamjoy import stream

if __name__ == "__main__":
    URL_FMT = "https://www.goes.noaa.gov/dimg/jma/fd/vis/{i}.gif"
    resources = [URL_FMT.format(i=i) for i in range(1, 11)]
    himawari_stream = stream(
        resources,
        uri="goes_custom.gif",
        intro_title="Himawari Visible",
        intro_subtitle="10 Hours Loop",
        intro_pause=1,
        ending_pause=1,
        optimize=True,
    )

313556145-f69eb289-8074-4b49-9d9e-26f2c47c1a51

But what makes it stand out from other animation libraries is that you have full control of each frame in the animation, including what it renders in parallel and when it pauses!

from streamjoy import stream

def plot_frame(time)
    important_time = ...
    if time == important_time:
        return Paused(fig, seconds=3)
    else:
        return fig

stream(..., renderer=plot_frame)

It supports images, URLs, directories, pandas, xarray, and holoviews objects straight out of the box! Supported formats - streamjoy (ahuang11.github.io)

It’s still in its early stages, so any testing and feedback is appreciated!

Many earth sciences related recipes here:

The repo: ahuang11/streamjoy: :rainbow::blush: Enjoy animating images into GIFs and MP4s in parallel! (github.com)


The internals are based on the ideas presented in Using Dask to parallelize plotting - Pangeo. There’s also a short description of the package design in the docs Package design - streamjoy (ahuang11.github.io)

14 Likes

Thank you for sharing this work @ahuang11

When it comes to turning science into positive impact for our world and communities reaching audiences is vital.

Looking forward to giving this a go.

3 Likes

Very nice! Thanks @ahuang11

1 Like

Very cool @ahuang11! I’ve use ffmpeg to stitch together a bunch of plots and this looks much easier to use and nicer to share.

Any chance you’d want to present at Dask Demo Day? The next one is April 18th, and this would be a fun demo.

1 Like

Yes! I’ve used that, and HoloViews to do so, but found myself having to look up ffmpeg flags every time while HoloViews was too slow for long animations.

That sounds awesome! How long should the demo be, and to confirm it’s from 8-9 AM PST?

1 Like

but found myself having to look up ffmpeg flags every time

you and me both!

That sounds awesome! How long should the demo be, and to confirm it’s from 8-9 AM PST?

:tada: Great, thank you! I’ll ping you on the issue. Demos are 5-10 minutes, and yes it’s from 8-9am Pacific time. Here’s one of the recent ones if you want to get a sense of what it’s like: https://youtu.be/07e1JL83ur8

1 Like