Use QuickTime Player to create a video wall

22.05.2009
Have you ever wanted to create a "video wall" on your Mac--that is, fill your screen with a bunch of different video clips, all playing at the same time? I can't say that this is something I've ever needed to do myself, but it does make for an excellent demo. While I've seen commercial rigs that do this with a mix of separate monitors and associated hardware and software, I've not seen anything like today's tip, which uses QuickTime Player to create a do-it-yourself video wall on your monitor.

Often here on the Mac OS X Hints blog, I'll present a tip that includes an AppleScript, and walk through the steps the script takes to do what it does. Other times, though, the script is longer and more complex, and such an explanation would make the column just slightly shorter than Tolstoy's "War and Peace." Such is the case with this video wall hint--I'm not going to explain the code, just present it at and let you know that it worked well in my testing.

After pasting the code, click Compile to make sure there aren't any errors, then save the code as an application. To do that, select File -> Save, give your script a name (Video Wall) and save location, and set the File Format pop-up menu to Application. (Uncheck the Startup Screen box if it's checked.)

Once you've saved the code as an application, it's ready to use--you might drag it onto the Finder's toolbar or sidebar to make it easier to access, and possibly paste a custom icon onto it to make it easier to see, but it's ready to go as is. To use the new application you created, select a number of video clips and drag and drop them onto your program's icon.

QuickTime Player will launch, and start opening the dropped clips. The clips will be sized and arranged to take best advantage of your screen space, and all the clips will play at the same time (in loop mode, so they'll repeat). Just note that the more clips you drop, the longer it will take to open and arrange them. I tested this myself with about a dozen clips, and it worked as expected. I can't say it's something I'm going to use very often, but it is impressive to watch.

Without further ado, here's the code, with thanks to reader yossie for creating and sharing it. Copy and paste the following into a new Script Editor (in Applications -> AppleScript) document.

on open filelist tell application "QuickTime Player" to open filelist run end open on run tell application "QuickTime Player" set ratio to 4 / 3 tell application "Finder" to set display_bounds to bounds of window of desktop set display_width to (item 3 of display_bounds) set display_height to (item 4 of display_bounds) - 42 -- menu height + title bar set window_count to count of windows set max_pixels to 0 repeat with potential_cols from 1 to window_count -- try all possibilities - hardly optimal but who cares. set potential_rows to round (window_count - 1) / potential_cols + 1 rounding toward zero set {potential_window_width, potential_window_height} to {round display_width / potential_cols rounding toward zero, round display_height / potential_rows rounding toward zero} if potential_window_width / potential_window_height < ratio then set {potential_window_width, potential_window_height} to {potential_window_width, round potential_window_width / ratio rounding toward zero} else set {potential_window_width, potential_window_height} to {potential_window_height * ratio, potential_window_height} end if set used_pixels to potential_window_width * potential_window_height * window_count if used_pixels > max_pixels then set {window_width, window_height, cols, rows} to {potential_window_width, potential_window_height, potential_cols, potential_rows} set max_pixels to used_pixels end if end repeat set {x, y} to {0, 0} set wins to (get every window) repeat with win in wins set doc to document of win set controller type of doc to none set looping of doc to true set {wi, hi} to natural dimensions of doc if wi / window_width > hi / window_height then set dimensions of doc to {window_width, hi / (wi / window_width)} else set dimensions of doc to {wi / (hi / window_height), window_height} end if set x to x + 1 if x = cols then set {x, y} to {0, y + 1} end repeat set {x, y} to {0, 0} set wins to (get every window) repeat with win in wins set {wi, hi} to natural dimensions of doc if wi / window_width > hi / window_height then set bounds of win to {window_width * x, 22 + window_height * y, window_width * x + window_width, 22 + window_height * y + hi / (wi / window_width)} else set bounds of win to {window_width * x, 22 + window_height * y, window_width * x + wi / (hi / window_height), 22 + window_height * y + window_height} end if set x to x + 1 if x = cols then set {x, y} to {0, y + 1} end repeat set wins to (get every window) repeat with win in wins play document of win end repeat activate end tell end run