Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Plex MythTV LiveTV Channel/Plugin

unsoberunsober Members, Plex Pass Posts: 9 Plex Pass

I just purchased plexpass and was hoping to be able to do the livetv from myth, but there really weren't any good options out there. I wrote a channel to do it. As of now, it just does the LiveTV. It doesn't list the recordings. With some tweaking, I set up a plex libraries to look at the mythtv recordings folder - so i didnt have a need for recordings yet. I'm not a fantastic developer, It's a little dirty and could probably be all done completely within the bundle, instead of the myth side php i used. My setup is ubuntu and separate VMs for plex and myth. HDHomeRun Prime. I have not done any load testing so don't know what the CPU/mem requirements are, but i've been able to do 2 streams on multiple vcpu VMs without any issue.

I have a basic Channel/Plugin built, which does the initial communicating with Myth to get the channels/icons and then calls the php file on the mythserver to initiate the livetv and start streaming through plex. Keep in mind, this is not using the myth streaming/transcoding like I've seen a few people try to do - The Plexserver is accessing the raw video stream just like any standard client does (ie: mythfrontend/kodi) and then based on the plexclient, the plexserver does the transcoding. I didnt think it made sense to transcode once with myth and then another time with plex.

Ya place the bundle in the plugin directory obviously (may have to change permissions to the plex user) and there's a config option when you launch the channel to set the mythtv hostname and/or ip and the categories you want to display. It always displays the "All Channels" and "Channels Recently Watched" category, but you can add things like Sitcom, Movie, anything ya like. It will create a group and only return those listings that have categories which fall within the group

The stream.php file (txt file attached) gets put in the web server root directory (ubuntu:/var/www/html) of the myth server as stream.php. Would need mythweb running of course.

It's not perfect and I see plenty of room for improvement. I don't have much down time, so I don't know if I'm going to be able to get this further than it is, but if someone who is a little smarter than me wants to take it and run with it....it's all yours. I haven't done a huge amount of testing, but It does what i needed it to do both from a pc and my iphone.

Couple things I noticed...
Rewinding and Fast-forwarding is funky. On the phone it works semi well, the web-browser, not so much. I think i have a way to account for it, just didn't have time to do it yet.
Channel Icons are sized weird, but better than nothing
In my environment - for the most part, all the channels are always there. But, for some reason a few disappear. If you go back to the list a minute later - the missing ones show up. They're randomly missing from results from the MythAPI call, so I'll be looking into why Myth is fumbling the results to see if there is a better way to do it.

If I do end up making any updates, i'll post them

Channel

Options

Categories

Category Listings

Listing Details

MythTV Live Channel playback

Comments

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass

    Unable to see the channel:
    I just copied the unziped "bundle" in the plug-ins directory changed the permission and ownerships and copied the stream.php in the webserver directory. I also disabled the compatibility check on the plex server side. Long story short I am unable to see the channel.
    Any thoughts? Thank you

  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass
    edited March 12

    Which OS ya running for plex and the version of plex? (i'm assuming some flavor of linux since ya were changing permissions). Also, could you look at the plugin log file to see if it is throwing any errors.
    You may have to restart plex, though I haven't needed to do it with ubuntu. And I didn't have to Disable capability checking. I just tried it with it checked as well and the channel still showed up for me, so I don't think that has anything to do with it.

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass
    edited March 12

    I am running Ubuntu 16.04 with PMS 1.4.3.3433. I did perform a reboot with no luck.
    This is the output of plugin log:
    [...]
    581: CRITICAL (core:615) - Exception starting plug-in (most recent call last):
    File "/usr/lib/plexmediaserver/Resources/Plug-ins-03e4cfa35/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/core.py", line 608, in start
    self.sandbox.execute(self.init_code)
    File "/usr/lib/plexmediaserver/Resources/Plug-ins-03e4cfa35/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 256, in execute
    exec(code) in self.environment
    File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/MythLive.bundle/Contents/Code/init.py", line 13, in
    ALL_CHANNELS = 'http://'+MYTHTV_HOSTNAME+':6544/Guide/GetProgramGuide?StartTime='+utc_datetime.strftime("%Y-%m-%dT%H:%M:%S")+'&EndTime='+(utc_datetime+datetime.timedelta(seconds=60)).strftime("%Y-%m-%dT%H:%M:%S")+"&Details=true"
    TypeError: cannot concatenate 'str' and 'NoneType' objects

  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass

    Try downloading the bundle again from the original post and giving it another shot.

    The Default preference for mythtv server was blank from the start which i apparently didnt run into. I just made the default localhost so the bundle should load. I'll eventually make an update to the code to do the error checking.

    When it does load, you'll need to click on the gear and configure the host. All the other settings can be left alone. You may want to eventually update the categories though.

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass

    Great, thank you, that worked. I can see the channel now. While I am currently unable to see the livetv stream in plex, I was able to verify that my mythtv server switched the encoder to the right channel and started recording.
    Any idea why the channel is not able to display the picture?

  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass
    edited March 12

    My guess is you are using a different tuner than me (i'm using hdhomerun prime). I updated the bundle again and put in options to set the video container/codec. Based on what the container and codecs, you would have to update those settings.

    I found these codecs available from an older post
    h263
    h264
    vp6
    wvc1
    divx
    div4
    xvid
    theora

    I havent searched for the audio codec or container options yet (i know mp4 is available as a container). I'll take a look for those a bit later and post

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass
    via Email
    I am using a ceton 6 tuner pci cable card
  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass
    edited March 12

    What do you normally use the play tv (mythfronend/kodi/something else?)? Do know know what codecs it uses when you play it now? I looked up that card and it's talking about all different formats.

    I added another option to set the content-type for the video returned from the myth php, though i was changing that to all sorts of things and it still worked fine for me, so i dont think it really makes an impact. I uploaded a new stream.php and bundle.

    If i change those initial codec settings to something other than what the hdhomerun is delivering (mpeg2) it causes it to kick off the livetv recording but not play on plex, so If you can narrow down the codecs being used I think that would help as I think that's probably the issue.

    We'll have to start diving into the logs if ya can't identify the ceton codecs being used.

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass
    via Email
    I use a combination of mythfrontend and kodi running on various hardware
    throughout my house. I just double checked and my recordings as well as
    live tv uses H.264 as the codec
  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass
    edited March 13

    can you try the following, if you haven't done so already...

    Which container is used by the MythTV Tuner?
    mp4

    Which video codec is used by the MythTV Tuner
    h264

    Which audio codec is used by the MythTV Tuner
    ac3

    What are the max channels the MythTV Tuner will provide?
    6 (may want to try 2 as well)

    What is Content-Type to be delivered from the MythTV Server?
    video/mp4

    If that don't work, you can take a look at the kodi log when starting to play a tv recording, that might be helpful in troubleshooting as well.
    Key items would be...
    CDVDVideoCodecFFmpeg::Open() Using codec: MPEG-2 video
    Creating audio stream (codec id: 86019, channels: 6, sample rate: 48000, no pass-through)

    Theres also an option when playing a video on kodi to display the video details which would give ya some good info. Need to look for Player process info> video decoder & audio process stream.

  • unsoberunsober Members, Plex Pass Posts: 9 Plex Pass

    Updated both the bundle and the stream.php file.

    Stream
    Fixed the disconnecting in between shows and having to restart, it plays continuously though the change in shows now.

    Bundle
    Eliminated the fixed duration that was in there for livetv, it was set to 4 hours. It wasnt needed from what i can tell.
    Added program info start and end times to the channels for descriptive purposes. Shows up on the computer app and/or web browser, doesn't show itself on mobile app

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass

    Sorry it took me so long to respond.
    I finally managed to get all the information for your questions together.

    Which container is used by the MythTV Tuner?
    ts

    Which video codec is used by the MythTV Tuner
    MPEG-2

    Which audio codec is used by the MythTV Tuner
    ac3

    What are the max channels the MythTV Tuner will provide?
    6

    What is Content-Type to be delivered from the MythTV Server?
    video/ts

    I will play with the settings this afternoon and report back if I have any luck streaming livetv

    Thank you

  • c00l8thomec00l8thome Members, Plex Pass Posts: 7 Plex Pass

    I played around with the different settings and I am still not able to get a picture. I do see that the tuners change to the selected channel but no luck on actually seeing a picture.
    My settings are:
    1) bytes 48000
    2) container mpgets
    3) video codec mpeg2video
    4) audio codec ac3
    5) max channels 6
    6) bitrate 8000
    7) content-type: video/ts
    Please let me know if I need to change the settings ... thank you

Sign In or Register to comment.