# Channel to View .TS files - need to transcode

**URL:** <https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [August 24, 2013, 2:29am UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160 "2013-08-24T02:29:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 24, 2013, 2:29am UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/1 "2013-08-24T02:29:01Z")

</div>

So I'm trying to see if I can write a channel that will take NextPVR recorded TS files.&nbsp; These are 1080i HE-AAC-LC H.264 video files - too big for most devices.

&nbsp;

So I have a real basic channel that I have harded coded an M3U URL as an item, and another where I've taken apart the M3U and grabbed the URL inside.

&nbsp;

The URLs are pretty horrible - but this "[http://pvr.lan:8866/public/download.aspx?rid=\_wEC3Qc\*&path=\_wFl&mode=1](http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1)"&nbsp; will on a PC download a .TS file directly.&nbsp; So as part of my channel I set this to be an HTTPLiveStream.&nbsp;&nbsp; In Plex Home Theatre this started playing - as I assume the PC was able to deal with the .ts directly.

&nbsp;

What I can't figure out is how to send that url to the transcoder for IOS/PlexConnect/Roku clients.

&nbsp;

What do&nbsp; ineed to do to get this into the transcoder?&nbsp; So pointers with some real basic code snippets would be appreciated.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [August 24, 2013, 10:48am UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/2 "2013-08-24T10:48:51Z")

</div>

To the best of my knowledge, TS files are not currently supported by the Plex transcoder. There are several lengthy threads discussing/requesting that feature. Any existing channels which make use of HLS streams do so by passing the m3u playlists directly to the client which most clients are able to play natively.

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 24, 2013, 1:22pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/3 "2013-08-24T13:22:57Z")

</div>

Have a look at the HLS specification:

[http://tools.ietf.org/html/draft-pantos-http-live-streaming-11#section-8.2](http://tools.ietf.org/html/draft-pantos-http-live-streaming-11#section-8.2)

If you define a playlist like in the link and return that, all clients that can handle HLS should be able to play it.

If you have a URL-service, the code would look something like this(not tested)

```
def MediaObjectsForURL(url):
    return [
        MediaObject(
            container = 'mpegts',
            video_codec = VideoCodec.H264,
            audio_codec = AudioCodec.AAC,          
            audio_channels = 2,
            optimized_for_streaming = True,
            parts = [
                PartObject(
                    key = HTTPLiveStreamURL(Callback(PlayVideo, url = url))
                )
            ]
        )
    ]

def PlayVideo(url):
    # Maybe do something to get the correct URL for the ts file

    # Create playlist
    playList = "#EXTM3U" + "
"
    playList = playList + "#EXT-X-VERSION:3" + "
"
    playList = playList + "#EXT-X-TARGETDURATION:" + "
"
    playList = playList + "#EXTINF:," + "
"
    playList = playList + "" + "
"
    playList = playList + "#EXT-X-ENDLIST" + "
"

    return playList
```

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 24, 2013, 7:27pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/4 "2013-08-24T19:27:32Z")

</div>

So what about the clients they can’t handle it? I pretty much have none. Apple TV 2 nor 3 nor a roku 3 are big enough. 1080i h.264 video with that sound standard is hard on clients

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 24, 2013, 7:30pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/5 "2013-08-24T19:30:28Z")

</div>

What about if I accessed then as local files? Since the plex server is on the same machine as the next pvr recorder?

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 24, 2013, 7:48pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/6 "2013-08-24T19:48:48Z")

</div>

> So what about the clients they can't handle it? I pretty much have none. Apple TV 2 nor 3 nor a roku 3 are big enough. 1080i h.264 video with that sound standard is hard on clients

Have you tried it on one of these clients?

Since it is allowed(according to the HLS spec), to have ts segments that are this large(\>5000 seconds), I suppose all clients that supports HLS must deal with this. I believe that the clients will start feeding their video decoder as soon as there is enough data to start with, i.e. they don't need to download the whole file before playback starts.

Also, they might try HTTP range headers or something similar to avoid having to download the whole file before starting playback.

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 24, 2013, 8:05pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/7 "2013-08-24T20:05:43Z")

</div>

I’ve tried it on all. And plex web and plex home theatre running on a windows 7 machine .  
  
Only the last one was able to work.

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 24, 2013, 8:23pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/8 "2013-08-24T20:23:56Z")

</div>

> I've tried it on all. And plex web and plex home theatre running on a windows 7 machine .  
>   
> Only the last one was able to work.

Ok, does the video playback start and if so, does it stutter etc?

I'm asking because maybe the ts-files are not encoded according to the HLS spec? Most clients have hardware acceleration support, but if these videos are very demanding it simpy doesn't work on "low-end" devices(lack of processing power)....

Not sure how to go from here if that is the case since it is what Mike says, PMS can't transcode mpegts streams...&nbsp;

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 24, 2013, 8:50pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/9 "2013-08-24T20:50:49Z")

</div>

The computer was fine. The iPhone just said it couldn't deal with it. Roku just didn't start playing.

I guess my question is why can't .TS be transcoded?&nbsp; They should be relatively similar to to an MKV?

I guess I could get them transcoded from the source system via the web services, but I wasn't keen on this as I can't set the parameters per client - which Plex does anyway - and if I did that wrong I'd be double transcoding.

I've put these TS files in to the plex library and they generally work ok, so I'm not realy sure I understand the limitation.

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 26, 2013, 7:44pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/10 "2013-08-26T19:44:47Z")

</div>

How do I get one of the dev to comment on 1, why this is a limitation, and 2, if it may ever change?

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 26, 2013, 9:02pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/11 "2013-08-26T21:02:37Z")

</div>

It seems that PMS 0.9.8.4.125 can&nbsp;transcode mpeg ts! (not sure about older version, I only tested on this)

I downloaded the sample "san diego" from&nbsp;[http://dveo.com/downloads/TS-sample-files/](http://dveo.com/downloads/TS-sample-files/), placed in PMS library and tried playback in Plex/Web. It started transcoding and it played fine.

Try something like this(not tested):

```
def MediaObjectsForURL(url):
    return [
        MediaObject(
            container = 'mpegts',
            video_codec = VideoCodec.H264,
            audio_codec = AudioCodec.AAC,          
            audio_channels = 2,
            optimized_for_streaming = True,
            parts = [
                PartObject(
                    key = Callback(PlayVideo, url = url)
                )
            ]
        )
    ]

@indirect  
def PlayVideo(url):  
return IndirectResponse(  
VideoClipObject,  
key = url  
)
```

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 26, 2013, 9:18pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/12 "2013-08-26T21:18:41Z")

</div>

> It seems that PMS 0.9.8.4.125 can&nbsp;transcode mpeg ts! (not sure about older version, I only tested on this)
> 
> I downloaded the sample "san diego" from&nbsp;[http://dveo.com/downloads/TS-sample-files/](http://dveo.com/downloads/TS-sample-files/), placed in PMS library and tried playback in Plex/Web. It started transcoding and it played fine.
> 
> Try something like this(not tested):
> 
> ```
> def MediaObjectsForURL(url):
> return [
> MediaObject(
> container = 'mpegts',
> video_codec = VideoCodec.H264,
> audio_codec = AudioCodec.AAC,          
> audio_channels = 2,
> optimized_for_streaming = True,
> parts = [
> PartObject(
> key = Callback(PlayVideo, url = url)
> )
> ]
> )
> ]
> 
> @indirect  
> def PlayVideo(url):  
> return IndirectResponse(  
> VideoClipObject,  
> key = url  
> )
> ```

OK, I'll give that a go tonight.

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 27, 2013, 8:55am UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/13 "2013-08-27T08:55:18Z")

</div>

```
2013-08-27 20:53:30,631 (fe4) :  INFO (logkit:16) - Content length for unknown type video/vnd.dlna.mpeg-tts is invalid - aborting
```

Still doesn't seem to like it.&nbsp; Pity.&nbsp; I thought you were on to something.

Rest of the system log:

```
2013-08-27 20:53:36,904 (f70) :  DEBUG (runtime:714) - Handling request GET /system/:/services/url/lookup?url=http%3A//pvr.lan%3A8866/public/download.aspx%3Frid%3D_wEC3Qc%2A%26path%3D_wFl%26mode%3D1
2013-08-27 20:53:36,907 (f70) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2013-08-27 20:53:36,908 (f70) :  DEBUG (runtime:811) - Found route matching /system/:/services/url/lookup
2013-08-27 20:53:36,910 (f70) :  DEBUG (services:23) - Looking up URL 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,911 (f70) :  DEBUG (services:602) - No service found for URL 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,911 (f70) :  DEBUG (services:617) - No matching services found for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,915 (f70) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2013-08-27 20:53:36,918 (f70) :  DEBUG (services:602) - No service found for URL 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,920 (f70) :  DEBUG (services:617) - No matching services found for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,921 (f70) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2013-08-27 20:53:36,924 (f70) :  DEBUG (networking:233) - Fetching HTTP headers for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,970 (f70) :  INFO (logkit:16) - Length: 0  Type: video/vnd.dlna.mpeg-tts
2013-08-27 20:53:36,970 (f70) :  INFO (logkit:16) - Content length for unknown type video/vnd.dlna.mpeg-tts is invalid - aborting
2013-08-27 20:53:36,971 (f70) :  DEBUG (services:602) - No service found for URL 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,971 (f70) :  DEBUG (services:617) - No matching services found for 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,973 (f70) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2013-08-27 20:53:36,976 (f70) :  DEBUG (services:602) - No service found for URL 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,976 (f70) :  DEBUG (services:617) - No matching services found for 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:36,976 (f70) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2013-08-27 20:53:36,979 (f70) :  DEBUG (networking:233) - Fetching HTTP headers for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-27 20:53:37,084 (f70) :  INFO (logkit:16) - Length: 0  Type: video/vnd.dlna.mpeg-tts
2013-08-27 20:53:37,084 (f70) :  INFO (logkit:16) - Content length for unknown type video/vnd.dlna.mpeg-tts is invalid - aborting
2013-08-27 20:53:37,085 (f70) :  DEBUG (runtime:106) - Sending packed state data (99 bytes)
2013-08-27 20:53:37,085 (f70) :  DEBUG (runtime:911) - Response: [404] NoneType, 0 bytes
```

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 27, 2013, 4:13pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/14 "2013-08-27T16:13:43Z")

</div>

It seems like your service does not recognize the URL. How does your ServiceInfo.plist look like?

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 27, 2013, 5:44pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/15 "2013-08-27T17:44:45Z")

</div>

> It seems like your service does not recognize the URL. How does your ServiceInfo.plist look like?

  
I haven't fully investigated a URL service as yet. I figured I needed to start looking at doing one.  
  
I see a URL service covers a huge area. Can I just implement the 1 or 2 functions I need? The play video and media object ones?

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 27, 2013, 6:12pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/16 "2013-08-27T18:12:25Z")

</div>

Ok,

I'm not sure an URL service is needed in your case but I honestly forget how to do it without one.

In this thread:

[http://forums.plexapp.com/index.php/topic/76897-kartinatv-plugin/](http://forums.plexapp.com/index.php/topic/76897-kartinatv-plugin/)

there is an example which might help you(replace with relevant parameters above).

If you implement an URL-service it would work with just those two above functions but only for PMC/PHT. Plex/Web, iOS, Roku(?) etc also requires the MetadataObjectForURL to exist. If you add it and simply just return None, it will work for those clients.

Do you have your code somewhere, I could have a look if you like?&nbsp;

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 27, 2013, 6:19pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/17 "2013-08-27T18:19:36Z")

</div>

Not yet. I can post it here. It’s all hardcoded links as if I can’t get the video playback to work then I have no need to develop it any further - ie to gather all the videos from the nextpvr system.  
  
I can, with nextpvr get the web service to initiate transcoding but it uses vlc and it can’t be tailored for the client, so i’d s prefer that plex was able to do it.

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 27, 2013, 7:34pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/18 "2013-08-27T19:34:11Z")

</div>

> Not yet. I can post it here. It's all hardcoded links as if I can't get the video playback to work then I have no need to develop it any further - ie to gather all the videos from the nextpvr system.  
>   
> I can, with nextpvr get the web service to initiate transcoding but it uses vlc and it can't be tailored for the client, so i'd s prefer that plex was able to do it.

Please do, and we'll see if something looks strange.

I agree that using another application to transcode would not be the ideal solution, but if it doesn't work out using only Plex, I think it would work for almost all clients if you set VLC to transcode to MP4 with H.264 and AAC.

---

<div class="post-metadata">

**Author:** ![psycik](https://avatars.discourse-cdn.com/v4/letter/p/b77776/32.png) [@psycik](https://forums.plex.tv/u/psycik)\
**Post date:** [August 27, 2013, 8:22pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/19 "2013-08-27T20:22:49Z")

</div>

So here it is.

Basically the "live" menu I'm been playing with the HTTP Live Stream.&nbsp; And the video is a hard coded link from my system.

Hopefully if I can get the video to work, then I can start trying to call the ASP.Net web services that are used on NextPVR to make calls to teh recording system to get access to the recordings - and live TV.

---

<div class="post-metadata">

**Author:** ![meo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/meo/32/4534_2.png) [@meo](https://forums.plex.tv/u/meo)\
**Post date:** [August 27, 2013, 8:49pm UTC](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160/20 "2013-08-27T20:49:17Z")

</div>

I've added an URL-service, please give it a try.

[Next page](https://forums.plex.tv/t/channel-to-view-ts-files-need-to-transcode/41160.md?page=2)
