Forums > Jitter

How do you combine multiple videos into one in texture or shader?


May 25 2016 | 8:50 am

Hi guys,

How do you combine multiple videos into one in texture or shader like in the example below? So not within a videoplane or anything like that but before that so I can put an effect after it. Any clues?

Thank you,
ygreq

— Pasted Max Patch, click to expand. —
May 25 2016 | 8:52 am

Or better yet how to you multiply it as many times as you want? 10×10 for example?

May 25 2016 | 10:23 am

if you want behavior similar to jit.glue, then using jit.glue with matrices prior to turning in to textures is the simplest route.

otherwise, you can roll up your sleeves with jit.gl.pix to accomplish this. "sample" and "norm" are the operators to look at. you will need to set the output texture dimensions to whatever you want using a dummy texture in the left most outlet.

here’s a basic example that glues together to video inputs to a single texture:

— Pasted Max Patch, click to expand. —
May 25 2016 | 11:26 am

Thank you, Rob, but jit.glue is a terrible object. And jit.gl.pix is a bit like Chinese for me.

I was trying to create at least a 2×2 grid of 4 videos. I guess I will try to do it using jit.gl.node if there are no other possibilies. :(

May 25 2016 | 2:24 pm

Wow. Didn’t realize you could do *that*, Rob. Thanks.

May 25 2016 | 2:30 pm

By the way – what’s wrong with jit.glue? It’s the obvious choice (unless you want to use usesrcdim / usedstdim and their friends srcdimstart, srcdimend, dstdimstart, and dstdimend to write to a named matrix, maybe)….

May 25 2016 | 2:36 pm

I am using jit.grab and doing fx with some shaders so I cann’t combine those with jit.glue.
And jit.glue is hoggy when it comes to using multiple columns and rows. At least this is what I remember since I last used it intensively a few years ago.

May 25 2016 | 7:55 pm

…and, thanks to Rob’s elegant example, here’s a solution to the jit.gl.pix 4-in-1.

As ever, I am in awe of your skills, Rob. Thanks!

— Pasted Max Patch, click to expand. —
May 25 2016 | 8:00 pm

Or just this?

— Pasted Max Patch, click to expand. —
May 25 2016 | 8:02 pm

sweeeeeeeet, Christopher! Add a few negative values to the scaling and it’s kaleidoscope time!!!!

May 26 2016 | 12:26 am

Thank you, guys, for your help!

Max, I will try that definitely. Christopher, that is what I was thinking of when I said I would need to add a jit.gl.node as there are many things that happen in the main render. Both solutions are great! And thanks again, Rob!

Dec 18 2016 | 7:32 pm

Just found this thread and have a question for those in the know.
If I wanted to construct a larger grid of videos (16×12 using 6 videos), than the jit.gl.pix option would be the best route in terms of performance over the other options offered…?

Dec 19 2016 | 9:39 am

the important thing is to size your video files appropriately (no larger than necessary), and enable output_texture. either technique in this thread will work well for displaying them.

Dec 19 2016 | 1:58 pm

Thanks for that Rob.

Yes, I have resized my video appropriately. I have constructed this ‘video fabric’ using the jit.glue route but would say it is not functioning at a performance level that cuts the mustard—particularly when switching videos.

I think I will roll up my sleeves and give the jit.gl.pix a try. To date, everything I have constructed in jit.gen has outperformed all other options.

Mar 16 2017 | 5:13 pm

Update on the ‘video fabric’ efforts and additional question.

To construct a 10×10 grid of video’s I ended up using 6 x (jit.movie @output_tecture 1 @ texture_name (name) @colormode uyvy) to 100 x (jit.gl.gridshape @texture (name) @transform_reset 2 @automatic 1 @drawto cat) to (jit.world cat @fps 60).

I have 40 videos that are randomly read into the jit.movie objects.
Up until this past weekend, I had no issues and am loving the results. The ultimate test, however, is if the installation can run all night.

Failed.

The issue is, after a few hours of running, I get an error message stating the movie file can not be found when the jit.movie attempts to read. I have to close the patch and reopen it to reconnect the file pathway. I’m working on a Mac Book Pro and have set the Energy Saver to ‘Never’ and have clicked the Prevent App Nap in Max. I added a counter during the last test to see how many read messages were successful before the error. 130 x 6.

I will test again this weekend and perhaps move the movie files to another location but other than that, I can’t figure out what might be the issue. I’m stumped. Any thoughts?

Mar 20 2017 | 12:30 pm

sounds like maybe you’re relying on the the current working directory path to load your movies. this will change to the location of the most recently loaded file, and so is not reliable if that location changes. you should either look into using absolute file paths for your movie files, or better yet use Projects.

Mar 20 2017 | 3:35 pm

Thanks for the reply Rob,

This weekend I tested a few methods and ended up with the same issue. I even placed the movies in the media folder where all the Max demo video are located. But no go. After a few hours of running the installation, I get the "can’t find movie file" error.
But before that error message, there is always a series of jit.gl.fbo_texture draw begin: GL Error: Invalid value
I thought that perhaps the jit.movie was losing the connection with @output_texture 1 so I set up a periodic bang message to the jit.movie.

The weird thing is, and this is what confuses me, if I am working on the patch; as in manually triggering buttons etc., this error issue does not occur. I’ve work a whole day on this patch with no problems. I might give PHIOL’s jit.gl.polymovie a go to see of that might work better.

Regards,
Teresa

Mar 20 2017 | 6:10 pm

try the jit.gl.multiple version of my jit.gl.polymovie.

you’ll get better results if you save the jit.gl.multiple version as a seperate patch

I’m getting a solid 60 fps with 20X20 videos (400 instances)
and even a good 33 fps with 40X40 videos (1600 instances)

and my mbp is almost 3 years old
nvidia 750m

— Pasted Max Patch, click to expand. —

of course you need to save it in a folder with all the other abstraction patchers.
and again the content (moviefiles) go in the media folder.

here it is , if anybody ever falls on this thread :-)

https://www.dropbox.com/s/s0vuheiufvmpz8u/jit.gl.polymovie.zip?dl=0

phiol

Mar 21 2017 | 9:47 am

teresa, sounds like you might be running out of memory, are you running in 32 or 64 bit? def better to be in 64 if possible.

Mar 22 2017 | 2:30 pm

Hi Rob, Thanks for the reply. I’m running in 64 bit. I stopped doing anything in 32 bit some time ago.

Hi PHIOL, Thanks A BUNCH for that! I will give it a go.

My issue was not fps as I was (joyfully) getting a solid 60 fps for the whole during when the installation ran.
It’s just the patch stopped finding the movies after a few hours.
I placed all movies in a Projects folder, then placed them all into the OS Movie folder with a direct search link, and then (going old school) into the Max program media folder. Same thing happened, after running for a few hours the jit.moive kicked out the error message that the movie could not be found, preceded by the (jit.gl.fbo_texture draw begin: GL Error: Invalid value) error.

I’ll spend the weekend looking at your patch, and thanks again for that.

Teresa

Mar 22 2017 | 5:31 pm

Hi again Teresa ,

> I have 40 videos that are randomly read into the jit.movie objects.
>130 x 6

This is where I believe my patch will help you.
All videos are read only once(on startup), then (in my patch setup ) each video texture are called using noise to call @texture attribute. As you can see this occurs directly in the jit.gl.multiple object.

As common practice, you load everything on startup , then put it to sleep.
Then wake it up when needed. This is how thing are done in 3D gl gaming software.
If the camera does not see your geos , there are not processed. But still everything is loaded on startup and waiting for a go!

Here below (objects in blue),

I make it obvious how to change a single cell’s texture

— Pasted Max Patch, click to expand. —

good luck

Mar 22 2017 | 5:46 pm

Thanks for that Phiol,

Nice patch.
It’s very helpful.

Best,
Teresa

Viewing 22 posts - 1 through 22 (of 22 total)

Forums > Jitter