TIVO video extraction and re-encoding using Linux

This document is for people who have:

A Series 1 standalone Tivo running at least 3.0-01-1-000
Installed the network card (wired or wireless)
Got the Tivo Web software working (I use v1.9.4)
Installed the tivoftpd FTP daemon
Mplayer and mencoder for Linux. Don't even think about using a different player/encoder.

Now you're ready to install the extraction and encoding scripts and programs.

First grab this handy tarball which contains all the programs and scripts you'll need on the Tivo and your Linux box.

Basic instructions, copy things to these places:

On the tivo, run: mkdir /var/hack/mfs and copy these files to their proper destinations:
mfs_stream      -> tivo:/var/hack/mfs/mfs_stream
readme.txt      -> tivo:/var/hack/mfs/readme.txt
tyhttpd         -> tivo:/var/hack/mfs/tyhttpd
mfsstream.cfg   -> tivo:/var/hack/tivoweb-tcl/modules/mfsstream.cfg
mfsstream.itcl  -> tivo:/var/hack/tivoweb-tcl/modules/mfsstream.itcl
mfscat.cfg      -> tivo:/var/hack/tivoweb-tcl/modules/mfscat.cfg
mfscat.itcl     -> tivo:/var/hack/tivoweb-tcl/modules/mfscat.itcl
Edit mfsstream.cfg, mfscat.cfg, make sure they know the correct path to the mfs_stream binary.

Run the tyhttpd (it will serve out the MFS streams) like this:
/var/hack/mfs/tyhttpd 2000 2 &  (2000 is the port, 2 is the # of httpds)
Restart your tivoweb. Make sure mfs stream menu option shows up (ignore the MFS cat module for now, it's just MFS stream with the HTML stripped out, it's useful for scripting grabs from the tivo), and make sure when you click on the stream name, your browser tries to download a .ty file.

You can actually play the .ty files directly, and transcode them directly to other formats using "Tivo mplayer" (and mencoder) from http://tivo-mplayer.sourceforge.net/ and if that doesn't tickle your tivo, you can even play/transcode streams directly from the tivo without downloading the .ty file (see vstreamer). But let's get back to basics for now.

Now, on the linux side...this is how to work with the script my pal Bob made, it's a good starting point and his script has many cool features plus is really easy to use. It knows which shows you've already downloaded and encoded, and won't step on its own toes even if you're furiously running it from cron.

Now install the Linux binaries and scripts:
*.sh, vsplitmux2c -> /usr/local/wherever
Make sure you can pull the "stored programs" list off the tivo:
        curl http://tivo/mfscat > ~/tv.list
Edit grabber.sh, encoder.sh, convertmpg.sh to set the paths for where on the filesystem you want your streaming/encoding to happen.
        grabber.sh simpsons
...will grab all the simpsons and convert to standard MPEG2 video,
playable with mplayer etc, or if you want to make a DVD.
        encoder.sh
...will run through all recent grabs and encode them to MPEG4 at 400x300 resolution. You'll want to edit the cropping to match your TIVO, and you may want a different resolution/bitrate. With my (analog) cable-TV, I tend to record at "Best Quality" on the tivo. A dtivo (Direct-TV tivo unit) is best because the MPEG-2 stream comes through to you without recompression.

After running the grabber and the encoder, you will end up with nicely encoded (and I mean nicely!) MPEG4 video files with decent categorization in your output directory:
./Assignment Discovery:
Assignment Discovery-Blue Planet: Seas of Life: Frozen Seas.avi
Assignment Discovery-Blue Planet: Seas of Life: Seasonal Seas.avi

./Star Trek:
Star Trek-Elaan of Troyius.avi
Star Trek-The Enterprise Incident.avi
Star Trek-The Gamesters of Triskelion.avi

./The Simpsons:
The Simpsons-Brake My Wife, Please.avi
The Simpsons-Grandpa vs. Sexual Inadequacy.avi
The Simpsons-Marge in Chains.avi
The Simpsons-Mother Simpson.avi
The Simpsons-The Strong Arms of the Ma.avi
Contrary to what you might have heard, editing commercials out of MPEG4 AVI files on Linux is a piece of cake.

Get a copy of winex, I use version 2.2b which is old but works fine.
Download and install the Most recent DIVX codec for Windows on your Linux box using winex.
Download and install VirtualDub for Windows on your Linux box using winex.

Run VirtualDub with /usr/bin/winex "C:\\Program Files\\VirtualDub\\VirtualDub.exe" and make sure you select "direct stream copy" in the "options" menu or else VD will try to re-encode your video stream which will make you sad.

Tip: hold down shift when you use the drag-bar in VD and it will snap to keyframes. VD will cut on keyframes and your video will look awesome.

Big ups to my secret h4x0r pal "B0b" from the UK for his hard core scripts and tivo hacking skillz.