TiVo to SVCD

Warning: (25 May 2009) I've not updated this page in six years. My Series 1 TiVo died a few years ago; before it did, I had replaced it with MythTV. I'm pretty sure most of this doesn't apply to Series 2 and newer TiVos, and in any case TiVo has finally provided a way to rip video from its newer boxes anyway, so you don't need to jump through these hoops. Finally, you probably really want to burn your TV shows to DVD instead of SVCD; at the time I wrote this, DVD recording was (at best) in its infancy. With all that said, if you're still running a Series 1 TiVo (maybe you, like me, paid for the lifetime subscription) and want to yank video off of it, keep reading. I've checked the links and fixed the ones that didn't work.

This is supposed to be impossible. :-) With the right hardware and software, you can grab a recording off of your TiVo personal video recorder, crunch it down, and fit it on one or two CDs that you can play back on your computer or in many DVD players. Hardware and software are now available that make this possible. It's not particularly easy or 100% foolproof, but it works.

TiVo video is recorded at 2/3 D1 (480x480) resolution at 30000/1001 frames per second with constant-bitrate MPEG-2 at one of four bitrates:

Setting Bitrate
Best 5.8 Mbps
High 3.5 Mbps
Medium 2.6 Mbps
Basic 1.47 Mbps

Regardless of video bitrate, audio is sampled at 32 kHz and always recorded with constant-bitrate MPEG-1 Layer 2 at 192 kbps. The following changes need to be made to the video to record it to Super Video CD (SVCD):

While we're at it, we might as well snip out the commercials. Less material to encode will also yield better quality for what gets kept.

With that said, here's what you'll need to save your favorite shows to SVCD:

Here's the software you'll need to rip the video. I have a package of binaries to install on your TiVo and some software that you'll run under one of the NT-derived versions of Windows...preferably Win2K, but WinXP should also work and NT 4 might work. The DOS-derived versions of Windows (Win9x and WinMe) are unsuitable for TiVo extraction due to the large files (over 2 GB) that you're likely to create during extraction and/or editing.

Here's the software you'll need to edit, compress, and burn the video. All of this stuff runs under Windows. You might be able to find comparable apps for Linux, MacOS, or whatever, but this is what I use:

Ripping Video from the TiVo

Once all the software and hardware is installed, start your web browser and bring up TivoWeb (it'll be at http://your-TiVo's-IP-address). You should see something like this:

TivoWeb homepage

There's plenty of stuff to fool around with in here (I like to access it remotely through an SSH tunnel to record shows I just heard about), but for now we'll use it to get stream IDs. Click "User Interface."

TivoWeb UI

To get a list of what's currently saved on your TiVo, click "Now Showing."

TivoWeb Now Showing

Pick a show and click on its episode name (under the Episode heading, not the Program heading)...it might say "Not an Episode" or "No Episode Title" if it's not a regular series with named episodes.

TivoWeb listing for an Iron Chef episode

If you scroll down a bit, you'll see a line marked "TyStream" with a bunch of numbers after it. (I've highlighted them in this example.) These are stream IDs that you'll need to extract this show.

With stream IDs in hand, pop open a couple of command-prompt windows (Start->Run...punch in "cmd" and hit Enter). In one of these, telnet to your TiVo (key in "telnet your-TiVo's-IP-address" and hit Enter). You should end up at a shell prompt on your TiVo, which looks something like this:

TiVo shell prompt

In your other command-prompt window, change to the directory where you want to receive the video. Once you're there, start nc (that's short for netcat) with an incantation similar to this:

nc -l -p 1200 >show-name.ty

Press Enter and your computer is ready to receive. This tells nc to listen for incoming traffic on TCP port 1200. We will send the tyStream from the TiVo to this port. ".ty" is the extension for a tyStream. If you want spaces in the filename, you should probably put quotes around it, like this:

receive window

Going back to the first command-prompt window (the telnet session to your TiVo), we will pipe the output of mfs_stream into nc. Use something like this:

mfs_stream -s stream-ids | nc -n -w 15 your-PC's-IP-address 1200

In our example, we'd have something like this:

transmit window

Hit Enter and the file will start copying from your TiVo to your computer:

transmitting

This process will take a while...with best-quality streams through a TiVoNET, it'll take about as long to send the file as it did to record it. Recording at lower quality and/or using a TurboNET (I really should get one of those :-) ) will speed things up. The completed file will be fairly large...1 hour of best-quality video will take about 2.5-2.6 GB. Since the maximum filesize on a FAT16 or FAT32 partition is 2 GB, you should make sure you extract to an NTFS partition.

Once the process is complete (when the TiVo returns to its "bash-2.02#" prompt and your other command window goes back to its prompt), log out of your TiVo by pressing Control-D. That window should go back to a command prompt. You can close both windows now.

Now that we have a tyStream sitting on your computer, use TyTool to convert the stream file into MPEG video and audio streams. Start TyTool, select "Process File..." from the File menu, find your tyStream, and double-click on it. It should start grinding away at your file:

processing with TyTool

When TyTool is done, close out of it and go to the directory where you stored your tyStream. You should find three new files alongside it:

/files/tivo2svcd created by TyTool

The file with the .m2v extension is an MPEG-2 video stream, the file with the .m2a extension is an MPEG-1 Layer 2 audio stream, and the text file is a log of everything TyTool did to the file. Open the text file in Notepad...toward the end of the text file, there should be a line that looks something like this:

A/V Sync Offset: 0ms (i.e. plays 0ms early!)

Make a note of the first number (which may be positive or negative)...we'll need it to make the audio and video sync up in the Avisynth script.

Editing Video

Load the .m2v file into DVD2AVI with File->Open. Select File->Save Project and save as show-name.d2v.

Open a command-prompt window, change to the directory where the files are located, and use LAME to convert the .m2a file to a WAV:

lame --mp2input --decode show-name.ty.m2a show-name.wav

You should now have show-name.d2v and show-name.wav. Create a new text file, but name it show-name.avs (Explorer will complain about your changing the extension; ignore it). Open show-name.avs in Notepad and enter this minimal Avisynth script:

vid=MPEG2Source("show-name.d2v")
aud=WAVSource("show-name.wav")
AudioDub(vid,aud)
DelayAudio(audio-delay)
src=ResampleAudio(44100)

src

audio-delay is the number you got from TyTool, divided by 1000 (to convert from milliseconds to seconds). Note that we're merging the audio and video together, tweaking the audio offset, and upsampling the audio from 32 kHz (what TiVo uses) to 44.1 kHz (what SVCDs use). If you save this file and load show-name.avs into VirtualDub, you should be able to scan around through the file. You could even play show-name.avs with Windows Media Player, but it'll probably be a bit choppy (even on a fast computer) since Avisynth isn't optimized for playback.

You'll probably want to remove ads and other garbage from the show. Delete the last line (the one that just says "src") from the script, use VirtualDub to find the beginning and end frame numbers of the bits you want to save, and for each clip, add this to your script:

cn=Trim(src,start,end)

where n is a number to identify the clip (I start at 1) and start and end are the frame numbers where the clip starts and ends. You might also want to create a couple of seconds of dead space at the end:

blk=Blackness(src,60)

This creates 60 frames of the same size as the source (60 frames at 30000/1001 fps is about two seconds). Tie all of these cuts together with UnalignedSplice:

UnalignedSplice(c1,c2,...,cn,blk)

If you save the script now and load it into VirtualDub, you should see that only the video you selected is in there.

Since most TV shows are shot on film at 24 fps and telecined to convert them to 30000/1001 fps for broadcast, you end up with lots of redundant video information that you can remove. Inverse telecine reduces the framerate to 24000/1001 fps, which is just a little bit slower than the original (the original was slowed down to 24000/1001 fps when it was telecined). As an added bonus, your video will be deinterlaced. One line at the end of your script will do the trick:

InverseTelecine(40,10,15)

Don't try changing the numbers...they control how the filter works.

Your finished script should look something like this (the frame numbers are completely made up):

vid=MPEG2Source("show-name.d2v")
aud=WAVSource("show-name.wav")
AudioDub(vid,aud)
DelayAudio(audio-delay)
src=ResampleAudio(44100)

c1=Trim(src,1234,5678)
c2=Trim(src,14565,34532)
c3=Trim(src,39346,52343)
blk=Blackness(src,60)
UnalignedSplice(c1,c2,c3,blk)
InverseTelecine(40,10,15)

If you load the script into VirtualDub now and slowly go from one frame to the next, you should see almost no interlace noise. You might see some for a frame or two occasionally; the inverse-telecine filter is an adaptive filter, so it sometimes needs to adjust how it does its job.

Warning: Not all shows are telecined! If a show was shot with a video camera instead of a movie camera, it was captured at 30000/1001 fps. Anything that's aired live (news, sports) will be shot this way. Some other genres (soap operas, cooking shows, etc.) are usually shot with video cameras to keep production costs down. If you apply the inverse telecine filter to content that wasn't telecined, strange things will happen. Remove the filter and be content with 30000/1001 fps interlaced video.

Before closing VirtualDub, get the length of the edited video. You'll need it to figure the bitrate to use for encoding. Drag the editing slider all the way to the right. The length should be in the status bar.

Encoding to SVCD-Compatible MPEG-2

Use Videohelp's bitrate calculator to determine what bitrate to use for your encoding; be sure to set SVCD as the media type and fill in the rest of the blanks with appropriate settings. Make note of the average and maximum video bitrates given; you'll need them in TMPGEnc.

Start TMPGEnc. Before you try loading an Avisynth script into TMPGEnc, you need to disable TMPGEnc's DirectShow file reader. Select Option->Environmental setting... and click the VFAPI plugin tab. Make sure the DirectShow Multimedia File Reader is unchecked:

TMPGEnc configuration

Click OK to save settings.

Click Browse next to the video source box and select show-name.avs, your Avisynth script. The first frame should show up in the preview window. Call the output file whatever you want; TMPGEnc will more than likely suggest show-name.mpg, which will work well enough.

Now we have a ton of options to set to get TMPGEnc to do what we want. Click Setting and go through each of the tabs as follows:

Video

Advanced

GOP structure (Group of Pictures, not Grand Old Party :-) )

Quantize matrix

Audio

System

Once all the options are set, click Start to begin. This will take a long time to run on even fast hardware...my dual Athlon MP 2100 takes about 3 hours (give or take 30 minutes) to encode 45 minutes of video. I have made some choices in encoding options (floating point DCT, for instance) that trade speed for increased quality. You can experiment with other settings if you want, but do at least your first encode with these options so you'll have a reference to go by as far as what TMPGEnc can do.

If you cut the program somewhere in the middle (needed for more than about 60 minutes of edited video), do the same for the remaining cuts.

Burning the Video to CD

Once TMPGEnc is done, you should have one or more additional MPEG-2 streams that can be played by any program that'll take MPEG-2 input. These should be somewhere around 800 MB each (for burning to an 80-minute CD-R). Your software DVD player should handle them; there are also MPEG-2 playback codecs that enable Windows Media Player to play MPEG-2 streams. What you really want to do now, though, is burn the stream(s) to one or more CD-Rs so you can put your rip on the shelf next to all your tapes and DVDs. :-)

VCDImager is most easily used with a small batch file that takes care of the program's Byzantine options. Here's what I use:

@echo off
vcdimager -t svcd -c %1.cue -b %1.bin -l %2 --volume-count=%3 --volume-number=%4 -p -v %1.mpg

Save this as makesvcd.bat in the directory where your SVCD MPEG-2 streams are stored. To run VCDImager, then, all you type in is this for each image file:

makesvcd outfile label volume-count volume-number

This will convert outfile.mpg into outfile.bin and outfile.cue. The CD will have label as its label (what shows up under the CD's properties). volume-count should be the number of CDs you will make for this program, while volume-number is the sequence number for this particular CD. Creating the image takes a couple of minutes or so. Once you have the image files, load them into your burning software (FireBurner, Nero, or whatever) and burn to a blank CD-R. You'll need to use one of the disc-at-once (DAO) modes; track-at-once (TAO) won't work. Packet-writing software (such as DirectCD or InCD) definitely won't work.

Conclusion

That's all there is to it! I've been doing this for a little over a year now, and this is the method that I've found currently works best for me. Compared to the method I previously published, this one uses much less disk space and runs quite a bit faster. Some people might find the increased reliance on command-line tools and scripts a bit intimidating at first, but they're really not that big a deal. I think the improved quality and increased performance and flexibility are worth it.

(last edited 23 May 2003)

Original content copyright © 1997-2013 Scott Alfter; all rights reserved.
Archived materials are the property of their respective owners.