video crossfade

mindthegap's picture

Hello,

I am new to quartz... I search the forum but couldn't find an answer.

I am looking for a tip to blend to videos... perhaps jump in one video which is loop from point a to b and then playing from b to point c after a input, serial or keyboard.

where can i start...

regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cybero's picture
Re: video crossfade

Immediate thought - use the Graphics Transition template or else the Image Filter template and just have you two videos going in, maybe using a Core Image Accumulator in addition. Have fun :-)

psonice's picture
Re: video crossfade

I don't quite get if you're trying to crossfade or loop the video here, but if you want to crossfade there's a dissolve transition patch that will do exactly that.

If you're trying to loop + skip in the video, you need to set the timebase to external and feed it the right time. I released a comp I did ages back as a tutorial that features heavy video cutting: http://kineme.net/Applications/Compositions/psonicescompositionsandstuff...

gtoledo3's picture
Re: video crossfade

Psonice is right on about the dissolve... the other option would be to maybe have two renderers, and some kind of color fade colored with a stop watch time setup turn off of the renderer. The one thing about the dissolve is that stuff upstream of both inputs are likely to evaluate... that can be good or bad depending on the scenario.

If I had a bunch of preset loop points for a video I would probably take a multiplexer, make it a number multiplexer and put all of the start points in, then I would take another multiplexer and put all of the endpoints. The idea is that multiplexer 1, index 0 would have your first start point, and multiplexer 2, index 0 would have the corresponding end point... and whatever flips the indexes would be hooked to both multiplexers so that it would effectively flip your loop point sets.

You might run into some issues depending on how you are loading movies. Sometimes, if you're loading movies fairly quickly, the movie player patch current position doesn't clear when you put in a new file (if you are doing so with a file loader/string type of setup). I don't know if this is a filed bug or even a bug, but it doesn't seem correct. I've been meaning to see if controlling the movie patch via external patch time, and resetting that patch time each time a file loads would help, but haven't had an opportunity.

I have heard that the v002 movie player doesn't have that problem that the stock apple one does.

mindthegap's picture
Re: video crossfade

hi,

I have two HD videos. one is looping, when a key is pressed the other starts and is faded over the loop... (the loop should stop)...

What do i need? two movie loader... something to trigger the start stop and a transistion, a sprite for the final output?

regards

psonice's picture
Re: video crossfade

2 movie loaders, feeding into a dissolve patch. I'd use a billboard for the output unless you want to rotate it or anything, it's easier to set the size because the aspect ratio is handled automatically.

Handling the transition is a little harder. I would do something like this:

  • set both movie loaders to 'external timebase'

  • connect your 'trigger' input to the 'start' input of a 'stopwatch' patch. This way, when your key is pressed or whatever, a timer starts ticking up.

  • connect the stopwatch output to the 'time' input of the dissolve patch. When the timer starts, it will crossfade into the second video. If you want the crossfade slower, add a mathematical expression between the stopwatch + time input, with "time / x" inside. Set x to the time you want the fade to take, so 2 = 2 seconds.

  • connect the stopwatch output to the time input of the second movie loader. Now the second movie starts playing when the trigger happens.

  • for the looping movie, create a 'patch time' to a 'mathematical expression', and connect that to the time input. Put this in the expression: fadetimer > 1 ? 0 : patchtime Connect the patch time to the patchtime input, and connect the stopwatch to the fadetimer input. What this does is let the patchtime timer through until the stopwatch reaches 1 second (i.e. when the fade is finished), then it just passes 0 so the movie stops playing.

Probably not the most efficient method, but it should work (if I've not missed anything, and I wrote that without having QC handy to check so I probably have).

mindthegap's picture
Re: video crossfade

hi,

thanks for the great explanation. i didn't understand the last point.

for the looping movie, create a 'patch time' to a 'mathematical expression', and connect that to the time input. Put this in the expression: fadetimer > 1 ? 0 : patchtime Connect the patch time to the patchtime input, and connect the stopwatch to the fadetimer input.

how to put the patch time of the movie to the input of the expression...

and how can I stop the video at the end and fadeback to the loop.

perhaps you can help me also for this.

thanks

psonice's picture
Re: video crossfade

Sorry, I wasn't too clear there. "Patch time" is a QC patch - create one of those, and connect it to the expression. Then connect the output of the expression to the movie's time input.

To fade back to the loop at the end of the video, you'll need some more logic. Unfortunately it's getting a bit too complex to work through in my head, and I'm too busy finishing off an iphone project at the moment to set it up, sorry :(

As a hint though, you could use a stopwatch instead of the 'patch time' to drive the looping movie. You need a signal patch set to trigger at the start to start it counting when the comp starts playing. The stopwatch gives you more control - you can stop it when it's faded out, and you can reset it and start it again when you start fading back.

To work out when to start fading back, use the 'current time' and 'duration' (or whatever they're called) outputs of the second movie patch, and use another math expression patch with something like currentTime > duration - 1. That will output a 1 when it's within 1 second of the end of the movie, use that to trigger the fade and start the looped movie.

mindthegap's picture
Re: video crossfade

great, I used the Stopwathc to trigger the pause/play of the loop. the seconds videos fades in... only one point: when the secodn video is at the end I check with an expresion for the end and it swtich to the loop. But I am to stupid to fade it back to the loop. it blend hard... how can I trigger the blend back to the loop?

also I tried to compile a standalone verison with the crystal demo. Now there are no mouse or keyinputs... no paramaters with CMD-T and alos the speed is terrible slow. In Composer i got 40-60 frames... is there another way to make an stand alone application or to trigger composer to sullscreen when it starts?

regards dietmar

psonice's picture
Re: video crossfade

Ok, now you've got the basics, time for a better way to crossfade. Generate a 1 using expressions while you want the 2nd movie to play (actually, it should return to 0 when you want to crossfade back). Plug that into a smooth, then into the dissolve patch - when the expression goes to 1 you get a smooth fade, and when it goes back to 0 you get a smooth fade back.

I've attached a quick file with it set up, it seems to work. It also stops either video from playing when it's not active to keep it efficient.

PreviewAttachmentSize
crossfade.qtz7.31 KB

mindthegap's picture
Re: video crossfade

thank, that a fine way to do it.

I blend 2 mp4 HD videos. the framerate is going down... abozut 15 frames when the fade starts. (on the same machine with windows xp an vvvv on it see www.vvv.org for more infos) I can blend a few more of the same videos at the same time...

Hm where is the bottleneck? is there a way to do this in open gl with more speed? hmmm.

dietmar

psonice's picture
Re: video crossfade

Try changing the settings for the movies (mainly the asynchronous one - I remember it having a big performance impact in some cases). Failing that, try vade's movie player plugin: http://002.vade.info/?page_id=13

gtoledo3's picture
Re: video crossfade

I'm thinking try vade's plugin... I've been down this exact road, and external patch time still wasn't fixing the glitch of movies picking up from the current position of the last played movie occasionally {at least this is what I remember, but I could definitely be wrong... I kind of got disgusted with the whole thing and then other projects came up :) }. The stock patch won't always clear that value before it loads and plays what you feed it from a string input.

Come to think of it, I meant to file a bug report on that.... I hadn't even gotten to my complaints of fps (or really considered it).

I think that performance (fps) between the stock and Vade's is really similar though (I notice no difference).

If you are using .mov or video input with QC, just make sure you aren't using a higher resolution input than what you are ever going to get out of the back end. I have to say, I really don't think it handles HD movie footage or large files that well, unless you have a nicely powered machine... even then it is wanting. It seems that the codec can really make a difference. I can't give advice on specific codec, but it might be worth playing around....

If this is a scenario where you are making a qtz based product that has to take whatever movie file someone is going to throw at it .... my best wishes to you :) !!! There will be much wailing and gnashing of the teeth.

psonice's picture
Re: video crossfade

Hopefully snow leopard will improve matters around this side hugely. Quicktime has been rewritten, and is supposed to be much faster (and uses hardware acceleration at long last!) and QC will change a lot I suspect. Still file those bug reports though, just in case :D

cwright's picture
Re: video crossfade

psonice wrote:
Quicktime has been rewritten, and is supposed to be much faster (and uses hardware acceleration at long last!)

... don't count on it -- their focus has been largely on QT + iPhone tech, so I'm going to bet H.264 got 99% of the development time, and the infernal QT-dev mailing list got the remaining 1%. Normally I'd be optimistic about apple fixing broken frameworks, but QT and ColorSync are so hopelessly ensnared in legacy/bad design that they're not going anywhere anytime soon.

Quote:
QC will change a lot I suspect. Still file those bug reports though, just in case :D

Definitely file bug reports :) QC-SL is cool though, and Lots changed. We're looking forward to it :)

gtoledo3's picture
Re: video crossfade

Good points... I'm thinking it is a wise thought to give this exact qtz a spin in sl, as well as other problem/bug qtz's.

I think the thing about bug reports is always giving due diligence and making sure that what you are doing really makes sense, and IS a bug. Sometimes I'm not so sure that I think that using the whole conditional/tolerance/mov load based on time position and it equaling the duration, etc., is 100% something that should be expected to work right because of the ordering of events. I know that sounds odd... but I think I hesitated on filing the bug because I really wanted to think it through.