Playing Multiple Videos as Layers

elisavage's icon

Hi all,

This is my first post. I recently found out about Max/MSP/Jitter because I was telling a fellow  installation artist about a problem I had with an interactive music video that I made in flash. In the video you could use the keyboard to turn off and on members of the band and their respective audio tracks. Flash bottomed out and I had to go with tiny videos because it couldn't handle the 5 instrument layers and a background. Even with this it took an untenable amount of time to load the bloated flash file. So basically I have 6 video layers, all of their alphas are set, so I just need to stack them one on top of the other in a viewer. Using 2- 4MIXRs, I was able to have all 5 instrument layers playing together, I just set it to "+" and set each layer to maximum. THe problem I am running into is getting those to just sit on top of my background layer. It doesn't have any alpha- it didn't need to because the instrument videos all have their alpha set  and were filmed in a way that  they will not need masking.  Does anyone know of a tool for simply stacking videos at full alpha in a VIEWR?  It would be great of  I can set my BG video to the back most layer and the 2nd 4MIXR to the front layer. Thank you ahead of time, I have been reading the forum a lot it it really seems like an amazing supportive community!

Cheers,

Eli

Rob Ramirez's icon

i recommend you dive into opengl for this. you can simply create a jit.gl.videoplane for each layer, set @blend_enable 1 @depth_enable 0 on each, and control the layering order with the @layer attribute. the default blend mode uses the alpha channel.

you can then download the jit.gl.hap external (os x, 32 bit only) which is a much more efficient player for quicktime movies (including those with alpha channels).

elisavage's icon

Awesome. That seems way more elegant than trying to stack 4MIXRs inside of 4MIXRs. Now if I wanted to build that as an application for the web (would it make it a javascript app?) would it package jit.gl.hap within a player, or would one need to use the default player? Thank you Rob!

Rob Ramirez's icon

there is no way currently to deploy a max patch to the web.
you can build a standalone application, but it must be run from a desktop/laptop.
the jit.gl.hap external should get automatically included in the standalone when you build it.

elisavage's icon

For the installation, that will work great. I was just hoping to integrate it into my online portfolio. Oh well! Thanks for all of the advice.

Russell Richards's icon

Hi Rob,

Just a few years on and I am trying to swap between 5 videos as jit.gl.videoplane layers but when a video stops it leaves a frame in view that does not go when changing the layer for the video nor can it be over-written by set another video to a higher layer. I have tried to change the video layer sequence when each video is running but that does not work either. I am using @blend_enable 1 @depth_enable 0.

Any help would be much appreciated.

Cheers

Russell

Source Audio's icon

there are quite few options to wipe screen, for example :

riccardo dapelo's icon

Or you could try with a combo of blend mode and gl_color message


Russell Richards's icon

Hi Both

Thanks for the swift replies. I'm going with Source Audio's bottom left patch as it feeds into the rest of my patch most readily.

Thanks again both.

Cheers

Russell

Russell Richards's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Further to: I implemented Source Audio's solution which worked in terms of switching the layers on and off but did not bring a given layer to the front. I tried dynamically having one vid as layer 1 and the rest as layer 0 but that was erratic, sometimes forwarding a layer I did not want.

In a patch that needs to arbitrarily bring any of seven vids to the fore I could not hard code that.

So the attached patch was created to handle that. Using sel it automatically brings a vid/layer to the fore and places the other six vids of different layers.

It's pretty ugly. Hence hiding it in a patcher.

It works but is there a more beautiful way to do this layer mapping?

slo ~|•'s icon

Hi Russell,

It's not clear exactly what you're aiming for, but I usually do this kind of thing kinda like a DJ. While one video is visible I swap the other one with the next video I was to show. Using jit.movie object's "asyncread" message can help avoid hiccups when switching/loading videos. Alternatively you can have a jit.movie object for each video, then switch the texture names being used downstream.

Check out the jit.gl.pix.alphablend.maxpat You can find it by searching in the File Browser.

Wil's icon

like @SLO said - or even more simple just [switch]

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

shouldn´t it be enough to use the same clock for both streams...

...and then switch the clock´s target, and not the movie output.

Russell Richards's icon

Here is the output if the enable is switched on for one vid and off for the others. The non-playing vids are still "above" the one I want to play.

Non-playing layers above a playing layer

Thanks @SLO I'll check those options out.

@WIL that's neat. I did not know you could use switch like that.

@Roman Thilenius I do not understand the use of a clock.

slo ~|•'s icon

I realize my post is a bit incoherent. Here's an example of what I was trying to get at (based on WIL's patch):

Max Patch
Copy patch and select New From Clipboard in Max.

EDIT: @Russell From the pic it looks like the plane of the jit.gl.videoplane/jit.gl.layer object is still in front/visible. You need to control (disable/make transparent/move to the back) the jit.gl.videoplane/jit.gl.layer object.

Russell Richards's icon

@SLO that is nicely done. My present project does not need cross-fades but I will certainly be using that in the future, and switch, of course.

riccardo dapelo's icon

As Slo pointed out the problem is making the other videos transparent. The approach with switches and clocks seems to me perhaps a bit unnecessarily complicated. If you don't need crossfades a minimum of control logic is sufficient, provided that you use blend mode= screen of the various jit.gl.layers.

Max Patch
Copy patch and select New From Clipboard in Max.

Russell Richards's icon

Dear All

As ever Max has many ways of doing the same thing. All of them more beautiful than my way.

Cheers

Russell