Archive for OSX

OSX Drawing with Quartz 2d for After Effects Plugins; A Quartz Composer Laces Sample Plugin

[vimeo clip_id=’35717847′ width=’500′]
When working on custom projects I develop a lot of single use plugins for things like data visualization. Although I’m becoming more comfortable with OpenGL, my comfort zone for drawing is really using the tools available on OSX like Quartz 2d. After Effects is my favorite compositing environment and it took a while to build a working toolkit for OSX drawing in an After Effects plugin with things like build phases, importing frameworks, Objective-C++, CGContextRef, PF_EffectWorld, PF_Handle, etc. To help folks trying to get that toolkit together I thought I’d share a starting point XCode project as well as the base drawing code for one of the data viz tools I’m working on.

The XCode project can be a useful starting point for a developer interested in these kinds of projects. It includes linked frameworks, a reasonable memory allocation scheme (I think, more experienced devs feel free to point out any gotchas), a working example of how to use both CGContextRef and NSGraphicsContext and some useful drawing code.

The sample plugin is a Quartz Composer style laces plugin which can work nicely for connecting nodes or data visualizations. The included version is pretty bare bones, but if there is interest I am thinking about developing it in to a more full featured general purpose plugin.

This setup has worked for my needs and has been cursorily checked for bugs, leaks and crashers, but if you are going to use it for production work I’d make sure to attempt some pre-renders at the size, bit depth, etc. you are using to make sure there is not something I didn’t account for.

If you end up using the code in something you release, I’d appreciate a credit in the release notes. Tip of the hat to Edouard FISCHER for the original laces drawing code. Next up is a deeper dive into OpenGL, Quartz Composer, textures, and all kinds of fast drawing GPU goodness.

Laces Plugin for OSX After Effects
Laces Plugin Xcode Project For OSX

Comments off

Saving a download in Safari stuck at “Displaying the software license agreement”

I was stuck on a fairly large .dmg download via Safari today with the Download window reading, “Displaying the software license agreement”, like so.

I’m not sure what was up, but I knew I didn’t want to take the time to re-download it. Turns out a quick right-click, and “Show Package Contents” gave me access to the .dmg and it mounted and verified just fine. I don’t think this would work with a .download that was actually hosed, but maybe a web search to this post will save somebody a bit of download time.

Comments off

Using Apple Motion with Adobe After Effects

Looks like Apple’s chocolate is in Adobe’s peanut butter, or is it the other way around? Import Motion Files Into Adobe After Effects is an Apple tutorial on how to bring Motion files into After Effects.

The cool thing about Motion files is that the project format is a well formed XML file that Quicktime understands how to render. That’s how you get cool products like Digital Heaven’s Automotion. If you’ve got more of a DIY bent, that also opens up a lot of possibilities for creating cool projects via XML transforms and scripting. More to come as I explore some of the possibilities.

Update 03.08.2007

While I was researching, it looks likes the folks at motionsmarts have already been hard at work with cool scripts for Motion. After Effects Position to Motion Position script looks particularly useful for the kind of stuff I do.

Comments (2)

Using the Spotlight Importer to Extract Text from a PDF

Ever have a PDF that you need to grab a bunch of text from and don’t want to spend a lot of time selecting and copy/pasting? You can use the Spotlight Importer command-line utility to extract the text on OS X.

/usr/bin/mdimport -d2 /path/to/pdf/file.pdf >& pdf.txt 

It’s the raw text that Spotlight is using to index the file, so you’ll need to do some clean up, but your mouse hand will thank you.

(via Borkware Quickies)

Comments off

Reading Quicktime Timecode in After Effects Redux: A Solution

When we were last talking about reading timecode from FCP sourced Quicktime’s I followed a tangent into Spotlight and other OS X technologies. Well, recently I revisited this problem for another project I’m working on and I think I’ve got a working solution for reading embedded timecode in After Effects on OS X.

timecodereader is a command-line utility that takes a path from After Effects via system.callSystem() and returns either the embedded timecode or the string . Right now the included .JSX script just writes that information to the console, but there are a lot of cool uses for Quicktime timecode in productivity scripts.

How to Use timecodereader

Download the zip archive, and either compile a new binary from the included XCode project or move the already compiled binary from build/release to a local binary directory. Since this is a command line tool you will want to move it to a location in your Path statement so you can use system.callSystem(“timecodereader ” + String(thisItem.mainSource.file))” instead of system.callSystem(“/path/to/timecodereader ” + String(thisItem.mainSource.file)) .

Update 09-09-2006: Lloyd Alvarez points out at aenhancers that AE preferers ~/bin/timecodereader when we set up as below. I’ve adjusted the enclosed script.

In the default Bash shell

export PATH="$PATH:~/bin"
echo 'PATH="$PATH:~/bin"' >> .profile

will setup a path to bin in your User directory. Move the enclosed script to your Scripts folder, select a Quicktime file in the Project window and we’re done.

When I run the script, I get these results (The 1:00:00:00 timecode is due to the fact that I’m using writeln to write to the console so the previous lines scroll up until they are out of view).

After Effects Project Window with Quicktime selected
After Effects Info Window with timecode displayed

I’ve tried timecodereader with quite a few Quicktime’s but obviously there might be a few that aren’t handled well, so consider this a beta release. The compiled binary is a universal binary so it should work on both PowerPC and Intel platforms. One gotcha, is that if you have a codec that is not compiled for the supported platform you might get a dyld returns 2 log message that might futz with your script. You can either work around it via string handling or remove the codec since it won’t work anyway. You’ll need to turn on Allow Scripts to Write Files and Access Network and turn off Enable JavaSript Debugger so we can eat the errors.

timecodereader requires After Effects 7, and OS X 10.4+

Updated file: 09.09.2006

Fixed a problem with external Hard Drives and Mounted Volumes. After Effects does not add /Volumes/ to drive paths like OS X, so /Volumes/MyHardDriveName is reported as /MyHardDriveNameI’m basically checking all mount points and adding /Volumes when appropriate, unfortunately the response is a bit slower if you have disk images or a lot of volumes mounted. If anybody knows anything faster send it my way.

Also. I’m using metadata checks for to check whether the file is a quicktime file. This only works on volumes that are indexed, so it might not work on mounted server volumes. I can add alternative QT detection if anybody finds it useful or necessary.

Zip Archive of Binary, Script and XCode Project

Comments (10)

Kona 10bit RGB/Trillions+ with Endian Option producing black frames?

Update 9/11/2006 6:20PMI said I’d update this post when updated drivers were available, and it looks like the 8/29/2006 drivers from AJA have addressed this issue. Download them here.

Update 8/19/2006 2:50PM OK. It appears that downgrading the codec to version 1.2 fixes the issue. Run the uninstaller, and grab the 1.2 codecs at Aja’s site. I’m going to leave this up for any future Google searches and I’ll update it when there is an upgraded codec. Thanks to Evan on this one.

I’m running into a problem with Kona 10bit RGB output with trillions+ that I’m hoping somebody might be able to help with since I’m on a really tight deadline. I’ve been happily producing 10 bit RGB quicktimes with trillions + option for weeks now. I bought several new machines that have introduced a new endian option in the compressor options like so…

big endian option

This is what all of our older machines with the same version of OSX, Quicktime and Kona drivers look like…

no big endian option

All of the Quicktimes we produce from the computers with the endian option produce black frames no matter what combination we use when trillions+ is selected. I’m aware of endian issues with the new Intel Macs vs G5 Macs, but I can’t seem to produce a working combination and like I said all software is up to date on all machines. I’m guessing a firmware issue or something. I’m hoping somebody has a working workaround and can send a comment or email to dale(at)creative-workflow-hacks(dot)com. Normally, I’d just go through tech support options, but my deadline is pressing. Thanks folks.

Comments off

Interface Gripes: Is your After Effects document dirty?

After Effects 7 has debuted to decidedly mixed reviews at work. While most folks are excited about the new features, there is a general unease with the new interface. It’s as if we’re dealing with a new Adobe OS. I think as we get a few projects under our belt the unease will dissipate a bit especially since we have such a history with the application and it is strong in features and implementation. My personal opinion is that user feedback will moderate the interface in future versions and I want to point out one example of a platform specific UI cue that is an example of why you might want to not make an application too uni-platform.

A dirty document in OS X is a document with unsaved changes. There is a clear way to indicate this. Here are a few examples in some Adobe apps.

In Photoshop, a document before making a change

A clean document in Adobe Photoshop

In Photoshop, after making a change

A dirty document in Adobe Photoshop

In Illustrator, a document before making a change

A clean document in Adobe Illustrator

In Illustrator, after making a change

A dirty document in Adobe Illustrator

Notice the filled in bubble on the left? Now let’s do the same thing in After Effects.

In After Effects, a document before making a change

A clean document in Adobe After Effects

In After Effects, after, umm, making a change

A dirty document in Adobe After Effects

In After Effects we lose an OS X interface cue. My guess, is this is an oversight from creating the interface with non-standard GUI widgets and that’ll get fixed in a later verson. But it is a great example of what happens when you try to go it alone in interface land, especially with Mac users who are a notoriously finicky lot. So, when I talk to Adobe developers, I’ll be sure to put in my voice for letting each platform retain its own individual personality.

btw…I am aware of the asterisk next to the file name cue, but this isn’t an either/or situation, so many interface cues are practically subliminal, and if a quick glance to the left corner doesn’t give me what I’m looking for, I’ll just think that it isn’t Mac like without really knowing why.

Comments (3)

A small command-line utility to convert paths and pathurls for OSX

One of the notable short comings of the workflow I outlined for converting Final Cut Pro elements into After Effects projects via scripting was the limited path support. That was mainly due to the fact that Final Cut Pro uses a fully qualified path url of the form file://path/to/file and After Effects has an Absolute URI that uses the tilde as a shortcut for the current user’s home directory. So, file://Volumes/MyHD/Users/Dale/Stuff becomes ~/Stuff. Trying to munge all of the contingencies in Javascript is not a pleasant task, and Cocoa has a nice set of methods for dealing with just this situation, including stringByAbbreviatingWithTildeInPath and stringByExpandingTildeInPath.

What I’ve done is written a small Cocoa foundation tool that works on the command line to move between the formats of interest. The tool takes the following switches.

pathconvert -u pathurl
Takes a pathurl of the form file://localhost/Volumes/Storage/Users/Dale/test used by Final Cut XML and converts it to an AbsoluteURI that After Effects will be happy with, including using stringByAbbreviatingWithTildeInPath to resolve directories in the User Home folder, such that the pathurl above becomes ~/test.
pathconvert -f fullpath
Takes a fullpath of the form /Volumes/MyHD/Users/Dale/Test and returns a short cut tilde path when appropriate. The string above would become ~/Test.
pathconvert -t abbreviatedPath
Takes a short cut path of the form ~/Test and returns a full path when appropriate. The string above would become /Volumes/MyHD/Users/Dale/Test.

This utility, combined with system.callSystem() in After Effects 7 will make our work with Final Cut Pro XML a lot more friendly in a scripting environment. Next up is an updated tutorial on working with Final Cut XML and After Effects scripting and more detailed instructions on how to install and use this utility. I wanted to post this now to get feedback from power users and developers on potential problems and gotchas. I’m not much of a c hacker, so I’m enclosing both the XCode project files and a compiled binary. Please send any improvements or ideas to me and I’ll share them here. As always, feedback and improvements to dale(at)creative-workflow-hacks(dot)com.

Compiled Binary and XCode Project files available here

Comments (4)

Stupid Scripting Tricks: Import every Quicktime available

Here’s a fun one. Run this script and it will import every Quicktime on your hard drive or mounted server that After Effects understands. Stupidest hack ever, right? Well yeah, but there is some real gold in this line of the script

mdfind 'kMDItemKind == "QuickTime Movie"'

mdfind is the command line version of Apple’s spotlight technology. Combined with the new Quicktime metadata API and system.callSystem() there’s a lot for a hungry developer to chew on.

The script, osX 10.4(Tiger) and After Effects 7 only (I know, I know)

var myProject = app.project;

var osString = "mdfind 'kMDItemKind == "QuickTime Movie"' | wc -l" ;
var numberOfQTs = system.callSystem(osString);
//After Effects seems to choke when I feed it more than 41 items at a time, so let's use sed to give it 40 to chew on at a time
for(x=1; x < numberOfQTs; x = x + 40){
	var osString = "mdfind 'kMDItemKind == "QuickTime Movie"' | sed -n '" + x + ", " + ( x + 40) + "p'";
	var systemCall = system.callSystem(osString);
	var movArray= systemCall.split("\n");

	for(y=0; y < movArray.length; y++){	
				var my_io = new ImportOptions(new File( movArray[y]));
				var myItem = myProject.importFile(my_io);
				//eat errors

And the downloadable version

followup 5/4/2006 2:30P EST:

So, most folks working in motion graphics have a lot of quicktimes on their system and don't necessarily want to take a long time to import all of them into an After Effects project as a proof of concept ( I told you this was a Stupid Scripting Trick). Therefore, here's a version that imports the first 20 of them with head -n 20 to act as a proof of concept for you busy people .

Here ya go:

You'll need to turn on Allow Scripts to Write Files and Access Network and turn off Enable JavaSript Debugger so we can eat the errors. As in anything that allows write access to your file system, be careful in experimenting with this script.

Comments off

Problems with multi-column output from system.callSystem() in After Effects 7?

I’ve been experimenting with system.callSystem() in After Effects 7. It’s a way to call commands and applications like you would from the command line but from within the After Effects scripting environment and get the output returned to the javascript variable. Works pretty great, but I’ve run into what seems like a bug and offer a small work around

If I call

var systemCall = system.callSystem('ls');

I get a nice alert box with my local directory. If I call

var systemCall = system.callSystem('ls -a');

I get a nice alert box including . entries (which is really just to test using the -a command switch to make sure I can send parameters through system.callSystem()). If i call

var systemCall = system.callSystem('ls -la');

I lock up AE7. I’m guessing it doesn’t like the multi-column output? Because if I pipe the ls -la to awk like so

var systemCall = system.callSystem('ls -la | awk '{print $1}');

I get a nice listing of my directory permissions which is the first column of the ls -la standard output.

So, it looks like the workaround if you freeze After Effects 7 with a system.callSystem() command that ouputs multi column output is to grab each column of interest with something like awk'{print $1}’ where $1 etc. is the column to grab. Not sure if this is a bug or a limitation of the standard output to After Effects. Would love some feedback from anybody that knows for sure.

Comments (2)

Older Posts »