By digitizing your old VHS tapes, you can move them from taking up precious shelf space to more readily available disk space. In this article, I'll show you a hack that lets you archive full-quality digital recordings from EyeTV to offline media, but still play them back easily in EyeTV.
I decided last year to start moving my old VCR tapes to digital storage to save physical space and give me better access to the programs I had taped. I picked up an EyeTV 200 to do the job, and it worked great. I archived a half-dozen or so tapes and realized that I was paying for the high quality of my digitization by eating up disk space. At "standard" quality, the MPEG-2 files that EyeTV creates are about 2 gigabytes per hour, so now I had a second archival problem: how to move the data off of my Mac's hard disk while retaining convenient access to it.
Initially, I figured I'd just burn everything to DVDs with EyeTV's DVD export function, and that'd be it. Unfortunately, closed captioning turned out not to be supported by this process, and I really wanted to preserve the captions. I checked with Elgato Systems, who confirmed that caption exporting wasn't supported. I needed to find an alternative.
Too many EyeTV recordings ...
Examining the EyeTV archive (version 1.8.4) shows that it contains a bunch of oddly named directories, each containing a .mpg file (the actual video) a couple of plist files (.evetvr detailing the recording, and .eyetvp detailing the scheduling of the recording), and an .eyetvi file full of inscrutable binary data.
I first tried copying the data to an external drive and then dragging the .mpg back onto EyeTV for playback. This didn't work. I tried to open the .mpg in QuickTime. That didn't work. Export from EyeTV to H.264 worked (very slowly), but gave me no captions. VLC could play the .mpg files directly, but the caption data wasn't available in the format that VLC wanted, so no captions again.
Obviously I was going to have to find a way to make EyeTV think the data was still there while it was actually somewhere else. At this point, a number of you are probably ahead of me. But for those who aren't, the answer is symbolic links. A symbolic link is a Unix way of putting an entry into a directory that says "The file you want? It's actually over there," and there can be anywhere, including another physical disk. Thanks to OS X's Unix underpinnings, I could at least try this option. The question at this point was, would EyeTV happily follow the link to the remote file, or would it get confused and complain?
I started off by backing up my whole EyeTV Archive to an external FireWire hard disk via drag and drop. Once I had a safe backup of the archive, I started experimenting with the data. I found that moving a complete recording directory (with the MPEG-2 file and the supporting EyeTV files) to another disk and symlinking it back to the original EyeTV Archive allowed EyeTV to play the recording back just as if it were in its original location. Quitting EyeTV and unmounting the disk, then restarting EyeTV effectively removed the program from the archive--it no longer showed when the Programs window was opened. Remounting the disk and restarting EyeTV brought it back again. Perfect. (I also tried using an OS X alias instead of a symlink. This worked too, but EyeTV still thought the program was there and showed it in the Programs window, even though it wasn't playable, which seemed less nice and more prone to confusion on my part: "do I have the right disk in the drive or not?")
I made these symlinked folders like this:
ls ~/Library/EyeTV\ Archive
mv ~/Library/EyeTV\ Archive/somename ~/Documents/somename
ln -s /Volumes/External\ Backup/EyeTV\ Archive/somename ~/Library/EyeTV\ Archive/somename
This process moves one complete EyeTV program (the MPEG-2 stream and the support files) out of the EyeTV archive, and sets up a symbolic link from where it used to be to the copy on the external hard disk.
|
Related Reading iMovie HD & iDVD 5: The Missing Manual |
|
I looked at doing this by hand and it seemed likely that if I tried to do it that way, I'd eventually mess up recordings and have to re-record them. It seemed like I should be able to write a small AppleScript program to duplicate the above method; I discovered, however, that the process was actually fairly difficult to do in AppleScript, despite the fact that EyeTV is nicely scriptable. The problem occurs because we have to manipulate files both as Finder entities (paths and aliases) and as Unix entities (directories and symlinks). AppleScript does OK with the Finder side, but it was necessary to use do shell script in various places to get the Unix part to work. Plus, it was also necessary to scan the EyeTV Archive once in EyeTV mode to find all of the recordings, and then do it again in the Finder to find just the real folders (without any already-existing symlinks) so we didn't try to archive stuff that'd already been archived.
The script here handles the basic workflow: find the actual recordings, split them up into DVD-sized chunks, copy them to a user-selected volume, back up the recordings for safety, and then create symlinks for them in the EyeTV Archive, repeating as necessary until we've finished clearing out the archive. Here's the application running.

After some chugging, the application puts up a dialog like this that shows a list of programs (by their real names) that will fit on a single DVD. You can click OK to copy these, or Cancel to skip this set and go to the next set.

Once you've selected the set of recordings, the program prompts you for the name of the DVD to use for the backup. Select a disk here and click OK to proceed (Cancel stops the script).

The Finder then copies the files to the DVD.

Once the copy's done, the program tells you to burn the DVD (you'll have to do this yourself as a separate step), and the insert a new one and name it (so it can be selected in the disk list and symlinked properly when the next set of recordings is backed up).
This is plain old AppleScript, so the user interaction is minimal. Error handling is also minimal, just enough to get this to work and trap the most egregious errors. (I'm working on a much more bulletproof AppleScript Studio version of this which will be available here once it's complete. In the meantime, the proof-of-concept version is available there now.)
For safety, the offloader does not delete the recordings from your hard disk. Instead, it moves them to your Documents folder. Once you've verified that your DVD works OK with EyeTV, you can drag the recordings to the Trash. If there's any problem, you can restore them to your EyeTV Archive simply by dragging them back into it and replacing the "copies" that are there (the symlinks).
|
The majority of what the script does is to convert one way of talking about folders to another. EyeTV refers to the folders where the recordings are stored as a "unique ID" of a "program." This is a floating point number (like 1.28438934), which has to be translated into the hexadecimal equivalent to find the directory name that corresponds to it in the EyeTV archive (I did this the simple way by passing it to Perl and having it do the conversion in a simple one-line program):
tell application "EyeTV"
set thePrograms to programs
set theRepository to repository url as string
repeat with theProgram in thePrograms
set theUniqueID to unique ID of theProgram
set theDirName to (do shell script "perl -e 'printf \"%016x\"," & theUniqueID & "'")
set thePath to theRepository & theDirName
set thePOSIXPath to (POSIX path of thePath)
...
At this point, I've got the POSIX path (like /Users/mcmahon/Library/EyeTV/000000007839af8) which will let me do the symbolic link later. I save this along with the program name, episode, etc., and then scan the EyeTV archive directory directly with the Finder, looking for the items that are folders (if we ran this program before, it's created symlinks which we want to skip). Now we scan the contents of each one of these directories, adding up the sizes of the files to see if we're still under the magic 4.34GB that will fit on a DVD created via the Finder.
Once we've got a DVD-full, we use chose from list to display the list of programs we're going to back up, and then use code like this to copy the files to the DVD:
tell application "Finder"
activate
open disk theDisk
end tell
repeat with i from 1 to length of theFolders
set theFolder to item i of theFolders
set sourceFolder to alias (theFolder & ":")
set targetFolder to alias (theDisk & ":")
tell application "Finder"
with timeout of (10 * minutes) seconds
duplicate folder sourceFolder to targetFolder replacing yes
end timeout
end tell
end repeat
Notice here that we have to talk about the folders as aliases. For safety, we then move the folders we just backed up to the Documents folder (talking about them as aliases again), and then do the work of actually setting up the symbolic links to the folders on the DVD:
-- the directory in the EyeTV Archive we're linking to the DVD
set targetPOSIXPath to escapeSpaces(thePOSIXPath)
-- use the disk name and directory name to create the name of the file on the backup
set sourcePOSIXPath to "/Volumes/" & escapeSpaces(theDVD) & "/" & (theDirName)
-- Symlink the DVD directory into the archive
do shell script "ln -s " & sourcePOSIXPath & " " & targetPOSIXPath
Now we need to talk about them as files to the (Unix) shell, which means that the folder names can't contain any spaces; these confuse the shell into thinking that the filename ends at the space, which we don't want. The escapeSpaces subroutine makes sure that any spaces in the filename are escaped with a backslash (\) in front of them to keep the shell from getting confused.
I've simplified these excerpts for tutorial purposes; the actual program builds a big list of lists that contains all of the information from the EyeTV Archive and then spends most of the rest of the time filtering it and extracting data out of it.
This file archiving is a time-consuming process, and it will take some time to back up a large amount of video. But in the end, you've got backups of your recordings, with captioning intact, and disk space to record more.
Author's note: Elgato just released EyeTV 2.0. I haven't purchased this version yet, so the information in this article is verifiable for the previous version, EyeTV 1.8.4. But I don't see any reason why Elgato would change the archive structure for this update. If you have version 2 and can test these techniques, please post a comment with your outcome.
Joe McMahon is a test automation architect for Yahoo! Search. He has been working with Macs since the 512K got an 800K disk drive.
Return to the Mac DevCenter
Copyright © 2009 O'Reilly Media, Inc.