Perhaps this should go on the other blog too, but what the heck.
I’m making available the source for the QTInfo project which does a lot of the heavy lifting on the backend of Media Mill. This was my solution to break down the wall between PHP and Quicktime. It’s a RealBasic project (rb2006r3) and makes use of the MonkeyBread plugins.
I wanted to note a few things which make the project interesting. Follow the jump for extreme geek content.
First off, it’s a console application. After you build it in RB, you’ll get a .app bundle, but what you really want is the binary executable named QTInfo in Contents/MacOS. Run that from the command line, and you’ll get some usage information.
The next interesting thing is that it’s not really a console application. (Hu?) You see, console applications in OSX can’t access the Quicktime API, because it lives up in the Quartz neighborhood. So, this is an application that looks like it’s a console app, but is actually talking to QT.
Because it’s not really a console app, I have to write output to the terminal using System.debuglog. This means that, even though you see the output in your terminal, the output is really being written to stderr instead of stdout. You can always redirect the stderr to stdout by appending 2>&1 to the end of the command line.
Anyways, so what does it do? There are two switches, –getinfo and –getthumbnail. Getinfo will give you back the filesize (necessary for me because PHP can’t filesize() files over 2gb), the framecount, the horizontal resolution, the vertical resolution and the framerate. Read the code for a discussion on getting the framerate – I try my best to get an accurate rate, but some files are very confusing.
The –getthumbnail switch takes in information about whether the video is anamorphic or not, how big you want the thumbnail to be, and optionally where in the video the thumbnail should come from. By default, it’ll fetch a frame 1/3rd of the way into the video. The frame gets written (as a jpeg) to /tmp, and QTInfo returns the filename.
Video names must be specified with a complete path. It will also intentionally fail on MPEG-1 files and text files. You could turn that off in the isMovie() method.
Obviously it’s not a full featured application – it’s just enough to do what I need it to do – verify videos, get metadata, and generate thumbnails. But perhaps it will be a useful starting point for someone else.