How can I load the video without affecting the overall process?

Hi guys,!Recently when I used the particle system, I clicked to generate a video and the whole was stuck. After the video was loaded, the fps would be restored. Is there any good way to solve this problem?

In general it makes sense to pre-load the video at the start of your sketch and just play it as soon as you need it.

Loading it in another thread can be complicated because of the underlaying gstreamer binding which is not happy running in a separate thread.

please load the video in setup() only without starting it

when you want to show it, just say video.loop() or video.play()

if(t&&frameCount % 30 == 0)

{
thread(“post”);

}

void post()
{
…///
}

Thank you all! I have solved it by this method!

I think technically this is a very bad idea

Why is it a bad idea? If I don’t want to wait for a long time to load at first, but want to add videos during the running process, I’m afraid this is the only way?

By the way, I changed the video to gif, and I want every generated gif to start playing when it is generated

I have solved that problem. It is indeed not a good method. Loading in setup is better than anywhere else. I encountered a very complicated memory overflow with multithreading. Putting it in setup perfectly solved the problem.

Cheers brother!

1 Like