# Difference between MPGEG-PS and MPEG-TS files?



## gamo62

Does anyone know what the differences are between the MPEG-PS and TS file types? When I use IE8, to connect to my Premiere, I have the option of downloading either format. Thanks.


----------



## dlfl

http://en.wikipedia.org/wiki/MPEG_transport_stream and

http://en.wikipedia.org/wiki/MPEG_program_stream

A TS can contain several program streams:



> Transport stream has a concept of programs. Each single program is described by a Program Map Table (PMT) which has a unique PID, and the elementary streams associated with that program have PIDs listed in the PMT. For instance, a transport stream used in digital television might contain three programs, to represent three television channels. Suppose each channel consists of one video stream, one or two audio streams, and any necessary metadata. A receiver wishing to decode a particular "channel" merely has to decode the payloads of each PID associated with its program. It can discard the contents of all other PIDs. A transport stream with more than one program is referred to as MPTS - Multi Program Transport Stream. A single program transport stream is referred to as SPTS.


Also, TS are supposed to have more error correction features, to make them better for transmission by less reliable means.

I'm not sure what practical aspects caused TiVo to use TS in some cases.


----------



## moyekj

Be warned however that TS downloads from Premiere units seem to have a lot more trouble compared to PS downloads. I've seen reports (in kmttg thread) of incomplete or problems with playback of TS downloads where same shows downloaded as PS are fine. So at least for now even though TS downloads are a lot faster it seems you are better off sticking with PS format for reliability. That may explain why currently TiVo Desktop offers no option for TS downloads.


----------



## HarperVision

moyekj said:


> Be warned however that TS downloads from Premiere units seem to have a lot more trouble compared to PS downloads. I've seen reports (in kmttg thread) of incomplete or problems with playback of TS downloads where same shows downloaded as PS are fine. So at least for now even though TS downloads are a lot faster it seems you are better off sticking with PS format for reliability. That may explain why currently TiVo Desktop offers no option for TS downloads.


Sorry to revive a way old thread, but I was wondering if this is still true about using the TS stream vs the PS stream in regards to PS being more stable?

It seems like, based on my reading, that TS would be better for me to use to download from my Roamio Plus that's all the way in Philly, since it's such a long distance from HI and will go through MANY hops most likely.

Also, would anyone happen to know which one the TiVo-to-Go Plex plugin uses for its streaming, PS or TS?


----------



## telemark

MPEG-TS is made for transmission networks (unreliable due to long distance and long transmission time). ATSC/OTA and Cable/QAM uses it, and a Tivo would just dump that to the HardDrive. Satellite should use something similar.

MPEG-PS is made for computer files (reliable due to short distance and short transmission time).

Most of the OSS software relies on tivodecode, including the Plex plugin.
tivodecode has spotty TS support and so a major hindrance.

The Windows tools may have better TS support than tivodecode.


----------



## HarperVision

telemark said:


> MPEG-TS is made for transmission networks (unreliable due to long distance and long transmission time). ATSC/OTA and Cable/QAM uses it, and a Tivo would just dump that to the HardDrive. Satellite should use something similar. MPEG-PS is made for computer files (reliable due to short distance and short transmission time). Most of the OSS software relies on tivodecode, including the Plex plugin. tivodecode has spotty TS support and so a major hindrance. The Windows tools may have better TS support than tivodecode.


Ok thanks, but which one is better for me to download when I'm logged into my Philly TiVo from a browser since it gives both options?


----------



## telemark

By default, you should use PS.

TS can be used to solve some technical problems, but they're rare and come with another set of problems, including a more limited set of tools that can handle them. [VideoReDo]


----------



## HarperVision

Great, thanks!


----------



## Dan203

The main reason TiVo added TS was H.264. It originally appeared in the Australia/New Zealand TiVos because in NZ they broadcast almost everything in H.264. PS does not handle H.264 well, and most players/demuxers will not handle H.264 in a PS container at all. So switching to TS for H.264 made the streams more compatible with the way TiVo Desktop just decrypts the stream and then hands it off to WMP to demux/decode.

As a side benefit TS files transfer much faster because the TS format is basically what they use internally, so only a very minor conversion is required rather then a full remux and re-encryption like they do with PS. It's also easier for their code to move past glitches and errors in the source stream when converting to TS because the conversion is minor and doesn't require them to demux the original audio/video streams. So files that would fail to transfer as PS due to errors in the stream will usually work as TS.

The biggest issue people have with TS files using a tool like kmttg is that the open source tivodecode never had it's TS decryption fully implemented. So it can actually introduce errors into the decrypted file. I wrote a program years ago (which I never released) that uses the TiVo DirectShow filter to do the decryption of TiVo files and it always works perfectly when decrypting TS files. In VideoReDo we use the DirectShow filter too, but we use sort of a backdoor into it rather then building a whole graph, and that backdoor can fail when it hits a glitch in the stream. We have some code to work around it, but it's not 100% so I'm eventually going to rewrite VRDs TiVo support to work more like my other program.


----------



## HarperVision

Dan203 said:


> The main reason TiVo added TS was H.264. It originally appeared in the Australia/New Zealand TiVos because in NZ they broadcast almost everything in H.264. PS does not handle H.264 well, and most players/demuxers will not handle H.264 in a PS container at all. So switching to TS for H.264 made the streams more compatible with the way TiVo Desktop just decrypts the stream and then hands it off to WMP to demux/decode. As a side benefit TS files transfer much faster because the TS format is basically what they use internally, so only a very minor conversion is required rather then a full remux and re-encryption like they do with PS. It's also easier for their code to move past glitches and errors in the source stream when converting to TS because the conversion is minor and doesn't require them to demux the original audio/video streams. So files that would fail to transfer as PS due to errors in the stream will usually work as TS. The biggest issue people have with TS files using a tool like kmttg is that the open source tivodecode never had it's TS decryption fully implemented. So it can actually introduce errors into the decrypted file. I wrote a program years ago (which I never released) that uses the TiVo DirectShow filter to do the decryption of TiVo files and it always works perfectly when decrypting TS files. In VideoReDo we use the DirectShow filter too, but we use sort of a backdoor into it rather then building a whole graph, and that backdoor can fail when it hits a glitch in the stream. We have some code to work around it, but it's not 100% so I'm eventually going to rewrite VRDs TiVo support to work more like my other program.


Awesome explanation Dan, thanks! I think I'll select TS for the long distance transfer to here for the time being, and see if there are any glitches, since you guys mention it transfers faster. If I get too many glitches I'll just go back to PS.

Since you have a great handle of these things, can you help with another question/issue I have?

I want to stream the MPEG-PS/TS file directly from Streambaby while its concurrently downloading the file from my philly Roamio+. The issue I'm having is that when I select the file that's downloading in my TiVo Recordings folder locally, it starts to play fine after it buffers a bit but it will only play to the point that the file size WAS when I selected it to stream/play. In other words the download isn't acting as a buffer to the Streambaby stream as I had hoped. How can it be made to do this?


----------



## moyekj

Dan203 said:


> The biggest issue people have with TS files using a tool like kmttg is that the open source tivodecode never had it's TS decryption fully implemented.


FYI, these days the kmttg windows installation includes DirectShowDump method as well, so at least for people on Windows platform with TiVoDirectShowDump.dll installed (partial TiVo Desktop installation which VRD also uses), you can decrypt TS TiVo files just fine. i.e. These days kmttg has 3 different options for decrypting TiVo files: tivodecode, DSD, and VRD, and of course the latter 2 work fine with TS TiVo files.


----------



## Dan203

moyekj said:


> FYI, these days the kmttg windows installation includes DirectShowDump method as well, so at least for people on Windows platform with TiVoDirectShowDump.dll installed (partial TiVo Desktop installation which VRD also uses), you can decrypt TS TiVo files just fine. i.e. These days kmttg has 3 different options for decrypting TiVo files: tivodecode, DSD, and VRD, and of course the latter 2 work fine with TS TiVo files.


I'm not sure uow DSD works exactly. VRD exploits an extra interface in the TiVo DS filter which allows us to access the unencrypted data as if it were a standard file. It works OK for most files, but we've recently discovered that if the file has a glitch then that interface will stop decrypting the data until you seek past the glitch. We added code to detect when this happens and then force a sequence of small seeks until it starts decrypting again. My program builds a simple DS graph, just like the file is going to be played, but it uses a special filter I wrote that can link directly to the output pin of the TiVo filter and dump the unencrypted stream to a file. We've found in our testing that this method is not effected by glitches in the video and is actually able to decrypt even the corrupted portion of the file allowing us to repair some of the frames which we can not even access using our current method.

If DSD uses a metod similar to VRf then it may have issues with some TS files. If it uses a meod similar to my program then it will likely give you the best possible results.


----------



## Dan203

HarperVision said:


> Awesome explanation Dan, thanks! I think I'll select TS for the long distance transfer to here for the time being, and see if there are any glitches, since you guys mention it transfers faster. If I get too many glitches I'll just go back to PS.
> 
> Since you have a great handle of these things, can you help with another question/issue I have?
> 
> I want to stream the MPEG-PS/TS file directly from Streambaby while its concurrently downloading the file from my philly Roamio+. The issue I'm having is that when I select the file that's downloading in my TiVo Recordings folder locally, it starts to play fine after it buffers a bit but it will only play to the point that the file size WAS when I selected it to stream/play. In other words the download isn't acting as a buffer to the Streambaby stream as I had hoped. How can it be made to do this?


I'm not sure how StreamBaby works but at one point I wrote a player app specifically for TiVo files (also never released) and one of the things I discovered with that is that the duration of the stream reported to the DirectShow graph by the TiVo filter does not get updated if the file is still downloading. So it's stuck at whatever duration was available when the file started playing. However the TiVo filter will decrypt data beyond that point, it just wont report it to the graph. You can see this happen if you play an in progress download in WMP. The duration will be reported as whatever is available when you start playing the file, and you'll only be able to seek in that portion, but if you let it play all the way to the end of the bar it will keep going until it hits the actual end of the file.

If StreamBaby is using DS to decrypt the file then it's likely getting the duration from the graph and then stopping when it reaches that point. I don't believe there is anything in the TiVo header that reports the actual duration of the file, and sunce it's downloading there is no way for it to be calculated, so the only thing I can think of that might fix it is if StreamBaby could detect that the file size was actively changing and then use a large duration, like say 24 hours, for any file it determines is still downloading. Then it would need to elegantly detect and recover when it hit the actual end of file. (could be easier said then done)


----------



## moyekj

Dan203 said:


> I'm not sure uow DSD works exactly. VRD exploits an extra interface in the TiVo DS filter which allows us to access the unencrypted data as if it were a standard file. It works OK for most files, but we've recently discovered that if the file has a glitch then that interface will stop decrypting the data until you seek past the glitch. We added code to detect when this happens and then force a sequence of small seeks until it starts decrypting again. My program builds a simple DS graph, just like the file is going to be played, but it uses a special filter I wrote that can link directly to the output pin of the TiVo filter and dump the unencrypted stream to a file. We've found in our testing that this method is not effected by glitches in the video and is actually able to decrypt even the corrupted portion of the file allowing us to repair some of the frames which we can not even access using our current method.
> 
> If DSD uses a metod similar to VRf then it may have issues with some TS files. If it uses a meod similar to my program then it will likely give you the best possible results.


 My preferred decryption method is VRD and what I recommend to anyone that asks that is using Windows OS.


----------



## Dan203

VRD does a QSF at the same time, so you're fixing two birds with one stone using it. But it's possible DSD would be able to handle files with glitches in them with a few less dropped frames because of the way it works.


----------

