QuickTime 7.5 Core Animation Improvements

QTMovieReflectionQCSnapShotLarge


Every time a new Apple software update comes out, people always wonder what's really changed. Apple's release notes are usually not very detailed. QuickTime 7.5 which was released the week of WWDC 2008 happened to be a fairly significant update in terms of bug fixes and enhancements.

I was trying to implement a "reflection" of a movie layer using QTKit and Core Animation. I wanted a single movie source and either two movie layers to share the the source, or a way to capture the current displayed image of one layer and transfer it to another. It turns out neither was possible prior to QuickTime 7.5. (You might be able to use to Core Video and OpenGL, but the QuickTime/Core Video API interface still hasn't been updated to support 64-bit which is a different problem. And the 'play multiple movies' work around is too performance heavy and the videos do fall out of sync.)

Now with QuickTime 7.5, you are able to use a shared QTMovie object and apply it to multiple QTMovieLayers/Views. (Capturing the current rendered image of a QTMovieLayer and redirecting to another CALayer is still not possible.)

There were a lot of other limitations and bugs with QTKit and Core Animation in general prior to 7.5. Using layer backed QTMovieViews, could expose strange white patches in places. There also seemed to be glitches with the control interfaces superimposed on the view when layer backed. All this seems to be fixed now.

Another important bug they fixed is 64-bit now works. There was a bug where the video would not render to the screen (it was completely invisible), though you could hear the audio play.

They also seemed to improve the performance of the 'playing in reverse' feature. Trying to set negative speeds led to a very jumpy/choppy experience. With the 7.5 update, things seem to have improved (though it could still be better.)


Because Apple's engineers fixed my problems here, I wanted to show my appreciation and publicly note that they do indeed read bug reports, fix bugs, and make things better. So I have posted a little demo prgoram that shows off the new shared movie code. (And I compiled a 64-bit version as part of the Universal Binary.)

Strangely, this demo was inspired by a WWDC demo which the Apple engineer later told me was inspired by my bug report and DTS incident I filed because I was unable to figure how to do "reflections" with the QuickTime/Core Animation stack. 

I don't think this demo is as good as the one at WWDC, but I put this demo together really fast (targeted two hours) and don't really have time to spend on it. Unlike the one at WWDC, I have made my source code freely available.


The demo just creates a bunch of movie layers and arranges them in a circle and rotates them around. Each 'blade' also has a reflection layer below it which is just another movie layer with a filter and some alpha.


And for no good reason whatsoever, I added a Quartz Composer layer as a background. Look for the #define DONT_USE_QUARTZ_COMPOSER to disable it if it is too much or the performance sucks too much.


One problem I struggled with is handling window resizes correctly. I originally tried the autoresizingMask system but the individual layers didn't resize correctly, and in some cases they disappear or render strangely.  Performance was also terrible. At the suggestion of Scott Stevenson from NSCoderNight, I moved to the CAConstraint/layout manager system which improved things considerably, but I still haven't gotten it to behave quite like I wanted. If anybody can improve on this, please drop me a line.

I have posted the code at Assembla in a Mercurial repository:

http://www.assembla.com/spaces/QuickTimeCAReflection

You can also find a prebuilt Universal Binary in the Files Section. It includes the 64-bit build, which suffers performance-wise on my iMac. So if you also get this performance hit, you might want to launch the app in 32-bit mode. (Use Finder's Info panel on the app to set this.) I need to get around to filing a performance bug report on this.


Copyright © PlayControl Software, LLC / Eric Wing