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!

HDHomeRun V2 Plug-in

cal1cal1 Posts: 15Members
edited November 2012 in Channel Development
Discuss some hurdles with PMS and HDHomerun
Everyone,
As it is posted, at least for Windows, HDHomeRun Plug-in no longer works with PMS.
I am attempted to rectify that and upgrade the plug-in to V2 API and make it work with HDHomeRun Prime
I am new to Plex and python and have run into many hurdles.
Mainly, lack of documentation of V1 API and many API development examples are based on V1.
I have overcome most of them and now I am stuck on the last hurdle.
It seems that HDHOMERUN:// stream type is no longer available in PMS after PLEX9.
There is a chance this problem can be overcome in the plug-in.

There are a very specific steps that need to happen to watch a stream from a HDHomeRun device.
Note: Silicondust has created a command line control program (hdhomerun_config) for most OSs.

The following came from here:
http://www.silicondu...development.pdf

Here is an example of streaming to VLC.
Example: Streaming to VLC:
Run VLC: File, Open Network Stream. Select UDP/RTP. Specify port 5000.
Discover the HDHomeRun:
hdhomerun_config discover
Run a channel scan:
hdhomerun_config FFFFFFFF scan /tuner0 scan0.log
Set the physical channel:
hdhomerun_config FFFFFFFF set /tuner0/channel auto:651000000
Check sub-programs:
hdhomerun_config FFFFFFFF get /tuner0/streaminfo
Select a sub-program:
hdhomerun_config FFFFFFFF set /tuner0/program 3
Set the target:
hdhomerun_config FFFFFFFF set /tuner0/target <ip address of pc>:5000
Note: there is an option to pipe the stream to a program.
eg: hdhomerun_config FFFFFFFF save /tuner0 - | vlc -
When done streaming the HDHomeRun channel needs to set to none.
hdhomerun_config FFFFFFFF set /tuner0/channel none
If this step is not done, only the very first connection attempt to each tuner will be able to watch a stream. subsequent requests will be rejected.
I think most of this can be handled through python call method.
The biggest issue is the these two items.
  • You need to tell the HDHomeRun device to stream to a specific target.
In order to support the most clients we need to Plex to transcode if needed.
  • Being notified when the client has disconnected / stopped the stream.
The the steps might be.
1. Tell Plex transcoder to listen for a stream. return the port it is listening on and the port it is transcoding to.
2. Use the listening port to tell HDHomeRun to stream to the plex transcoder.
3. Tell the client to connect to the Plex transcoder on the output port.
Note: Not all clients can handle all stream types or video or audio codecs, so initially the focus would be PMC and ROKU. (So this might need to be wrapped with HTTP?)
4. Wait for Client to send stop or disconnect, so the HDHomeRun can stop the streaming.

I am willing to entertain all suggestions on how to solve this.
I did not necessarily want to brute force a solution, however; the V2 development documentation is sparse.

I am attaching my current version of the plug-in.
Note: This is extremely alpha code. I have left a lot of debug, test and original code in.

Please feel free to suggest any improvements to the existing code.
If you do suggest a better way to solve something, all I ask is you point me to some reference, so I can understand why that is a better choice.

Thanks for any assistance.
For the next few weeks I may not have access to my home network, so I may not be able try any solutions.
HDHomeRunV2.bundle.zip

Cal

Everyone,
I appreciate your debug logs, however; this plugin is a work in progress, and does not currently work.
It needs a lot of effort.
There a quite a few hurdles to solve before it is usable.

The purpose of this topic was two fold.
One, attempt to expose issue discovered as developing a plug-in goes.
Two, solicit help and ideas when I get stuck at different areas.

Unless your like to get your hands on code, or a glutton for punishment, please do not install this plugin.
When I get to a point where it might work, I will update this message.

Thanks for being patient.
Cal
«1345

Comments

  • bing281bing281 Posts: 6Members, Plex Pass
    Lets do this on github so we can all contribute.
  • EbatteEbatte Posts: 17Members, Plex Pass
    Thanks for attempting to get this working again. A lot of us HDHomerun users appreciate it.
  • mp81mp81 Posts: 3Members, Plex Pass Plex Pass
    I am very happy that someone has picked up the development on this again, I am not much of a programmer so i would not be too much help on that end, but would certainly assist in testing and looking for any bugs. At this time I have installed this and when trying to view any channels i am greeted with the following error: could not determine input format. The url for the channel is correct. Please let me know if you have any suggestions or if you would like any log files.
  • cal1cal1 Posts: 15Members
    bing281 wrote:

    Lets do this on github so we can all contribute.


    I was thinking about doing that, is just over the next few weeks, I will be too busy to do so.
    I know about github, I have just never created a project nor contributed.
    Since I am not going to be able work on this for the next few weeks, I figured I would at least get the ball started rolling.

    Just a question, should this be a branch(?) of the original project, or a new project?

    Cal
  • necorasnecoras Posts: 1Members, Plex Pass Plex Pass
    cal1 wrote:

    I was thinking about doing that, is just over the next few weeks, I will be too busy to do so.
    I know about github, I have just never created a project nor contributed.
    Since I am not going to be able work on this for the next few weeks, I figured I would at least get the ball started rolling.

    Just a question, should this be a branch(?) of the original project, or a new project?

    Cal


    Hey. I have an oldschool HD Homerun box. I'm hoping to get everything hooked up and streaming through a roku or two and possibly a ps3. Most of my programming experience is in C#, but I'd be happy to pitch in however I can.

    Is there more to installing this code than just dropping it in the PMS folder with all of the other bundles?

    Also, can someone suggest a good python development environment/debugging tool?
  • bing281bing281 Posts: 6Members, Plex Pass
    Usually you will make a branch when the other project is active and you have plans to merge that branch back into the project. However when the original developer is not there to merge your branch back into the master branch then you have an issue. However you can fork and just never re-merge. Ultimately the choose is your's and the appropriate thing to do here is to fork and never re-merge so that anyone that finds the original can also find your new project.

    So in terminology you should fork the project to under your user name.

    cal1 wrote:

    I was thinking about doing that, is just over the next few weeks, I will be too busy to do so.
    I know about github, I have just never created a project nor contributed.
    Since I am not going to be able work on this for the next few weeks, I figured I would at least get the ball started rolling.

    Just a question, should this be a branch(?) of the original project, or a new project?

    Cal
  • EbatteEbatte Posts: 17Members, Plex Pass
    I'd like to suggest that, in the interest of immediate gratification, a simple means to play existing .strm files would suffice as a start. One can use the hdhomerun config to create the stream files for the channels. We just first need a way to play them in plex. We don't have to have the channel discovery and labeling functionality working at first, like what was in the original hdhomerun plugin. If that could be planned for a future update it would be great, but not necessary in order to get the plugin working again.
  • cal1cal1 Posts: 15Members
    Eric b wrote:

    I'd like to suggest that, in the interest of immediate gratification, a simple means to play existing .strm files would suffice as a start. One can use the hdhomerun config to create the stream files for the channels. We just first need a way to play them in plex. We don't have to have the channel discovery and labeling functionality working at first, like what was in the original hdhomerun plugin. If that could be planned for a future update it would be great, but not necessary in order to get the plugin working again.


    Eric b,
    I would need to look at the contents of an STRM file to make sure, however; the issue I am facing I think would affect STRM files also.
    The code that handles the "HDHOMERUN://" protocol is missing as far as I can tell.

    This is totally different that asking a webserver for a specific file.
    I detailed the steps that need to happen behind the scenes to stream a simple video channel,

    And for me, I an looking at this as a way to stream to a Roku device.
    And as of right now, the stream must be transcoded for it to work.

    Cal
  • IanDBirdIanDBird Plex Employee Posts: 2,265Members, Plex Employee, Plex Pass, Plex Ninja Plex Employee
    I'm not sure how useful this is, but have you seen https://github.com/garybuhrmaster/python-libhdhomerun ?
  • EbatteEbatte Posts: 17Members, Plex Pass
    Have you seen this thread which seems to indicate the lines of broken code in the old hdhomerun plugin?
    http://forums.plexapp.com/index.php/topic/40110-0960-beta-bug-using-hdhomerun-plugin/page__p__280900#entry280900
  • EbatteEbatte Posts: 17Members, Plex Pass
    cal1 wrote:

    Eric b,
    I would need to look at the contents of an STRM file to make sure


    Here is the content of one of my .strm files for the hdhomerun atsc single tuner:

    hdhomerun://10213D2F-0/tuner0?channel=8vsb:599000000&program=3

    I hope this can help.
  • IanDBirdIanDBird Plex Employee Posts: 2,265Members, Plex Employee, Plex Pass, Plex Ninja Plex Employee
    Eric b wrote:

    Here is the content of one of my .strm files for the hdhomerun atsc single tuner:

    hdhomerun://10213D2F-0/tuner0?channel=8vsb:599000000&program=3

    I hope this can help.


    I think that the problem you might have is that the 'hdhomerun' protocol was something that used to be built into Plex Media Center. This is not something I believe that Plex Media Server will actually handle and therefore is unlikely to be able to transcode to another client (like the Roku). If I was looking into this channel, i'd investigate what libraries are available to access the HDHomeRun (like https://github.com/garybuhrmaster/python-libhdhomerun) and determine the stream format which can be obtained. If the underlying stream can be accessed, it's much more likely that PMS can read it and provide better support for all possible clients. I'm happy to help anyone with this development, I just don't have a device to actually test...
  • EbatteEbatte Posts: 17Members, Plex Pass
    The last time I tried to play the .strm file above in PMC it worked just fine. I'm curious if the change that removed support for the hdhomerun protocol was documented.
  • IanDBirdIanDBird Plex Employee Posts: 2,265Members, Plex Employee, Plex Pass, Plex Ninja Plex Employee
    Eric b wrote:

    The last time I tried to play the .strm file above in PMC it worked just fine. I'm curious if the change that removed support for the hdhomerun protocol was documented.


    So that's two separate things...

    The custom HDHomeRun 'protocol' is classed a legacy within Plex Media Center. It 'might' work but there no guarantees, and could be removed completely in the future.

    This is separate to '.strm' files which can also be played by Plex Media Center.

    However, neither of these mechanisms are supported by Plex Media Server and therefore it would not be possible to use these methods to produce a HDHomeRun channel that could be run on a Roku device.
  • MartinAylaMartinAyla Posts: 857Members, Plex Pass Plex Pass
    Really happy to see some development on this, looking forward to following the updates in this thread :)
  • cal1cal1 Posts: 15Members
    Eric b wrote:

    Here is the content of one of my .strm files for the hdhomerun atsc single tuner:

    hdhomerun://10213D2F-0/tuner0?channel=8vsb:599000000&program=3

    I hope this can help.


    Eric b,
    Thanks.
    That does help.
    You are subject to the same issues we are.
    "hdhomerun://" Informs PMC that a special sequence of commands are needed.
    "10213D2F-0" is the identifier of your your HDHomerun device.
    "tuner0?channel=8vsb:599000000&program=3" is the configuration the HdHomerun needs to be set to.

    There are a lot of additional commands and instructions that go on behind the scenes to make all this happen.
    My initial post contained the steps that happen when the center encounters "hdhomerun://" in the STRM file or link.
    If you are interested, I imagine there will be more discussions on how this needs to happen in future posts.

    For those that do not need transcoding, there are alternate solutions that might work for you.
    Multicast IPTV without transcoding (xupnpd+udpxy)
    This is an except from the RT-N56U custom firmware page.
    http://code.google.c...iki/MediaServer
  • cal1cal1 Posts: 15Members
    IanB! wrote:

    So that's two separate things...

    The custom HDHomeRun 'protocol' is classed a legacy within Plex Media Center. It 'might' work but there no guarantees, and could be removed completely in the future.

    This is separate to '.strm' files which can also be played by Plex Media Center.

    However, neither of these mechanisms are supported by Plex Media Server and therefore it would not be possible to use these methods to produce a HDHomeRun channel that could be run on a Roku device.


    lanB,
    Thanks for joining the discussion.
    I am still researching all the details, and learning as I go.
    Currently the HdHomerun device just forwards the core cable transport stream without transcoding.
    I think it is a MPEG-TS stream with MPEG2/AC3 video and audio codecs.

    I do not know if the DVB or ATSC transports are different.
    I do believe that PMS should be able to handle the the stream and codecs just fine.
    My first post identifies an example of using VLC as the transcoder.

    My only problem with this solution is that it is another piece of software that needs to be loaded.
    Also, I am not sure that VLC would inform the plugin if the user disconnected and therefore informing the HdHomerun to stop streaming.
  • IanDBirdIanDBird Plex Employee Posts: 2,265Members, Plex Employee, Plex Pass, Plex Ninja Plex Employee
    cal1 wrote:

    lanB,
    Thanks for joining the discussion.
    I am still researching all the details, and learning as I go.
    Currently the HdHomerun device just forwards the core cable transport stream without transcoding.
    I think it is a MPEG-TS stream with MPEG2/AC3 video and audio codecs.

    I do not know if the DVB or ATSC transports are different.
    I do believe that PMS should be able to handle the the stream and codecs just fine.
    My first post identifies an example of using VLC as the transcoder.

    My only problem with this solution is that it is another piece of software that needs to be loaded.
    Also, I am not sure that VLC would inform the plugin if the user disconnected and therefore informing the HdHomerun to stop streaming.


    There are definately some additional complexities with this plugin compared to other 'normal' ones, which will probably make it a little trickier. I don't have a device myself (although have been tempted to buy one in the past) but keen to help you with whatever I can. I'm away at the moment until the weekend but when I get back maybe we can have a chat (Skype, Plex Chat, ...) to work out what problems/questions we can identify that I can discuss with other Plex Developers to see what's possible, etc.

    Ian
  • cal1cal1 Posts: 15Members
    Everyone,
    I have finally:
    Created a GitHub repository.
    Forked over the original HDHomeRun.Bundle,
    And update the repository with all my changes.

    http://github.com/Ca...omeRunV2.bundle
  • cal1cal1 Posts: 15Members
    I also stumbled on this over at VideoLan Forum.
    http://forum.videolan.org/viewtopic.php?f=4&t=70404#p251103

    This was about HDHomerun and using VLC to transcode.
    "Yes, absolutely possible if you've enough CPU power.

    Something like this should do it - depending on CPU power available tweak vb, scale, fps, ab, channels, samplerate and possible other settings.

    IP_ADDR = IP address of the machine that should convert the stream
    PORT = TCP port remote clients must connect to"
    The code:
    #set channel and program
    hdhomerun_config FFFFFFFF set /tuner1/channel auto:FREQUENCY
    hdhomerun_config FFFFFFFF set /tuner1/program NUMBER

    #setup stream and transcode it
    cvlc udp://@:5000 :sout="#transcode{vcodec=h264,vb=600,scale=0.5,deinterlace,fps=20,acodec=mp4a,ab=64,channels=1,samplerate=11250,venc=x264{keyint=20,bframes=0}}:standard{access=http,mux=ts,dst=IP_ADDR:PORT}" -v

    #ask hdhomerun to begin streaming
    sleep 2
    hdhomerun_config FFFFFFFF set /tuner1/target IP_ADDR:5000
    "To view the converted stream on a remote client, simply start VLC -> Open Network Stream... -> Protocol: HTTP, Address: IP_ADDR:PORT -> Play"

    I will be looking at hard coding this logic as a proof of concept.

    Cal
«1345
Sign In or Register to comment.