Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Getting Non-Apple video formats into Spotlight System
The availability of software like Perian and Flip4Mac that make non-Apple video formats available to QuickTime and players like VLC and MPlayer means that many of us have files in formats like Flash and Windows Media Video that Mac OS X's Spotlight metadata subsystem recognizes as 'Movies' but for which it cannot determine video-specific metadata like dimensions, codecs, duration, and bitrate. It is possible to fix this in Leopard by duplicating and modifying a piece of the base OS, but in Snow Leopard it takes a bit more effort.

(This hint is also useful for 10.5 and probably 10.4, but 10.6 adds a special twist.)

Spotlight indexing relies on software components called 'metadata importers' to get format-specific details about various file types, which are packaged as bundles with the extension .mdimporter.

The standard set of these lives in /System/Library/Spotlight, with add-ons installed within application bundles, /Library/Spotlight, or ~/Library/Spotlight.

The key to getting the most detailed metadata into Spotlight is to have an importer that can analyze the file or knows how to get another program to do so and which lists the specific 'Universal Type Identifier' (UTI) for the file's format in its Info.plist file, which is inside its Contents directory, e.g. /System/Library/Spotlight/CoreMedia.mdimporter/Contents/Info.plist. Those files are Apple property lists, usually in XML text format.

In 10.5 the standard QuickTime importer appears to be a simplistic shim that hands any file given to it to QuickTime for analysis, so you can hack in support for additional movie types (assuming you have Perian and Flip4Mac installed) rather easily:
  • Copy the whole QT importer(in 10.5) to a suitable location:
    cp -rp /System/Library/Spotlight/QuickTime.mdimporter /Library/Spotlight/MoreMovies.mdimporter
  • Use the Apple Property List Editor from the Developer Tools package (or any text editor if you are comfortable with XML) to add UTI's to the 'Document Content Type UTIs' array (if you use a text editor, this is the array with the key "LSItemContentTypes") in /Library/Spotlight/MoreMovies.mdimporter/Contents/Info.plist. To catch Flash video and most flavors of Windows video, the UTI's to add are:
    public.movie
    public.avi
    com.microsoft.windows-media-wmv
    com.microsoft.advanced-systems-format
    org.perian.flash-video
    com.adobe.flash.video
  • Use the command line interface to Spotlight to force it to rescan movie files:
    mdimport -r /Library/Spotlight/MoreMovies.mdimporter
    That command will return silently and quickly, after it triggers the system to fire off a background process that will scan your system for all relevant files. In a few minutes, you will be able to do a "Get Info" on non-Apple movie files and see useful metadata in the More Info section.


For 10.6, this does not work. Apple moved video metadata importing for its own formats to a new 'CoreMedia' importer, and adding alien UTI's to it does not work. Do not despair!
  • If you have a copy of 10.5 available there is an arcane workaround. You can copy the QuickTime importer bundle from 10.5 to the 10.6 system and modify Info.plist as described above, but because 10.6 uses 64-bit code wherever possible and the programs that use metadata importers are all 64-bit, the 32-bit code of the QuickTime importer from 10.5 can't be used automatically. However, you can work it in a semi-manual way. Instead of putting the modified importer bundle in /Library/Spotlight, put it somewhere that the system won't try to use it automatically: your home directory. Then you can get the metadata for files imported by forcing mdimport to run in 32-bit mode and specifying the importer and files to import:
    arch -i386 mdimport -g ~/MoreMovies.mdimporter ~/Downloads/*.flv
    arch -i386 mdimport -g ~/MoreMovies.mdimporter ~/Downloads/*.wmv
If you are comfortable with shell scripting and cron (or launchd, for non-dinosaurs) you can probably think up ways to adapt those examples and make it almost seem like the importing is as automagical as it is with .mov files.

[crarko adds: I haven't tested this one. This is a reasonably complex procedure so proceed carefully. For example note that the standalone QuickTime importer does not exist in 10.6 and, as the author indicates, needs to be copied from 10.5 and then modified. Still, if you do mixed-format video work I can see where this would come in quite handy.]
    •    
  • Currently 2.57 / 5
  You rated: 1 / 5 (14 votes cast)
 
[6,754 views]  

Getting Non-Apple video formats into Spotlight | 0 comments | Create New Account
Click here to return to the 'Getting Non-Apple video formats into Spotlight' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.