Hacked!
Hey Everybody, My blog was hacked and not in a Creative Workflow way, so things are in a little disarray after restoring and not being sure what files were compromised. It may take a while to sort things out so thanks for your patience. Dale
Hey Everybody, My blog was hacked and not in a Creative Workflow way, so things are in a little disarray after restoring and not being sure what files were compromised. It may take a while to sort things out so thanks for your patience. Dale
If you updated to the latest version of Quicktime you lost some of your export options like Sorenson (You take the good with the bad with the beneficent dictatorship that is Apple UI design). To get it back…
Thanks Brandon
Looks like I’m a little late to the party, but I’m catching up with some great posts at omino.com. I’ve always admired David Van Brink’s qt_tools project, A great open source command-line set of tools for dealing with Quicktime, and it looks like he’s now sharing more quick hits of his pixel, motion and scripting explorations. Very fun David.
Last time, we talked about using a Socket Object in After Effects CS3 to parse a data feed with E4X XML parsing. There are a lot of useful workflow operations I can think of that could make use of data feeds, but After Effects is a visual medium, so let’s do something visual, let’s import a set of flickr photos matching a tag. This is a proof of concept script, and before you plunge into experimenting you should check the terms of service of the web feed provider and respect the use of images you download. That said, let’s take a look at some code.
Read the rest of this entry »
I had an email conversation with Matt, who wanted to fetch some xml to play with the new E4X XML parsing in AE CS3. We’re still waiting for the ExtendScript HttpConnection Object to show up in After Effects, but we do have access to the Socket Object. The Socket Object is a little low level, but if you are using web feeds and don’t need authentication it’s actually pretty easy.
This code segment outlines the basics.
webConnect = new Socket;
response = new String;
if(webConnect.open("feeds.feedburner.com:80","UTF-8")) {
webConnect.write('GET /current/currentpicks?format=xml HTTP/1.0nn');
response = webConnect.read(100000);
response = response.toString();
var xmlStart = response.indexOf("<?xml");
var xmlString = response.substring(xmlStart, response.length);
alert(xmlString)
webConnect.close();
} else {
alert (""unable to open webConnect via Socket"")
}
We open a Socket and connect to, in this case, a feedburner feed. We use the read() method to read in the XML, and since the Socket object includes the header we use indexOf to find the beginning of the XML and substring to read to the end of the line.
A couple of gotchas in the code. In this case the header tells us the document encoding is utf-8 so we explicity set it with
webConnect.open("feeds.feedburner.com:80","UTF-8")
Also, when Matt and I were initially exploring this we were just getting the header. It looks like a GET request with
response = webConnect.read()
allows a block response, and the later content was going off into the ether, If we used
response = webConnect.read(100000);
with a sufficiently large number to include all of the XML we got all of the contents of the XML file. This seems like a really bad idea, since we’ll never know the size of the XML file unless we munge some headers and setting it arbitrarily high also seems like a bad idea. Can someone who’s spent more time with the Socket object leave a comment or email me on how to handle the block response or alternatives to setting a big count for the read() method? I’d appreciate it.
Anyway, that’s the basic idea. You’d then parse the xmlString variable and do fun stuff with it. One heads up, the sample above includes namespaces, so be sure to read the section on namespaces in the Scripting Guide.
Just a quick heads up that I’ve decided to focus my efforts on FCPToAE and related tools to the CS3 Suite only. With a strong subset of ECMA-357 (E4X) (pdf link) parsing in Extendscript 2, it doesn’t make a lot of sense to keep inventing workarounds to FCP-XML parsing. I do plan on incorporating bug fixes to the scripting side of the equation to the AE 7 app, so it’ll stay feature compliant to the current state, but I won’t be updating new features.
This will definitely make things a lot easier to develop tools, and it opens up a whole new slew of possibilites for Web 2.0 mashup tools and explorations when combined with After Effects Socket or new HttpConnection support. kuler explorer anyone? If you’re a scripter, you owe it to yourself to check out the ExtendScript Toolkit (ESTK) 2.0 there are a lot of features that sort of “hide” in Extendscript that aren’t obvious in the After Effects CS3 scripting guide(pdf link).
More experimentation with sampleImage(). This one relies on this expression.
target = thisComp.layer("layerToSample.mov");
samples = new Array();
var spacing = 10;
var w = target.width / spacing ;
var layerOrder = 1;
var h = 10 * layerOrder;
letters = " .,:!-+=;iot76x0s&8%#@$";
for(x= 0; x < w; x++){
samples[x] = target.sampleImage([x* spacing ,h],[spacing , spacing], false, time);
}
var string = '';
for(z = 0; z < samples.length; z++){
var y = Math.round((0.299 * samples[z][0] + 0.587 * samples[z][1] + 0.114* samples[z][2]) * 100)/ 4;
string = string + letters.substring(y,y + 1);
}
We loop through the row of pixels and place the sampled RGB pixels in the samples array, convert the RGB samples to YUV and grab the Y or brightness value for comparison against a rough gradient of ASCII values. For best results, use a monospace font to retain proper spacing. A more complete script/expression and breakdown to come.
sampleImage() is a new layer method expression introduced in After Effects CS3 that allows you to access a layer’s color pixel data. Combined with sophisticated particle systems like Particular, I think we’re likely to see some really interesting designer driven explorations a la Processing, but with more of a tinkering, let’s try things out approach.
I’ll have more scripts, and automated stuff as I explore further, but until then you might want to take a look at the reference and examples that Dan Ebberts is posting at the brilliant MotionScript.com
I’ve never spent much time with Apple’s Automator technology. Which is a little strange, considering how interested I am in automation and workflow technologies. I think some of it is a sense that it seems inaccessible, it doesn’t seem clear how to make things generalizable enough to be useful, and at least part of it is my aversion to Applescript as a scripting language That said, it’s clear that there is a lot of power available with Automator and I’ve started to dip my toe in the water and seeing If I can learn a few things and maybe create something useful.
This is the first fruit of my experimentation. I often need to make a tape log of a sequence in Final Cut Pro, and a quick way to get the sequence details into a text file could be useful. The most approachable way to address the problem seems to be with markers. You can store all of the values I need for a tape log in a marker – item number, name, description, length and the starting timecode. So, that’s how we’ll approach it.
Apple posted some sample code demonstrating how to extract timecode from Quicktime files using the objective-c based QTKit only dropping down into the low level C API when “absolutely required”.
I’ve found myself deep into the Quicktime API before and the modernization of the Quicktime architecture can’t come too soon. Unfortunately, digging deeper into the sample code, it’s clear that it’s going to be slow-sledding before we get NSString *timeCodeTime = [movie tcTime]; or some such. Anyway, it’s good to have this info from the definitive source, it’s taken a bit of research to find before now.