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.
austin said
I’ve been hard coding my paths at the top of the scripts. I haven’t done a lot of back and forth with FCP – what are the contingencies you were seeing? I’m curious why a text replace of the tilde in Js wouldn’t work…
(PS – great site!)
Dale said
Hey Austin,
Thanks for the encouraging words…
As far as the Javascript path munging…
Final Cut XML has an element called <pathurl> that contains a macintosh file path url, that will usually begin with file://localhost, so the first order of business is to strip that away. Then depending on which user is logged in, we need to look for /Users/Dale or some such, if there is Users/SomeOtherUser we have to do some indexOf switching and we are still just guessing as to who is the local user. If not, we pass in /Volumes/Path/To/File. As you can see, it’s rather messy. With this it’s
var afterEffectsPath = system.callSystem(‘pathconvert -u file://localhost/Volumes/Storage/Users/Dale/Test/myFile.mov’);
returns
~/Test/myFile.mov
I like this one better. I’ll follow up with more info later.
Best,
Dale
austin said
Your utility is definitely cleaner and nicer.
Most of our production machines have the same user (eg ~/gfx) and our projects are all on the server(/Volumes/MyServer/Projects) so it hasn’t been a big issue so far.
Plus, having the script break when the file is not where the script expects it is an evil way to encourage people to keep their projects in the standard places on the server. 🙂
Dale said
Austin…
It’s definitely an advantage when you can hard code locations, etc. In fact in my early explorations of the FCP To AE scripts much of the scripts were based on my locations and things I was doing in production at Primal Screen. Now I’m trying to make them more general and usable in different production situations.
Dale