# A single sketch for saving video's frames and storing them in an array

**URL:** https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126
**Category:** Processing
**Created:** [August 31, 2018, 3:07am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126 "2018-08-31T03:07:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![arnonneder](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arnonneder](https://discourse.processing.org/u/arnonneder)
#### Post date: [August 31, 2018, 3:07am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/1 "2018-08-31T03:07:08Z")

</div>

I believe this is a beginner’s question 🙂

I want to play a video in Processing for the purpose of storing the frames in a folder and then storing those frames in an array so I can upload them into the sketch for further manipulation.

The problem is that playing and saving the video’s frames happen inside draw(), whereas storing the frames in an array occurs inside setup() (I can’t store them in an array before breaking the video into consecutive frames).

Does anyone have an idea how I can combine them in a single sketch? Is that possible?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [August 31, 2018, 3:13am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/2 "2018-08-31T03:13:25Z")

</div>

Can you do it in two separate sketches? Create one sketch that processes the video into image files, and then another sketch that loads the image files.

If that won’t work, can you please post a [MCVE](https://stackoverflow.com/help/mcve) that shows what you’re trying to do?

---

<div class="post-metadata">

### Author: ![arnonneder](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arnonneder](https://discourse.processing.org/u/arnonneder)
#### Post date: [August 31, 2018, 3:22am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/4 "2018-08-31T03:22:40Z")

</div>

Thanks @Kevin, yes I currently have two separate sketches but I was wondering if it was possible in any way to combine them for the sake of efficiency…

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 31, 2018, 3:29am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/5 "2018-08-31T03:29:32Z")

</div>

You will get better feedback if you provide a demo aka MCVE of your code.

For instance, if you put it together, I assume you will run or the other but not both, correct?

Kf

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [August 31, 2018, 3:33am UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/6 "2018-08-31T03:33:08Z")

</div>

I would probably just stick with two sketches. In fact that’s exactly what I did for my [Movie Colors](https://discourse.processing.org/t/movie-color-visualization/2285) project.

I wouldn’t worry too much about “efficiency” with this kind of thing. Keeping your code simple and easy to work with is generally much more important.

If you really need to do it in one sketch, then you can do something like play the movie at 10x speed to get the frames at startup.

---

<div class="post-metadata">

### Author: ![arnonneder](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arnonneder](https://discourse.processing.org/u/arnonneder)
#### Post date: [August 31, 2018, 1:30pm UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/7 "2018-08-31T13:30:49Z")

</div>

> [@kfrajer](#):
>
> For instance, if you put it together, I assume you will run or the other but not both, correct?

Yes exactly @kfrajer

---

<div class="post-metadata">

### Author: ![arnonneder](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arnonneder](https://discourse.processing.org/u/arnonneder)
#### Post date: [August 31, 2018, 1:32pm UTC](https://discourse.processing.org/t/a-single-sketch-for-saving-videos-frames-and-storing-them-in-an-array/3126/8 "2018-08-31T13:32:00Z")

</div>

I see what you mean @Kevin, thanks!
