OzTiVo to DVD conversion

Here’s how I convert programs on the TiVo to DVDs for archival.

Things needed

  • A TiVo, with the video resolution set to 720×576 which avoids the need to resize and thus transcode the video
  • Playitsam with the following patches applied:
    1. This patch fixes large file support so the program doesn’t crash when writing a stream larger than 2G.
      --- hdr/defines.h       19 Oct 2002 03:56:07 -0000      1.1
      +++ hdr/defines.h       1 Jan 2007 02:05:50 -0000       1.2
      @@ -3,4 +3,8 @@
       #ifdef __linux__
       #define __USE_FILE_OFFSET64
       #define __USE_LARGEFILE64
      +
      +#define _LARGEFILE_SOURCE
      +#define _LARGEFILE64_SOURCE
      +#define _FILE_OFFSET_BITS 64
       #endif
    2. This patch changes it to use madplay and mplayer instead of the ancient mpg123 and mpeg2dec (NB: if you want to use gplayitsam you will need to make a similar change there):
      --- unix/unixcli.c      19 Oct 2002 03:55:44 -0000      1.6
      +++ unix/unixcli.c      31 Dec 2006 22:59:59 -0000      1.7
      @@ -18,8 +18,8 @@
       static struct termios oldtios, newtios;         /* Console settings for raw */
                                                       /* and cooked modes */
      
      -#define AUDIO_PROG mpg123 - 2 /dev/null
      -#define VIDEO_PROG mpeg2dec -o x11 2 /dev/null
      +#define AUDIO_PROG madplay -Q -
      +#define VIDEO_PROG mplayer -ao null -vo xv -  /dev/null 2 /dev/null
      
       /* Open the output devices used for playback. Returns
        * 1 if ok, 0 if an error.
  • The ffmpeg, mjpegtools, dvdwizard, dvdauthor and dvd+rw-tools packages and their dependencies.

Procedure

  1. Use TivoWeb to get the list of FSIDs for the program; for example: 18022,18024,18025
  2. Run Playitsam, giving it the TiVo’s hostname, the FSIDs, and the output file names:
    playitsam tivo:18022,18024,18025 program.mpa program.mpv
  3. Perform editing operations in Playitsam (see the documentation for details). Then, either:
    • If you are going to do the heavy lifting on the same machine, press R to record the stream to the output files.
    • If you want to do the processing on another machine (maybe with more disk space or CPU power), follow these steps:
      1. In Playitsam, press L to get the cut list, for example:
        Here is the list of cuts:
          cut from chunk 0 to 496
          cut from chunk 28273 to infinity
      2. On the other machine, use the nvcut tool (also part of Playitsam) to download the actual stream. The cut list becomes the final arguments. Eg:
        nvcut tivo:18022,18024,18025 program.mpa program.mpv 0 496 28273
  4. Transcode the audio stream to AC3 with ffmpeg:
    ffmpeg -i program.mpa -ar 48000 -ab 192 -acodec ac3 program.ac3
  5. Multiplex the audio and video streams, using the mplex program from the mjpegtools package.
    mplex -f 8 -o program.mpg program.mpv program.ac3

    NB: on one recording, I found that the audio was out of sync about half a second ahead of the video. I don’t know what caused it, but if you have the same problem, you can use the -O option to mplex to correct it. You will need to determine the correct offset experimentally, in my case I used -O-500ms.

  6. Create a DVD filesystem and menus with the dvdwizard program. At this point you can also put other programs on the DVD or make nicer menus. See the dvdwizard documentation for details. An example command-line is:
    dvdwizard -T 'disc title' -N PAL -A en -t 'program title' -c 900 program.mpg
  7. If the program is in anamorphic widescreen (for example, if it was recorded from a set-top box in 16:9 mode), the generated DVD will have the wrong aspect ratio of 4:3. If this is the case, you need to edit the generated dvdwizard.xml file, changing aspect=4:3 to aspect=16:9 where appropriate, then reauthor the DVD:
    rm -r dvd  dvdauthor -x dvdwizard.xml
  8. Test the result in your favourite software DVD player, eg. Xine or mplayer:
    xine dvd:$PWD/dvd
    mplayer -dvd-device $PWD/dvd dvd://
  9. If you’re happy, burn it to a DVD:
    growisofs -dvd-compat -Z /dev/dvdrw -dvd-video dvd/

Published by

ab

Well, AB's just this guy, you know?