Creating dynamic video stripes (jit.gl.pix or codebox)

Luciana Viñas

9月 02 2023 | 4:17 午後

Hello! I think this is my first post in the forum, so thanks for reading. This is the scenario I'm imagining and what I couldn't achieve so far. I have a video being played in loop and I want to play specific vertical stripes of that video, leaving the rest in plain black. For example, if I divide the screen in 5 (N) equal stripes, I could show the 2nd and the 4rd stripes of the video and that would be seen as a black stripe, a stripe of the video, another black stripe, another stripe of the video and the last black stripe (0.2 to 0.4 and 0.6 to 0.8 would be the visible stripes, in normalized X-coordinate values). In order to do this I have a jit.gl.pix object with two inlets: in the left one the jit.gl.matrix, in the other one a unidimensional matrix with N numbers, that is the amount of stripes. For the scenario I just explained, that list would be 0 1 0 1 0.

After trying different approaches I ran into codebox. I have a function that crops the video, receiving the initial and the ending corners to crop:

``````rect(corn1, corn2) {
bord1 = step(corn1, norm);
bord2 = 1-step(corn2, norm);
return bord1.x * bord2.x * bord1.y * bord2.y;
}``````

If I write this manually inside the codebox, I can achieve what I want:

``````rect(corn1, corn2) {
bord1 = step(corn1, norm);
bord2 = 1-step(corn2, norm);
return bord1.x * bord2.x * bord1.y * bord2.y;
}
Param numSlices(5);
sliceSize = 1/numSlices;

out1 = rect(vec(0.2, 0), vec(0.2 + sliceSize, 1));
out1 += rect(vec(0.6, 0), vec(0.6 + sliceSize, 1));
out1 *= in1;``````

The problem is that I want the amount of stripes and the number of black stripes completely dynamic, so that's why I added the unidimensional matrix with the columns that I want to show. In the end I'm just not understanding how the value of the cells in the second matrix is accessed and how I can use it to alter the first matrix.

I'm attaching the patch working in "manual" mode (hardcoded stripes inside the codebox) and some commented code that I tried.

Thanks!

Michael Reichmann

9月 03 2023 | 12:22 午後

You can just multiply (jit.op @op *) the jit.movie output with the slices-matrix output to achieve the desired effect.

To change the number of slices you can then alter the dimensions of the slices-matrix.

Luciana Viñas

9月 03 2023 | 1:26 午後

God bless you... thanks!