Generating a Video Grid
Hello,
I'd like to create a patch that takes a video and displays it on a video grid consisting of n items.
Each item, showing the initial video, should be slightly time delayed to its left item. If we think of it in terms of a matrix of dimension 2 x 2, the item in cell 0 0 would show the original video without delay. The item in cell 1 0 would be delayed by e.g. 50 ms. Relative to cell 0 0, cell 0 1 would be delayed by 100 ms and cell 1 1 by 150 ms.
I've tried using jit.glue, but it doesn't generate textures and is thus not able to perform well. Another disadvantage is that I was only able to create 7 or 8 rows and columns, if I go higher the video just disappears (even after resizing my jit.world render). Also, this approach requires me to patch the video matrix into n amounts of time delays and n amounts of jit.glue row and column inlets, which is way to much work for a high dimension matrix.
I'm looking for a solution that takes as little wiring as possible and runs efficiently with textures.
The number of grid rows and columns need to be actively adjustable and the rest of the patch should do the following calculations automatically. I'm sure this is somehow possible, so that the original video is resized to fit into "the first cell of a matrix", then create time delayed copies of that cell to the neighboring cells.
Can somebody please guide me in the right direction?
Thanks for all the effort.
Josh
Hi Joshua,
What you need is a video delay.
The simplest way to accomplish your goal IMO is using a 3D texture accessed via shader.
At the moment, there's no other way to access and use 3D textures.
The main advantage of this approach is that the computational cost is independent of the grid size (try to crank up the "grid_size" value).
Another possibility is to use jit.gl.textureset, which is great for implementing video delay. However, since you need a video grid, you have to access the video buffer multiple times and at different locations, and probably jit.gl.textureset would be slow and/or cumbersome to use in the context.
Another possible approach could be using the object jit.gl.polymovie (see "multihead" tab in the help file), but again, it's hard to assign a different frame to each grid cell in a flexible manner.
I hope this helps,
Cheers!
Hi Matteo,
I am stunned by how efficient your patch is and how you managed to do that with so little patching. Your solution is basically exactly how I imagined the program to work. Thank you so much for your time!
This leaves my brain a little less flooded with endorphins, as I didn't go through days of pain, trying to find a solution myself 😂. Nevertheless, I would be happy to use your patch as a working base to implement other functions like rotation. And also use it to render videos for non-commercial and maybe commercial purposes. Do I have your permission to do so?
Btw you are a beast (positively speaking), I've been following your patreon for some time now and your content is always educational and exciting.
All the best,
Josh
Thanks so much, Joshua!
I'm glad you enjoy my educational content.
Sure, feel free to use the patch however you prefer