Channel to View .TS files - need to transcode

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

Awesome ,thanks.

Well the log looks a little better, but still that content length error.

2013-08-28 12:51:56,789 (1d28) :  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-28 12:51:56,799 (1d28) :  DEBUG (runtime:811) - Found route matching /system/:/services/url/lookup
2013-08-28 12:51:56,799 (1d28) :  DEBUG (services:23) - Looking up URL 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:51:56,799 (1d28) :  DEBUG (services:615) - Found a service matching 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1' - NextPVR (com.dcSoftware.plexapp.nextpvr)
2013-08-28 12:51:56,799 (1d28) :  DEBUG (services:41) - Loading service code for NextPVR (URLServiceRecord)
2013-08-28 12:51:56,825 (1d28) :  DEBUG (services:615) - Found a service matching 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1' - NextPVR (com.dcSoftware.plexapp.nextpvr)
2013-08-28 12:51:56,825 (1d28) :  DEBUG (services:41) - Loading service code for Fallback (URLServiceRecord)
2013-08-28 12:51:57,000 (1d28) :  DEBUG (networking:233) - Fetching HTTP headers for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,434 (1d28) :  INFO (logkit:16) - Length: 0  Type: video/vnd.dlna.mpeg-tts
2013-08-28 12:52:05,434 (1d28) :  INFO (logkit:16) - Content length for unknown type video/vnd.dlna.mpeg-tts is invalid - aborting
2013-08-28 12:52:05,440 (1d28) :  DEBUG (services:602) - No service found for URL 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,440 (1d28) :  DEBUG (services:617) - No matching services found for 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,444 (1d28) :  DEBUG (services:602) - No service found for URL 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,444 (1d28) :  DEBUG (services:617) - No matching services found for 'ipad:http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,454 (1d28) :  DEBUG (networking:233) - Fetching HTTP headers for 'http://pvr.lan:8866/public/download.aspx?rid=_wEC3Qc*&path=_wFl&mode=1'
2013-08-28 12:52:05,484 (1d28) :  INFO (logkit:16) - Length: 0  Type: video/vnd.dlna.mpeg-tts
2013-08-28 12:52:05,484 (1d28) :  INFO (logkit:16) - Content length for unknown type video/vnd.dlna.mpeg-tts is invalid - aborting

Is this something the web service should be returning?  If we know what, I may be able to get it added.

Progress I hope....

So I asked on NextPVR forums and got a new download call.  Bit more direct this one.

Plugging this url in gets me the following from plex:

2013-08-28 13:32:32,022 (23e4) : INFO (logkit:16) - Length: 278710752 Type: video/MP2T
2013-08-28 13:32:32,022 (23e4) : INFO (logkit:16) - Content length for unknown type video/MP2T is invalid - aborting

I see the video type has changed, and that a length is being reported - but something wrong with it.  This is a 265Mb video - not the biggest I have by a long shot (some of my other channels the files are about 6gb).  So was wondering if the 278710752 number is too large?

So can I confirm that this URL Service method is still expecting an HTTPLiveStream or is it expecting something else?

I believe NextPVR is just providing a direct file download - but I haven't yet seen the headers to know what's being passed back and forth.

Actually I just tried something else, I tried with PHT, previously this worked using the HTTPLiveStream request.  But this gets the same error as all teh other devices now about the content length being empty (the long url) or being invalid (the shorter url)

I assume the logs are when trying to play from Plex/Web and the extracts are from com.plexapp.system.log?

If so, it looks like Plex/Web thinks it can direct play but we want it to request transcode.

Try adding the parameter ext = 'ts' to the Callback routine like this:

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

Try with both methods/urls.

If that doesn't work try this code in ServiceCode.pys

def MediaObjectsForURL(url):
    return [
        MediaObject(
            parts                   = [
                PartObject(
                    key = Callback(PlayVideo, url = url)
                )
            ]
        )
    ]

In this code we have removed almost all parameters which should force a transcode(even for clients that can handle mpegts except PMC/PHT which very seldom/never requests transcoding)

No, actually in this case I was attempting from iOS. I thought I saw in the log that it said iPad://

Maybe that’s further up in the log, or in the pms log.

No, actually in this case I was attempting from iOS. I thought I saw in the log that it said iPad://

Maybe that's further up in the log, or in the pms log.

Using iOS should be fine. The iPad:// means that the URL-service failed and is using a fallback to try to find a video stream. 

You can still try the above and when/if you do

  1. Restart PMS(to clean all log entries)
  2. Try to play
  3. Post the Plex Media Server.log

Will do. Thanks for all your help in this. Would be so keen to get this Woking. Surely once this process is figured then any recording system could implement a channel.

I see there is already a media portal one but they may have a different way of providing a steaming link.

So I gave those two methods a go.  Tested both from IOS

The 2nd option (remove almost everything) resulted in the same messages.

But here is the log from the first attempt with the ext = 'ts'

I do note a 404 not found for both, but it downloads fine when I give firefox the urls mentioned.  Here is firefox downloading the live?oid= variant.

BTW attempting the channel with PLex/Web just gets me a this channel is not available.

Ok, can you please attach the Plex Media Server.log? This is located one directory up from where the plugin- and system logs are located.

Ok, can you please attach the Plex Media Server.log? This is located one directory up from where the plugin- and system logs are located.

This is the full plex log when using plex web to play one of the videos.

It doesn't say alot to be honest.

It strange because we don't even see that a transcode is requested, Plex can't recognize mp2t MIME, but will do if it is a local file? I'm confused. Also the default transcode/remux PMS method for iOS devices is a HLS playlist containing mp2t segments.(Someone please correct me if I'm wrong here)

Ok, one more option to try if you use the "live?oid=" URL that returns MIME mp2t:

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

def PlayVideo(url):
playList = “#EXTM3U” + "
"
playList = playList + “#EXT-X-VERSION:3” + "
"
playList = playList + “#EXT-X-TARGETDURATION:3600” + "
"
playList = playList + “#EXTINF:3600,” + "
"
playList = playList + url + "
"
playList = playList + “#EXT-X-ENDLIST” + "
"

return playList

Unfortuneately, no change in any of the messages for IOS.

And Channel unavailable for Plex/web (I can't test PHT at the moment).

What about a change of tack....instead of trying to access the video via http, what about from the file system.

Given this is windows the path will either be:

G:\Recordings\Thomas & Friends\Thomas & Friends_20130828_09000910.ts

or via the network

\\pvr\recordings\Thomas & Friends\Thomas & Friends_20130828_09000910.ts

Is it possible to put either of these notations into a plex channel?

Maybe like this(not tested):

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

def PlayVideo(url):
return Redirect(Stream.LocalFile(‘G:\Recordings\Thomas & Friends\Thomas & Friends_20130828_09000910.ts’))

Also, I found this(after doing some research about NextPVR since I don't really know so much about it):

http://gbpvr.com/pmwiki/pmwiki.php/Config/MVP#toc10

This indicates that all NextPVR installs have FFMPEG and if you can put in the config the parameters for FFMPEG it will be quite easy to let FFMPEG to transcode into MP4 with H.264 and AAC which would play on almost all clients. For those who can't PMS will be able to transcode just fine

UPDATE:

For live streams it would be better to let FFMPEG transcode into a HLS stream

Also, I found this(after doing some research about NextPVR since I don't really know so much about it):

http://gbpvr.com/pmwiki/pmwiki.php/Config/MVP#toc10

This indicates that all NextPVR installs have FFMPEG and if you can put in the config the parameters for FFMPEG it will be quite easy to let FFMPEG to transcode into MP4 with H.264 and AAC which would play on almost all clients. For those who can't PMS will be able to transcode just fine

UPDATE:

For live streams it would be better to let FFMPEG transcode into a HLS stream

No joy on the local file.  Was complaining that Stream.LocalFile didn't exist as a global function.  What I couldn't find in the API docs was there HTTPLiveStreamURL was listed to see waht the other options were.

And ffmpeg for nextpvr, is used for offline conversion of videos, rather than on the fly transcoding.  The web services allow for a VLC transcoded file, so I guess that's my next option to try.

No joy on the local file.  Was complaining that Stream.LocalFile didn't exist as a global function.  What I couldn't find in the API docs was there HTTPLiveStreamURL was listed to see waht the other options were.

And ffmpeg for nextpvr, is used for offline conversion of videos, rather than on the fly transcoding.  The web services allow for a VLC transcoded file, so I guess that's my next option to try.

Ok, I guess VLC is up

You could try adding:

PlexPluginCodePolicy
Elevated

to the Info.plist file, the Stream.LocalFile is perhaps not allowed if not in "elevated" mode

I had a look tonight at the response header for the live method. It seems to be putting out Content-Length. How can I find out what pms is expecting? I have seen in other sites that they had to accept Content-Length and Content-length