- Introduction
- Who This is For
- Background
- ReTimer for Final Cut Pro
- ReTimer as an Automation Platform
- Javascript and E4X
- Notes and Limitations
- Download the program
- Additional Resources
Introduction
Computers` strongest advantage is their ability to execute custom code, allowing to automate repetitive tasks. Ironically, this is the one functionality that has been missing from all major editing systems. Avid, Final Cut, and Premiere - none of those programs have scripting or macro capabilities to this day.
This article introduces a JavaScript-based XML parser for Final Cut Pro, which is available along with its source code. It discusses using XML parsing as an accessible platform to manipulate bins and timelines in a programmatic way, and its potential for automating editorial tasks in lieu of built-in NLE scripting.
Who This is For
ReTimer itself can be used by anyone with intermediate knowledge of Final Cut Pro. As an automation platform, it is intended for any post-production staff that performs the roles of assistant editor, online editor, or facility engineer. It was written in JavaScript, with the intention of being relatively accessible to non-programmers. It does, however, require scripting knowledge and an aptitude for coding.
Background
About a year ago I was onlining a feature documentary which contained a wide variety of footage. Sources included film, 3/4", digitized archives, and contemporary HD footage in 60p, 30i, 24p, and 25p. The film was offlined in SD 30i, but after weighing the sources and the distribution options it was decided to master in 60p. However, FCP had no ability to modify the time base of an existing sequence. Multiple attempts to "copy and paste" the sequence resulted in completely mangled cuts. Existing tools, from Automatic Duck to Avid Media Composer, could not perform a workable conversion. I ended up developing new code myself to address this major hole in FCP's functionality.
ReTimer for Final Cut Pro
This program, written in Javascript/E4X, parses a Final Cut Pro Sequence and converts its frame rate. It takes an XML file from FCP and returns a compliant XML file to be imported back into FCP.
Functionality included with this release:
- Convert timebases between 24, 25, 30, and 60fps and their fractional counterparts.
- Batch search and replace clips by name (both file name and clip name).
- Selective resizing: find all images of a certain type (JPG or TIF), and if they are smaller than a certain size, scale them to fit the canvas` width.
ReTimer as an Automation Platform
The functionality of ReTimer is fairly specific by design. If you need generic functionality, chances are that your NLE already has it. The greater potential of this code is to serve as a platform to create your own code and achieve whatever tasks would help you in your work. Some examples include:
- The documentary included footage in NTSC that was a bad transfer from PAL (broken cadence). It was used frequently throughout the film. The production obtained a proper PAL copy for the online, however its metadata was mismatched in almost every way. I wrote an extension for ReTimer that found every affected clip, replaced it with the PAL version, compensated for the timecode differences, and set the scaling and aspect ratio to just the right values.
- Batch-processing titles can be particularly tedious. You could write a function to correct a spelling error in 30 out of 500 subtitles, or apply some other change to a subset of text generators that's not readily isolated in the sequence.
- Simple mathematical manipulations need to be done manually in the NLE, but are easy to perform in a script. For example, "double the scaling of every green clip" or "fit to width".
The more tedious or repetitive your work, the more you would benefit from scripting and automation.
There are other tools in the market that manipulate XML, but by and large they are commercial products and their source code is not available. They excel at doing the purpose for which they were created, but cannot be customized for automating production and facility-specific tasks.
JavaScript and E4X
This program was developed in JavaScript for a wide range of reasons:
- JavaScript is a straightforward and accessible language, providing flexibility and the power of object-oriented syntax while enjoying looser programming requirements than C++. As said, it is my intention for post-production staff to modify the code, and therefore accessibility took precedence over ideal coding practices at times.
- JavaScript uses human-readable code, as opposed to compiled binary code.
- JavaScript is used in abundance on the internet, which also means there are numerous code examples, learning resources, and user forums for help.
- JavaScript is client-sided, which means the code runs locally on your machine. No server is required to execute your code and it doesn't "phone home." An internet connection isn't necessary either.
- JavaScript was born as an extension of HTML, and so was XML. If you learn web scripting you're already learning the tools to manipulate XML.
- ReTimer utilizes E4X ("ECMAScript for XML"), a JavaScript extension that adds native XML support to the language, allowing easy access to the DOM. For example, the code to set an "in" point for a sequence is fcpxml.sequence.in = 240;
- The nearest sibling of NLE scripting is available in Adobe Creative Suite, and also uses JavaScript. Learning the language will benefit your scripting abilities in Adobe products.
Packaging the program in an HTML page was a side-effect of the writing process, but proved an interesting test case. All the program's elements - code, UI, and resources - are embedded in one HTML file. Even the logo is encoded using base64.
Notes and Limitations:
- Since JavaScript is mostly used online, browsers run it in a "sandbox" and place restrictions on what it can do. The main implication is a restriction on file operations - the code can't just access files on your computer. It's possible to launch your browser with the safety restrictions disabled, but I opted for a safer way: the XML you wish to process simply needs to reside in the same folder as the code, and you save the processed XML using the browser's "save as" command.
Notice that these restrictions are imposed by web browsers and are not a property of JavaScript. Other implementations, such as After Effects scripting, have their own custom libraries that are optimized for the needs of their users. I hope that if we see scripting in Premiere Pro it will utilize the same mechanism. - Unfortunately E4X wasn't widely implemented and future support is uncertain. I recommend Firefox version 3 to 15 to run the program properly. Future versions may drop the need for E4X or utilize a different platform altogether. I'd be happy to see ReTimer ported to AppleScript. If you're interested, check out XML Tools Scripting Addition and JavaScript OSA by Late Night Software.
- This is an initial release, and the program is offered on a free, as-is basis with no guarantees whatsoever. If you need help post a comment and I'll try to assist, but I welcome you to tinker with the source code to make it fit your specific needs.
Download the Program
To download ReTimer, right-click here and choose "Save As."
Additional Resources
If you have needs that could be automated, check with those companies to see if they already developed a tool that'd help you:
Intelligent Assistance
XmiL
Spherico
Digital Heaven
If you're interested in using XML to automate tasks in Final Cut Pro X, or adapt ReTimer for FCPX, see this introduction by Jonathan Tyrrell:
http://postpost.tv/2011/09/fcpxml/
XML Tools AppleScript Scripting Addition by Late Night Software.
http://www.latenightsw.com/freeware/XMLTools2/index.html
FCP7 XML Interchange Format
http://developer.apple.com/appleapplications/download/finalcutpro_xml.pdf
FCP X XML Format
http://developer.apple.com/library/mac/documentation/FinalCutProX/Reference/FinalCutProXXMLFormat/FinalCutProXXMLFormat.pdf


Leave a comment
JavaScript required.
If you're having trouble posting comments, clear your browser's cache and make sure you have JavaScript enabled.