# How can I load the video without affecting the overall process？

**URL:** <https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964>\
**Category:** Libraries\
**Created:** [January 11, 2021, 4:07am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964 "2021-01-11T04:07:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [January 11, 2021, 4:07am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/1 "2021-01-11T04:07:16Z")

</div>

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？

---

<div class="post-metadata">

**Author:** ![cansik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cansik/32/8815_2.png) [@cansik](https://discourse.processing.org/u/cansik)\
**Post date:** [January 11, 2021, 10:43am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/2 "2021-01-11T10:43:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 11, 2021, 7:00pm UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/3 "2021-01-11T19:00:05Z")

</div>

> [@AbleYudada](#):
>
> After the video was loaded, the fps would be restored.

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

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

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [January 18, 2021, 7:17am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/4 "2021-01-18T07:17:56Z")

</div>

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

```

{  
thread(“post”);

}

void post()  
{  
…///  
}

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 18, 2021, 8:46am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/5 "2021-01-18T08:46:06Z")

</div>

I think technically this is a very bad idea

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [January 18, 2021, 8:57am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/6 "2021-01-18T08:57:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [January 18, 2021, 9:00am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/7 "2021-01-18T09:00:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AbleYudada](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ableyudada/32/14190_2.png) [@AbleYudada](https://discourse.processing.org/u/AbleYudada)\
**Post date:** [January 19, 2021, 7:14am UTC](https://discourse.processing.org/t/how-can-i-load-the-video-without-affecting-the-overall-process/26964/8 "2021-01-19T07:14:30Z")

</div>

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！
