Matplolib animation not updating

Hi everyone ! :relaxed:

I am trying to develop an app that computes and displays animations of satellite images :artificial_satellite:, based upon acquisition parameters specified by the user.

I have been able to generate these animations and display them with a kind of “hacky” procedure : by using matplotlib.Animation.to_html5_video() and putting the resulting html in a st.markdown(html_video, unsafe_allow_html = True). I know I could have used streamlit.components.v1 according to this topic, but then I would have not been able to adapt the size and layout of the video generated.

Either way, I have several questions :

  1. I have the user submit a time (with a slider in a form) at which the animations should be starting. When I submit a new timestamp, the content updates correctly (the titles and static images) except for the animations, which remain the same (see screencast below). I feel like they are cached or something. Can I somehow force the app to actually recalculate everything again ?
  2. I am struggling to make the videos play all at once. I have tried to modified the HTML autoplay attribute of the generated videos and tried to add a custom javascript to the app as well, with no success.
  3. Bonus question: Is it possible to zoom dynamically on an image in streamlit ?

Link to the screencast on google drive

Thanks for your help !

Specs:

  • Streamlit 0.82
  • Python 3.9.1, using conda
  • Ubuntu 20.04
  • Firefox 88.0.1 (64 bits)

Update: By using streamlit.components.v1, the animation updates correctly but it messes up my layout like so:

So I guess a solution would be to find a way to modify the video size to make it fit inside the iframe that is created by components ?

Update:

  1. In the end, I used streamlit.components.v1 with a hard coded figsize that fits my layout. Not the best but it’s ok.
  2. It is definitely possible, I’ve succeeded to play all the videos all at once, though I am struggling to do the same when the app reloads. In fact, the script is running in a streamlit.components.v1 as well and unfortunately, it doesn’t get reloaded with the app (with a slider update or upon hitting R). I am still investigating and I’ll be sure to post down below my script when I achieve this.
  3. It doesn’t seem possible… :sob: :pleading_face: