How to increase the plot speed of a python animation in Streamlit?

I’m trying to generate an animation of relativistic orbits in streamlit, but the plot is taking about 20 seconds (which is a lot).

As the code below shows, I’m generating them with components.html. I imagine the problem may be this video format.

Is there any way (adapted to streamlit) for me to decrease the plotting time so that the result appears faster? Maybe plotting in another format, like gif, or adapting the html itself?

        graph, = plt.plot([], [], color="gold", markersize=3, label='Tempo: 0 s')
        L = plt.legend(loc=1)

        plt.close() 

        def animate(i):
            lab = 'Tempo: ' + str(round(dt*i * (rs_sun / 2.0) * 3e-5 , -int(math.floor(math.log10(abs(dt*(rs_sun / 2.0)*3e-5)))))) + ' s'
            graph.set_data(x[:i], y[:i])
            L.get_texts()[0].set_text(lab)  
            return graph,

        skipframes = int(len(x)/200)
        if skipframes == 0:
            skipframes = 1
        
        ani1 = animation.FuncAnimation(fig, animate, frames=range(0,len(x),skipframes), interval=30, blit = True, repeat = False)
        components.html(ani1.to_jshtml(),height=800)