[MPlayer-dev-eng] .TiVo file support
voroshil at gmail.com
voroshil at gmail.com
Sun Dec 10 08:20:38 CET 2006
I'm not serious developer, but some time ago i've wroted
small driver for MPlayer and i hope my expirence will be
usefull for you.
Jeremy Drake wrote:
> Hello, I have authored a program to convert .TiVo files to plain MPEG
> (http://tivodecode.sourceforge.net/) and want to restructure it into a
> library-type thing which could be used to make an mplayer plugin to play
> these files.
>
> I mentioned this on IRC the other day and it was suggested that I try
> here.
>
> I would like to ask about how such a codec should be written.
> Is there any good place to look to get started writing a plugin which
> filters an MPEG stream?
>
> I would like to point out, before anyone mentions it, that the tivo://
> thing is for hacked earlier tivos or some such, this is for the supported
> TiVoToGo download feature.
>
> First, let me apologize for my lack of knowledge of correct terminology,
> most of what I know about this I learned from reverse engineering, so I
> pretty much made up names for things as I went along ;)
>
> The tivo files contain a normal MPEG stream at a certain offset in the
> file, and only some of the packets need handling (those with scramble bits
> set to 3). Basically the TiVo file contains a valid mpeg file, and only a
> fraction of the packets need to be decoded before being handled in the
> normal mpeg way.
>
> The TiVo file has a header, then at some offset (specified in the header)
> there is an mpeg stream. In this stream, some of the packets have certain
> bits set in the packet header, which mean that this packet needs to be
> sent through a Turing stream cipher. If those bits are not set, then the
> mpeg packet can be handled by a normal mpeg parser as-is. After the
> encoded packets are handled, they are normal mpeg packets that can be
> handled by a normal mpeg parser.
>
> The decoding needs to know the contents of the header of the file, some
> bits in the packet header, and the decoding is stream-based so it needs to
> have decoded the previous packets with the same block number (this is what
> I call some certain bits which are involved in generating the Turing
> stream). You could potentially seek during playback to certain points in
> the file without breaking the decrypt, but not every place you could have
> in a non-encrypted file. And if you tried, you would get garbage for a
> sec and then go back to valid decoding at the next change of the block
> number.
>
> If you are interested in the specifics, the format was documented on this
> wiki while being figured out (http://www.alt.org/wiki/index.php/TiVoToGo).
>
> You can already play the files in mplayer by piping the output of the
> decoder into mplayer:
> tivodecode -m XXXXXXXXXX Test.TiVo | mplayer -
>
> the -m is the MAK, a key from the tivo that made the file which is needed
> to decrypt the file
>
If i undestand you correctly, your driver should have TiVo file as input and
standard MPEG as output.
In this case, i think, the easyest way will be writing "stream" module (in MPlayer
terminology). The main purpose of this module will be building clear MPEG
data stream, suitable for handling by existing MPEG demuxer.
In this module you should realize at least two methods: "open_s" (opening the
file and initializing the module if neccesery) and "fill_buffer_s" (filling given
demuxer's buffer with decrypted MPEG data).
Optionally, you can also write "close_s" (proper closing) and "seek_s"(seeking in
stream). Method names may vary (actual names must be set in stream_info_t structure,
see stream_t definition in stream.h).
Note, that you must either realize "seek_s" routine or mark stream as
non seekable.
I think, descrambling may be realized in "fill_buffer".
Supporting "-m" option may be get in two ways. If MAK may vary from file to file (i.e.
unique for downloaded file) then it should be a part of movie URL (e.g.
"mplayer tivo://XXXXXXXXXX/<path_to_file>". Otherwise you can make it regular option
(and start mplayer with something like "mplayer -tivo mak=XXXXXXXXXX
tivo://<path_to_file>" or put option into configuration file).
First method you can see in any stream/stream_* file (see "stream_opts_fields"
array there). For a second way see cfg-common.h and related global variables in
stream/stream_*.
As start point you can see stream/stream_file.c (simple stream, that performs
just reading file from disk, routines named "fill_buffer" and "open_f")
More complex examples will be stream_tv or stream_radio.
> It was suggested on IRC that perhaps the thing I needed to write was this:
> rxt_: probably the easies way it the same used to handle stuff like mpeg
> in mov or ogg in avi, that's making a tivo demuxer that sends its output
> to the mpeg demuxer
>
> It was also suggested that I talk to nicodvb on this list.
>
> Thanks for your help, and I hope this message is somewhat sane, it is
> mostly copied and pasted from what was said in IRC. Please let me know if
> there is any code around that would be a good starting place for me to
> hack something like this together. I do not know much of anything about
> the internals of video software, or how to go about getting something put
> together. I would like to make a plugin for mplayer, whether an external
> project or integrated in some way...
>
I hope my knowledge will help you.
In any case, getting serious developers (like nicodvb and others) opinions
will be a very good idea.
Probably, i'm wrong and exist much simple (and/or correct) way.
--
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
Omsk State University
JID: voroshil at jabber.ru
ICQ: 95587719
More information about the MPlayer-dev-eng
mailing list