A-B video switcher

Image

 

This is a more refined sort of A-B video switcher patch than the one shown in the “Simplest possible A-B video switcher” example. It has a considerably more sophisticated user interface when viewed in Presentation mode. It will try to open two video files called “A.mov” and “B.mov”, and it also provides buttons for the user to open any other videos to use as the A and B rolls.

Another possibly significant difference is that in this example we stop the movie that is not being viewed, and then when we switch back to that movie we restart it from the place it left off. In the previous example both movies were running all the time. If you need for the two movies always to be synchronized, you can either leave them both running as in the previous example, OR, whenever you stop one jit.qt.movie object, you can get its current ‘time’ attribute value and use that value to set the ‘time’ attribute of the other jit.qt.movie object when you start that one. (That’s not demonstrated in this example.)

Simplest possible A-B video switcher

Image

 

This is the simplest possible way to switch between two videos. When the patch is opened we read in a couple of example video clips (which reside in ./patches/media/ within the Max application folder, so they should normally be in the file search path). Because the default state of the ‘autostart’ attribute in jit.qt.movie is 1, the movies start playing immediately. Because the default state of the ‘loop’ attribute in jit.qt.movie is 1, the movies will loop continually. Click on the toggle to start the qmetro; the bangs from the qmetro will go out one outlet of the ggate (the outlet being pointed to by the graphic), and will thus go to one of the two jit.qt.movie objects and display that movie. Click on the ggate to toggle its output to the other outlet; now the bangs from the qmetro are routed to the other jit.qt.movie object, so we see that movie instead. (Note: You can also send a bang in the left inet of ggate to toggle it back and forth, or you can send it the messages 0 and 1 to specify left or right outlet.)

If you don’t know the difference between a metro object and a qmetro object, you can read about it in this page on “Event Priority in Max (Scheduler vs. Queue)”. In short, qmetro is exactly like metro except that it runs at a lower level of priority in Max’s scheduler; when Max’s “Overdrive” option is checked, Max will prioritize timing events triggered by metro over those triggered by qmetro. Since the precise timing of a video frame’s appearance is less crucial than the precise timing of an audio or musical event (we don’t notice usually when a frame of video appears a fraction of a second late or even occasionally is missing altogether, but we do notice when audio drops out or when a musical event is late), it makes sense to trigger video display with the low-priority scheduler most of the time.