Unofficial Kodi HDHomeRun DVR PVR Client

Kodi Community Development

Moderator: TVJunkie198

Post Reply
dugiehowsa
Posts: 113
Joined: Sat Mar 21, 2015 1:19 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by dugiehowsa » Fri Jul 05, 2019 10:54 am

djp952 wrote:
Wed Jul 03, 2019 10:50 am
Also, for dugiehowsa, I found nothing I could point to in the PVR that could cause your issue. The only memory leaks I was able to detect are when the DirectX system (Windows only) is shutting down in Kodi, and when SQLite is shutting down since I have an "automatic extension" set up, there are a couple benign, very very small, memory leaks there. All of this only occurs when the system is unloading anyway, not while it's running. I see that at least one other Kodi user has the same problem you do, didn't sound like they are using this PVR.

If I find anything that might help, I'll let you know. I think this is squarely a Kodi-level concern, but as time allows I don't mind poking around Kodi at all.
Thanks for taking the time to look into it. I appreciate it. I'll report back if I receive any new news while continuing my investigation.

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Fri Jul 05, 2019 3:32 pm

ddejager wrote:
Sun Jun 23, 2019 6:07 am
djp952 wrote:
Sat Jun 22, 2019 7:33 pm

Wanted to let you know I haven't forgotten about this, but I did run into some problems trying to implement it. It seems very possible, I'm just having problems getting the tuner to actually send me data back. It's probably me messing up how to ask it for the channel I want based on the information I have. My intention is to still have this in v2.1.0, perhaps as something flagged as 'experimental'.
Thanks. This is NOT critical, just an experiment, so do whatever is important first.
I redid the basics of this again after an unfortunate mistake I made deleting a git branch (doh). It seems to work well enough in and of itself, I just need to clean it up and re-add the plumbing that I also lost. Move some stuff around here and there. I did solve the problem I was having before I nuked it, I needed to add a wait loop around the stream read function, libhdhomerun doesn't wait on it's own.

So, this is still coming. There was a bump in the road, but I replaced the tire and back to where I was.

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Sat Jul 06, 2019 12:28 pm

Happy Saturday gang! Beta release for the folks waiting to test a couple requested features:

Version 2.2.0~beta1 (Build 7126)
  • Add support for legacy RTP/UDP streaming directly from tuner devices
  • Add "Append repeat indicators to applicable episode names" setting
  • Add "Preferred tuner streaming protocol" advanced setting
  • Prevent error logging of every channel when EPG has been temporarily disabled due to an error
Downloads (Leia only): https://1drv.ms/f/s!AgEGEEVzGNq-i_pBT94_zBJgTPOmOg

As with all unofficial builds you have to grab the .zip/.appx from OneDrive and install it manually. I was careful to follow the Kodi version rules and they assure me that "2.2.0" will be flagged as newer than "2.2.0~beta1" so this shouldn't screw up auto-update. You can revert to v2.1.0 using the built-in Update function in Kodi, or when v2.2.0 goes live it should also auto-update to that. We'll see I guess!

Add support for legacy RTP/UDP streaming directly from tuner devices

This is the thing I'd love to see tested out a bit before back-porting it to Jarvis and Krypton. This should fulfill the request to allow for UDP streaming via libhdhomerun, but let me 'splain how this works. By default the PVR will always try to use your RECORD engine for Live TV so that timeshifting support is there. The Advanced option "Stream Live TV channels directly from tuner device(s)" bypasses this and automatically falls back to hitting a tuner directly. Until now there was only one way to do this - using the HTTP interface of the tuner. Now there is a second fallback mode. If the stream from RECORD fails, and the HTTP stream from the tuner fails, the PVR will now fall back to legacy RTP/UDP.

You can force legacy RTP/UDP for all Live TV by enabling "Stream Live TV channels directly from tuner device(s)" and then changing the new child option "Preferred tuner streaming protocol" to "RTP/UDP".

Note that the streaming code for RTP/UDP is pretty simple, there isn't going to be a lot of tolerance for network issues or drop-outs. If the stream stalls or drops out for too long, Kodi is going to close the channel on you. The implementation I have will wait up to one second for data before telling Kodi "I don't have anything for you". On my network I've never been without data for more than 15 milliseconds, so one second seems like a reasonable maximum. If you play with this and run into significant issues as compared with using HTTP let me know, maybe it can be tweaked more.

Enjoy your weekend!

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Mon Jul 08, 2019 3:07 pm

dugiehowsa wrote:
Fri Jul 05, 2019 10:54 am
djp952 wrote:
Wed Jul 03, 2019 10:50 am
Also, for dugiehowsa, I found nothing I could point to in the PVR that could cause your issue. The only memory leaks I was able to detect are when the DirectX system (Windows only) is shutting down in Kodi, and when SQLite is shutting down since I have an "automatic extension" set up, there are a couple benign, very very small, memory leaks there. All of this only occurs when the system is unloading anyway, not while it's running. I see that at least one other Kodi user has the same problem you do, didn't sound like they are using this PVR.

If I find anything that might help, I'll let you know. I think this is squarely a Kodi-level concern, but as time allows I don't mind poking around Kodi at all.
Thanks for taking the time to look into it. I appreciate it. I'll report back if I receive any new news while continuing my investigation.
No problem. I actually finished going through the entire thing with the special debugger and only made a minor change to deal with the SQLite leaks at exit. That was actually my fault, I wasn't calling the shutdown function. Very minor and would only happen when the module is unloaded so no impact during runtime.

I put in a couple PRs for SiliconDust's libhdhomerun to clean up some small Windows leaks I found earlier today. Again, nothing that would cause any problems at runtime and only on Windows. The original PR I sent to Kodi for the bug I found when I started looking at this was accepted for Matrix, and if they do another Leia it should be there as well. Once again, though, a Windows exclusive problem. The log spam concern in the PVR was checked in and is available in the "2.2.0~beta1" in the previous post if you want to install that to limit the log chatter, while unlikely, there certainly could be some correlation with excessive logging.

I hope the gang at Kodi can find this one for you, I'm about as close to 100% certain as I can be that it's not something I will be able to fix for you :( If I happen to be playing in Linux and see it, I'll of course try to capture it as best I can and assist with your thread on the Kodi forums with any additional info I can add.

Let me know if there is anything else you think I can help with, I'm always happy to try. But hey -- it wasn't a lost effort by any means -- found and proposed some fixes so totally worth the time!

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Mon Jul 08, 2019 7:35 pm

I realize I'm talking to myself, but I wanted to ask everyone a question as well. Has anyone recently seen "Malformed JSON" in their logs or missing EPG data?

I ask because the problem seems to have disappeared and if so I think I know why. cURL accidentally disabled HTTP pipelining support in version 7.65.0, which seems to coincide when I stopped seeing this. There was no degradation in performance (the SD backend doesn't support HTTP/2 yet AFAIK) for the EPG load, and cURL has fixed this oversight in their next release. To that end, what I've done in the PVR is tell cURL not to use any pipelining/multiplexing features so it will stay disabled after the next cURL update.

For now I've taken "Malformed JSON" concerns off the list of TODOs. If anyone is still running into this I would love to know. It has been a long standing mystery and I may just be manufacturing a root cause that happens to fit the symptoms ...

Ken.F
Posts: 2148
Joined: Fri Apr 05, 2013 9:20 am
Device ID: 1041A706, 1043EB32, 104BAD9E, 13168DC5, 1322A7AC
Location: West Rockhill, PA

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by Ken.F » Tue Jul 09, 2019 4:38 am

djp952 wrote:
Mon Jul 08, 2019 7:35 pm
I realize I'm talking to myself, but I wanted to ask everyone a question as well. Has anyone recently seen "Malformed JSON" in their logs or missing EPG data?
You aren't talking to yourself. I read everything posted in this thread but most of the time I don't have anything worthwhile to say other than thank you for your work.
I don't remember seeing anything about Malformed JSON in the logs. That's probably because I don't read logs unless there's a problem, and I haven't had a problem in a long time.

ddejager
Posts: 115
Joined: Tue May 06, 2014 2:26 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by ddejager » Tue Jul 09, 2019 5:05 pm

Add support for legacy RTP/UDP streaming directly from tuner devices
Thank you. I missed the notice from the forum about the update so I just loaded it now. I will test a bit and report back. RTP/UDP does appear to work, but glitches are more visible (I guess if a key frame gets a glitch it stays around for a bit and is not corrected by http).

Regarding missing EPG data, I have seen that in the past (as recently as today with 2.1.0 and Kodi 18.2. I just upgraded my firestick to 18.3 and your 2.2.0~beta1 so I'll see if it still happens. When it happens when I start up Kodi, the guide is all blank until I manually clear the guide data.

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Tue Jul 09, 2019 5:52 pm

ddejager wrote:
Tue Jul 09, 2019 5:05 pm
Add support for legacy RTP/UDP streaming directly from tuner devices
Thank you. I missed the notice from the forum about the update so I just loaded it now. I will test a bit and report back. RTP/UDP does appear to work, but glitches are more visible (I guess if a key frame gets a glitch it stays around for a bit and is not corrected by http).

Regarding missing EPG data, I have seen that in the past (as recently as today with 2.1.0 and Kodi 18.2. I just upgraded my firestick to 18.3 and your 2.2.0~beta1 so I'll see if it still happens. When it happens when I start up Kodi, the guide is all blank until I manually clear the guide data.
If I recall I think your EPG problem was where it didn't find any channels at startup? Kodi 18.3 should help that, I found why it wouldn't add new channels after startup and they put it in that release. Definitely let me know my friend.

ddejager
Posts: 115
Joined: Tue May 06, 2014 2:26 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by ddejager » Wed Jul 10, 2019 4:26 pm

So I've upgraded to Kodi 18.3 plus the beta version of the PVR Client in three different environments (my house, and two friend's houses). All seem to be working well. In my friends houses there is NO recorder and previously they would experience the video buffering spinning circle. This no longer happens when they are using the UDP option. (though they do get occasional pixelation if a UDP frame get corrupted.

In one of my friend's house prior to the upgrade there was a strange problem before the upgrade. When starting a channel sometimes the channel would never sync up correctly...picture breaks up and buffering attempts made, but no real success unless you switch away from the channel and come back (or stop and restart the channel)...then it would start correctly. Interesting thing is that this was happening on a FireStick 4K with an ethernet connection to the network and with the tuner also having an ethernet connection to the same network, all in the same house. I never figured out why the startup in Kodi did not work reliably. No problem with the HDHomeRun app on the same firestick. I've not tried with HTTP on this device with the new beta and 18.3 (yet)...only with UDP which seems to be working.

So far the EPG has been loading properly as well.

Anyway, it looks like your beta is working well. Thanks!

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Wed Jul 10, 2019 4:35 pm

Cool. Did I ever tell you guys my UDP joke? You may not get it and I really don't care. Bah-dum-dum :mrgreen:

I can duplicate the pixelation on a Pi over WiFi. I'll see if I can tell if it's the way I'm waiting for data or as you indicated just UDP being UDP.

I'm glad it's a useful feature. Let's call it a.keeper!

jasonl
Silicondust
Posts: 14425
Joined: Sun Oct 28, 2007 9:23 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by jasonl » Wed Jul 10, 2019 5:13 pm

Image

ddejager
Posts: 115
Joined: Tue May 06, 2014 2:26 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by ddejager » Wed Jul 10, 2019 5:21 pm

djp952 wrote:
Wed Jul 10, 2019 4:35 pm
Cool. Did I ever tell you guys my UDP joke? You may not get it and I really don't care. Bah-dum-dum :mrgreen:
:D

Rickt1962
Posts: 136
Joined: Tue Dec 01, 2015 2:17 pm

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by Rickt1962 » Fri Jul 12, 2019 6:37 am

Trying to track down a glitch. I have HDhomerun 3 tuner on Comcast running on WMC-7 recording TV shows automatically and MCEbuddy scanning them removing commercials and moving the MP4 video to My Cloud so I can watch them with KODI on Rasberry's.

I have a GIGABYTE box with LibreElec 18.2 just started using 2.1.0 everything works great watching live TV but for some reason the shows I watch are being sent to my Main P.C drive D: folder "Recorded TV shows" over the home network which MCEbuddy monitors and scans them to MY Cloud. Very strange ! Anyone else seeing this ?

http://ix.io/10fk

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Fri Jul 12, 2019 7:25 am

Rickt1962 wrote:
Fri Jul 12, 2019 6:37 am
Trying to track down a glitch. I have HDhomerun 3 tuner on Comcast running on WMC-7 recording TV shows automatically and MCEbuddy scanning them removing commercials and moving the MP4 video to My Cloud so I can watch them with KODI on Rasberry's.

I have a GIGABYTE box with LibreElec 18.2 just started using 2.1.0 everything works great watching live TV but for some reason the shows I watch are being sent to my Main P.C drive D: folder "Recorded TV shows" over the home network which MCEbuddy monitors and scans them to MY Cloud. Very strange ! Anyone else seeing this ?

http://ix.io/10fk
LibreELEC/Kodi isn't going to do anything like that on it's own, and it would also need an SMB share set up to get to your Windows box at all. I'm not sure the log link you attached is the one you expected? That appears to be from Kodi 17.4 running on an Amazon device.

Did you install the HDHomeRun DVR service on the Main PC? When you watch Live TV, the HDHomeRun DVR service creates temporary MPEG files on disk. I think it creates a subdirectory called "Live TV" or something very similar to that, that is where it will put them. Perhaps MCEBuddy is picking these up on you and needs an exclusion?

You can test this by telling the PVR to Stream Live TV channels directly from the tuner(s) instead of the DVR engine. It's in the addon settings under Advanced. Turn that on temporarily, test it out, see if the issue stops. Since the stream isn't cached by the DVR engine no files should be created anywhere.

This is all I can think of, anyway.

djp952
Posts: 940
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD

Re: Unofficial Kodi HDHomeRun DVR PVR Client

Post by djp952 » Fri Jul 12, 2019 1:37 pm

ddejager wrote:
Wed Jul 10, 2019 4:26 pm
So I've upgraded to Kodi 18.3 plus the beta version of the PVR Client in three different environments (my house, and two friend's houses). All seem to be working well. In my friends houses there is NO recorder and previously they would experience the video buffering spinning circle. This no longer happens when they are using the UDP option. (though they do get occasional pixelation if a UDP frame get corrupted.
I can get some bad pixelation on my Windows laptop over Wifi as well streaming an HD channel. On the same machine I ran hdhomerun_config to compare what I was seeing via the PVR with what that tool says, and unfortunately I got what I was expecting to get -- lots of network errors:

Code: Select all

hdhomerun_config XXXXXXXX save /tuner2 null
....n...n.n...n..n.n.n..n.nnnn.nnn.n.n.............n.n.n..........nn.nn.
-- Video statistics --
70489 packets received, 0 overflow errors, 30 network errors, 0 transport errors, 0 sequence errors
I'll throw some breakpoints in the code and see if there is anything I think I can do to improve it, but it's looking like UDP is just being UDP. I fear it will come down to what kind of problems are preferred on less than ideal networks -- with UDP you may miss packets of data but won't cause incessant Kodi buffering. with HTTP (TCP) you get reliable data but can't deliver it fast enough to Kodi.

Having this behavior on my Windows laptop is ideal for trying to do something about it, though. I'll spend some time on it this weekend and see if there are any tricks I might be able to play. Low probability, though - libhdhomerun is pretty tight - it would be rather arrogant of me to think I could somehow do better (I can't).

I'll let you know one way or the other!

Post Reply