The program was inspired by an executable-only program called Playback which was released by `the Doctor' in the Dealdatabase TiVo Hacks Forum. I wanted an open-source version, so I wrote Playitsam.
Features of Playitsam:
Playitsam comes as a gzipped tarball which contains the source code, this documentation and a TiVo binary called tplayitsam. I've only called it this so that if you accidentally type make to make the non-TiVo version of the program, it won't overwrite the TiVo version.
You should copy tplayitsam over to your TiVo to wherever you have installed other binary tools, and rename it to be playitsam. Remember to chmod it 755 so that it is executable.
If you want the non-TiVo version of Playitsam, simply type make. This will produce a binary called playitsam which you can copy to /usr/local/bin on your system. The make will also make the tyserver program, which allows you to make your Unix box into a TiVo stream server. Again, copy it into /usr/local/bin. Make sure both are executable with a chmod 755 on both.
Note: The make will try to compile tplayitsam, and will fail if you don't have a TiVo cross-compiler installed. This isn't a problem because I have provided the tplayitsam binary. At present, I am using mmap() in the tyserver program to speed up I/O across the network. If your Unix system doesn't support mmap(), then edit or remote the first line in tyserver.c to turn off the use of mmap().
To run Playitsam on a non-TiVo system, you will need the mp2 audio playback tool Amp, and the MPEG video playback tool Mpeg2dec. You could use mpg123 instead of Amp, but you would need to edit the playitsam.h file.
Help: Apart from mmap(), the tyserver.c code should be easily ported to a Win32 platform. Could someone do this, and return the diffs and the resulting tyserver.exe program so I can include it in future releases?
Playitsam is run on both TiVo and non-TiVo systems as follows:
% playitsam [-v] [-n] [-p] [-M] [-D] inputsource [outputsource]If you are using Playitsam on the TiVo, then before you run it, you should make sure that there is no writing on the screen. Either go to Live TV and clear the green bar, or start playing an existing recording. If you don't, then you will have to put up with writing on the screen!
The input source follows this naming convention:
% playitsam 45887 # TiVo FSID for stream
% playitsam 10.10.1.1:the_bill # Stream from a tyserver
% playitsam ../my_hero # Unix file
-v Be verbose when running. It's only really useful for debugging Playitsam.When Playitsam starts up, it will firstly try to kill off the EventSwitcher on the TiVo, which gives it exclusive use of the audio/video devices. So, it's a good idea to use the -M switch to restart them when Playitsam is finished. If you chose -p, then Playitsam will go straight into Play mode and play the stream. Otherwise, Playitsam will go into Edit mode. If you chose -n, then the EventSwitcher won't be killed.-n Don't play the stream using the audio/video device. Just print out details of the editing.
-p Only play the stream back, don't go into editing mode. Obviously, -n and -p are mutually exclusive.
-M On the TiVo, restart MyWorld when Playitsam ends normally.
-D On the TiVo, disable on-screen feedback of the editing process.
In edit mode, you can go forwards and backwards through the stream, and mark cuts to make. Then, when you go into Play or Record mode, the sections of the recording that you have cut will be skipped. If you are playing from standard input or from the tyserver, then you cannot edit the input stream.
The original input source is not altered by your editing operations; only the playback of the stream, or the exporting (recording) of the stream will be affected.
Edit mode starts by playing the input stream. A cut is marked starting at the first chunk, but with no end yet. This assumes that your program starts with something you don't want. If not, it's easy to clear this pending cut.
You can edit the stream using the Unix keyboard, or the TiVo remote. Here are the commands available on the keyboard:
Keystroke | Operation |
space | Toggle pause & playback |
f | Go forwards 1 chunk |
1,2,3 | Go forwards 5, 25, 125 chunks |
4,5,6 | Go forwards 500, 2500, 12500 chunks |
0 | Go to the last chunk and pause |
b | Go backwards 1 chunk |
!,@,# | Go backwards 5, 25, 125 chunks |
$,%, | Go backwards 500, 2500, 12500 chunks |
) | Go to the first chunk |
c, s | Make a cut starting at this chunk |
e | End the current cut at this chunk |
k | Kill (delete) the current cut |
K | Kill all the cuts made so far |
l | List the cuts made so far |
P | Go into Play mode to play the edited stream |
R | Go into Record mode, and export the edited stream |
q,Q,ctrl-C | Quit Playitsam |
Information about the chunk numbers and the cuts you make are also shown on the login/telnet connection.
If you choose to go into Record mode from Edit mode, then the stream minus the cut material is exported to the named output source. I've found that TCP data transfers off the TiVo are much faster than with NFS, so if you do want to export to a remote device, I would recommend that you set up a tyserver.
Every 100th chunk, some information is displayed to let you know that the recording is actually working. When the edited stream is finally exported, Playitsam will exit normally, and will restart MyWorld if you specified the -M option.
If you choose to go into Play mode from Edit mode, then Playitsam will go back to the first chunk. It will pause for 10 seconds before starting the playback; this is so that you can get your VCR ready to record the program. Hint: if you are recording to VCR, then before you go into Play mode, find a black chunk and pause on it in Edit mode. This will start you off with a blank screen before the playback begins.
During the 10 second initial delay, Playitsam will print out a countdown, so you can work out when the playback will start.
It is only useful to run the tyserver if you have a TiVoNet connection from the TiVo to a Unix box. On the Unix box, run tyserver and name the directory where you keep your exported streams, e.g:
For security reasons, only run the tyserver on a private network which is not accessible from elsewhere. There is no authentication with the tyserver, and a malicious person could fill up your hard disk with streams!
You might find that playback from the tyserver has a lot of stuttering. I have found that there are at least two reasons for this:
/sbin/sysctl -w net.inet.tcp.recvspace=65536I don't have a Linux or Windows box, so I can't tell you how to do the same tweaking on these systems. if you can supply details, I would be grateful.
/sbin/sysctl -w net.inet.tcp.delayed_ack=0
/sbin/sysctl -w net.inet.tcp.sendspace=131072
Secondly, you need to get a decent CD-ROM drive, if you are going to play streams back from CD-ROM. I was initially using an 20x ATAPI CD-ROM drive and playback was awful. I found that the drive was continually speeding up & slowing down, and this was causing the stuttering. I now have a 16x SCSI-2 CD-ROM drive, and now I rarely get any stutters on playback.
However, to really get rid of the stutters, use the tyserver and not NFS or SMB, tweak your TCP options, and copy the stream to hard disk instead of playing from CD-ROM.
The TiVo native video stream format (aka tystream) is a proprietary multiplexed MPEG-2 stream. If you use Playitsam to extract a tystream intact (i.e without making any cuts), then you should be able to use the other TiVo stream tools (tyc, splitstream, TyConvert etc.) to convert this into a standard MPEG-2 file. However, as soon as you edit the stream and cut out chunks, then the resulting tystream cannot be converted into a standard MPEG-2 file. It can still be played back on the TiVo, but don't expect to be able to do anything else with it.
Firstly, treat this as beta quality software. It seems to work for me fine, but then I only wrote it a few days ago and there are sure to be bugs lurking in the program. I have a standalone TiVo running version 1.3 of the software, so I have no idea if it will work on other systems. Please BACKUP your system before you run this, as I cannot take any responsibility for lost data or a damaged system.
The TiVo video stream is a proprietary MPEG-2 stream. Because of the way it is structured, you will find what looks like blocky or corrupted images when you go forward or backward frames. This is normal, and is due to the fact that MPEG-2 streams encode differential images as well as full images. So when you skip data, or play stuff back in the wrong order, then you will get artifacts like this.
Hint: if you are in pause mode and are going backwards, go backwards more chunks than you need to, and then come forwards. This helps to bring the video back into `sync' so that it is uncorrupted again.
The Mpeg2dec program on a non-TiVo often dumps core when you jump chunks or go backwards; this is because it doesn't expect an MPEG-2 stream which is jumbled as much. I might try to fix it so that it doesn't dump core, but tries to resync on the jumbled input.
If you have any questions or comments, please e-mail me at wkt@tuhs.org.
Warren Toomey, January 2002.