Channel to View .TS files - need to transcode

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

 

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.

 

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

 

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

 

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

 

 

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.

Have a look at the HLS specification:

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

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

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

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.

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.

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... 

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?  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.

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

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

I downloaded the sample "san diego" from 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
)

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

I downloaded the sample "san diego" from 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.

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.  Pity.  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

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

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?

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/

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? 

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.

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.

So here it is.

Basically the "live" menu I'm been playing with the HTTP Live Stream.  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.

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