SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-31-2015, 02:55 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Native HDHomeRun Prime Support

I was wondering if anyone is working on this for either Windows or Linux. If not I am willing to try and put some effort into it, but I am not sure where to even start. On windows it appears that the first issue happens very early on in the DirectShow discovery of the device. I am sure even after that is resolved there would still be a ton of additional issues to sory out.

Are there different options to support the HDHomeRun Prime that might be more cross platform than suing DirectShow? Should libhdhomerun be utilized on both Windows and Linux? Would there be some benefit to using it over Direct Show?
Reply With Quote
  #2  
Old 08-31-2015, 05:15 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
I think going forward most of these type of support should be in the form of a network encoder, NOT natively built into the core. This will future proof things far better. Of course, I really different tasks being segregated completely. I think that currently, PrimeNetEncoder is still relying on some windows .exe's, but I think all the features that are required are in the web interface of the HDHomeRun, including streaming the video, which ffmpeg could pull in. this would allow full cross platform capability, and not depend on any drivers or software being installed on a given device.

In all honesty, I am hoping to approach silicon dust about actually building network encoder support directly into the HDHomeRun firmware, which would be quite awesome... This can't be done until there is an extension made to the network encoder profile to enable streaming from an encoder to the server and having the write that stream to disk itself. With the current network encoder profiles, it will require the encoder (the HDHomeRun in this case) to have write access to network share, and I'm thinking that would be far more complication than it'd be worth.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #3  
Old 08-31-2015, 05:36 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by Fuzzy View Post
This can't be done until there is an extension made to the network encoder profile to enable streaming from an encoder to the server and having the write that stream to disk itself. With the current network encoder profiles, it will require the encoder (the HDHomeRun in this case) to have write access to network share, and I'm thinking that would be far more complication than it'd be worth.
This is already in the protocol. There's an 'uploadID' (seen in NetworkCaptureDevice.java) which can be passed to network encoders which then can be used when the encoder connects to the SageTV Media Server (MediaServer.java) which then grants it write access over the protocol. This is the same server that streams to SageTVClient...it has various extra commands that you probably never knew about such as directory listings (recursive as well), read/write capabilities and also transcode streaming (if that part even works, I don't recall what it was ever used for).
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #4  
Old 08-31-2015, 05:48 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Ahh, yeah, I had seen the UploadID, but didn't dig too deep into it, as it looked like it was tied deeply into the core network encoder/client connection. I'll have to do some reading.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #5  
Old 08-31-2015, 06:30 PM
KryptoNyte's Avatar
KryptoNyte KryptoNyte is offline
SageTVaholic
 
Join Date: Dec 2006
Posts: 2,754
When I read "native" support, I was thinking about the ability to play the stream directly in Sage, which is currently hit or miss (the "dump" method as SageDCT calls it, the networkencoder doesn't offer this option). If Sage was capable of rendering the direct stream, wouldn't that be a good precursor to whatever the tuner solution may be?
Reply With Quote
  #6  
Old 08-31-2015, 07:37 PM
mechling-burgh mechling-burgh is offline
Sage Aficionado
 
Join Date: Feb 2006
Location: Pittsburgh, PA
Posts: 406
Fuzzy if we would do network capture with the built network encoder would we not be just capturing the native stream like SageDCT. If so would we not be also caring over the same problems with comcast where sagetv would not play them sometimes. I know we can update the SageTV Clients with the newest mplayer builds but if I have been reading the forums correctly we won't be able to correct them in the extenders since they can not be upgraded them to the newest mplayer, correct.
Reply With Quote
  #7  
Old 08-31-2015, 08:36 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Before I knew about the above mentioned uploadID network encoder PUSH method, I had intended the future STREAM network encoder command to leverage ffmpeg as the stream sink on the server, which would result in fixing streams on the way to the HDD. I can't test the 'broken' streams that comcast sends out, as I don't have comcast. I had used dump for a few years with Charter and not experienced much of a problem - I now use ffmpeg, but mostly as a result of switching to PrimeNetEncoder instead of SageDCT.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #8  
Old 09-01-2015, 12:34 PM
Tiki's Avatar
Tiki Tiki is offline
Sage Icon
 
Join Date: Feb 2005
Location: Southwest Florida, USA
Posts: 2,009
One downside to the network encoders is I think they still do not support the "gapless" playback of live tv (you get a pause/glitch when the program you are watching is scheduled to end that lasts for a couple of seconds). Sage v7 added a fix for the pause with native recording sources, but not for network tuners.
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM
Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2)
,USBUIRT (multi-zone)
Source:
Comcast/Xfinity X1 Cable
Primary Client: Server Other Clients: (1) HD200, (1) HD300
Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE,
HDHR, HVR-2250, HD-PVR
Reply With Quote
  #9  
Old 09-01-2015, 01:08 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by Tiki View Post
One downside to the network encoders is I think they still do not support the "gapless" playback of live tv (you get a pause/glitch when the program you are watching is scheduled to end that lasts for a couple of seconds). Sage v7 added a fix for the pause with native recording sources, but not for network tuners.
I think they might. There is a SWITCH statement, that is supposed to change to a new file. It'd be up to the encoder to break the file at a good point and continue the stream in the next file for it to work.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #10  
Old 09-01-2015, 01:25 PM
mwnswiss mwnswiss is offline
Sage User
 
Join Date: Feb 2007
Location: Switzerland
Posts: 54
Quote:
Originally Posted by jvl711 View Post
I was wondering if anyone is working on this for either Windows or Linux. .... Should libhdhomerun be utilized on both Windows and Linux? Would there be some benefit to using it over Direct Show?
I did some work on Linux with the native/so/HDHomeRun2.0 library, made it to compile on OS/X, added with support from Taddeusz the libhdhomerun version 20150615, removed the hardcoded 2 tuner limit so it discovers now 4 tuners on respective models, fixed an issue with the DUAL EU model to properly handle DVB-T versus DVB-C. All should be merged in soon, else you can get it from my fork if you like to further test.

I don't have a PRIME, but if you would test the server on a linux (ubuntu 14.04 would be best) and describe what is not working, I may help. You would need to compile the HDHomeRun2.0 as debug, edit the HDHomeRun2.0 Makefile and add a line "DEBUG=1" on the top and make a clean.sh and buildall.sh afterwards. With debugging enabled on the SageTV server (setting in Sage.properties or via placeshifter) you will get the sagetv_0.txt logfile which will support identifying issues.

Be aware that there is still the blocker of recording video streams on 64bit, all the rest seems now pretty OK.

I don't think the libhdhomerun is used on Windows, but I didn't spend too much time. I recall windows is mainly using the BDA driver installed through the Windows HDHomeRun software.

All my changes here refer to the native plain libhdhomerun usage, NOT to the dvbhdhomerun kernel module usage!
__________________
Standard Intel PC with 4GB RAM Ubuntu 16.04 64bit
JVM version=1.8.0_121-b13 / SageTV V9 latest
HDHR DUAL EU with 2 DVB-C and HDHR EXPAND 4DC with 4 DVB-C
XMLTV using WebGrabPlus in Switzerland
Clients: HD200, Placeshift on OSX (limited) and Windows, Sage Android Client on ShieldTV and Tablets
Reply With Quote
  #11  
Old 09-01-2015, 01:33 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by Tiki View Post
One downside to the network encoders is I think they still do not support the "gapless" playback of live tv (you get a pause/glitch when the program you are watching is scheduled to end that lasts for a couple of seconds). Sage v7 added a fix for the pause with native recording sources, but not for network tuners.
You can do gapless playback/recording with network encoders...it's done on Google Fiber. As Fuzzy mentioned, the SWITCH command can be used for that. You also need to set the "fast_network_encoder_switch" property for that capture to enable it since most network encoders won't support it by default.

Ideally we should probably extend the protocol to query the network encoder itself for this capability, as that would be easier to setup (of course if its setup using network encoder discovery, then it can control the config that way).
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #12  
Old 09-02-2015, 01:24 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Quote:
Originally Posted by Narflex View Post
You can do gapless playback/recording with network encoders...it's done on Google Fiber. As Fuzzy mentioned, the SWITCH command can be used for that. You also need to set the "fast_network_encoder_switch" property for that capture to enable it since most network encoders won't support it by default.

Ideally we should probably extend the protocol to query the network encoder itself for this capability, as that would be easier to setup (of course if its setup using network encoder discovery, then it can control the config that way).
Jeff,

Would you mind explaining a little bit how to use the UploadID with the MediaServer. I assume the NetworkEncoder client gets both the filename and uploadID from the server. It can then either place the file directly to the path itself, or use the MediaServer to upload the file. Besides not needing direct access to the storage path and possibility of gapless playback, is there other benefits to using this methodology. Would this enable quicker start of playback?

As mentioned by Fuzzy I am using FFMPEG to clean up the stream. I am not exactly sure what is wrong with the "pure" stream from comcast, but it can causes pixelation, audio pops, and sometime no video playback. For some reason when the stream is put through FFMPEG with no conversion it is able to fix the stream in such a way that Sage has no problems with it. Should/Could this type of stream fix be moved to SageTV? I think if this was fixed by Sage it might speedup the time it takes for Live TV playback to start.

Thanks,
Josh
Reply With Quote
  #13  
Old 09-02-2015, 07:20 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
The UploadID isn't required for the gapless playback. All that is required is ensuring the streams are uninterrupted between files, meaning the transition happens at the right frame in the stream, and that the encoder is configured in sage as supporting this. What it essentially does, I believe, is since sage 'knows' it is the same stream simply continuing i a new file, it doesn't tear-down and recreate the playback graph.

The UploadID is a different thing, and yes, allows the encoder to push the stream to the server. I've been messing with it off and on the last couple days. Essentially, the encoder receives the uploadID with the START request, and then can EITHER write directly to the file, or open up a channel to the MediaServer port (8171). It requests permission to stream to the file via WRITEOPEN filename UploadID\r\n. If sage recognizes the uploadID, it allows it, and awaits "WRITE offset length\r\nDATA".

It seems to work on the server end for me, I'm having issues on my encoder end getting the data cleanly from ffmpeg. I am using Perl, trying to make my encoder as light as possible, and capturing the piped output from ffmpeg. PERL doesn't seem to have the umpf to do this without dropping data, so the stream gets corrupted. Going to have to move to a compiled c program for the streaming, most likely. In any case, avoiding samba share issues will be worth it if I can get this implementation to work.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #14  
Old 09-03-2015, 01:03 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by jvl711 View Post
As mentioned by Fuzzy I am using FFMPEG to clean up the stream. I am not exactly sure what is wrong with the "pure" stream from comcast, but it can causes pixelation, audio pops, and sometime no video playback. For some reason when the stream is put through FFMPEG with no conversion it is able to fix the stream in such a way that Sage has no problems with it. Should/Could this type of stream fix be moved to SageTV? I think if this was fixed by Sage it might speedup the time it takes for Live TV playback to start.

Thanks,
Josh
Looks like Fuzzy answered the question about uploadID.

Regarding stream repair...SageTV has extensive code for doing this already. It's what's been always used with any of the Digital TV systems we support. It actually remuxes the transport stream into a program stream and then writes that out. There is a facility in sage.media.format.MPEGParser for doing the remuxing from a Java level...but I don't know if that specific path of code still works because we stopped using that awhile ago. At the native layer though, it definitely works.

Ideally, we would add this to the MediaServer so that you can send in the MPEG2-TS that way (along with some config parameters for setting up certain aspects of the remux) so that it'll do it as it's receiving the data before it writes it to the file. This would then provide this general remuxing service to any network encoder easily.

You may want to give the remuxing code in MPEGParser a shot and see if it works...it's pretty easy to use, and if it works...then that's a huge step forward regarding this.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #15  
Old 09-03-2015, 01:57 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Thanks Jeff and Fuzzy. This is great info. I am going to try and implement all of it. I agree that if we could pull all of those things off it would be pretty good implementation. I also would like to add tuner locking support as well. I would like to add all the other features first though.

Josh
Reply With Quote
  #16  
Old 09-03-2015, 02:07 PM
Taddeusz Taddeusz is offline
SageTVaholic
 
Join Date: Nov 2004
Location: Yukon, OK
Posts: 3,919
One thing that would be nice to support is being able to do is "gang" tuners if what is scheduled to record is in separate programs of the same physical QAM channel. I know Cox cable here in OKC has some of the local networks that way. I know it's also a feature that the DVB crowd has requested in the past.
__________________
Server: i5 8400, ASUS Prime H370M-Plus/CSM, 16GB RAM, 15TB drive array + 500GB cache, 2 HDHR's, SageTV 9, unRAID 6.6.3
Client 1: HD300 (latest FW), HDMI to an Insignia 65" 1080p LCD and optical SPDIF to a Sony Receiver
Client 2: HD200 (latest FW), HDMI to an Insignia NS-LCD42HD-09 1080p LCD
Reply With Quote
  #17  
Old 09-03-2015, 04:32 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Quote:
Originally Posted by Taddeusz View Post
One thing that would be nice to support is being able to do is "gang" tuners if what is scheduled to record is in separate programs of the same physical QAM channel. I know Cox cable here in OKC has some of the local networks that way. I know it's also a feature that the DVB crowd has requested in the past.
That's not something that would be, architecturally, impossible. But it would take changes in both the capture device/lineup systems, AND the scheduling system. There would need to be a way to identify channels that are over the same stream, which is not incredibly easy for sage at this point with the way remapping is done, which would obfuscate simply using tuning information. The scheduler would also need a check early on in it's algorithm to see if a given channel is already being recorded from a previous scheduler pass and use it. That's code changes touching parts of sage that are VERY important, and VERY complicated, so this is a down the road goal, but not something to be rushed into.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #18  
Old 09-04-2015, 02:05 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
I have made some pretty good progress. Here is how I am currently recording to Sage.

hdhomerun_config.exe (UDP) -> ffmpeg (STDOUT) -> SageTV MediaServer (TCP). This is working pretty well. I also made some tweaks to ffmpeg. I am setting analyzeduration and probesize. Channel changes are now taking ~3-4 seconds instead of ~6 seconds.

I also have discovery working properly. I even have discovery working correctly when PrimeNetEncoder is started as a runnable class from Sage.

Now I am looking to see if I can utilize the MPEGParser class to remux the file instead of ffmpeg. I have a few questions on how to use the class that I am hoping you guys might be able to help me with.
1. Is this library available in Windows environments? What file is this library compiled into.
2. What is the mode variable. I am assuming it is either REMUX_TS or REMUX_PS. Is that the input or output format?
3. What is the channel variable? I see in remuxFile it is set to 0.
4. Here is what I think the usage would look like. openRemux(REMUX_TS, 0, outputStream), pushInitData for first 8192 bytes, muxy.seek(0), pushData starting a position 0 till the end of stream, muxy.close().
Reply With Quote
  #19  
Old 09-08-2015, 03:50 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by jvl711 View Post
Now I am looking to see if I can utilize the MPEGParser class to remux the file instead of ffmpeg. I have a few questions on how to use the class that I am hoping you guys might be able to help me with.
1. Is this library available in Windows environments? What file is this library compiled into.
2. What is the mode variable. I am assuming it is either REMUX_TS or REMUX_PS. Is that the input or output format?
3. What is the channel variable? I see in remuxFile it is set to 0.
4. Here is what I think the usage would look like. openRemux(REMUX_TS, 0, outputStream), pushInitData for first 8192 bytes, muxy.seek(0), pushData starting a position 0 till the end of stream, muxy.close().
1. Yes, should be....it appears to be in the DShowPlayer DLL file.

2. I'd think it would be output format...it should autodetect input format.

3. It's likely for multiple program transport streams; 0 would mean use the 'primary' one (whatever that would be defined as).

4. Yeah, looks right....the remuxFile method in there is what'd I'd use as my guide to try it out (and looks like you already were thinking that).
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #20  
Old 09-08-2015, 06:11 PM
jvl711's Avatar
jvl711 jvl711 is offline
Sage Fanatic
 
Join Date: Jan 2004
Posts: 825
Thanks Jeff,

I will write a test program and load it as a runable in Sage to make sure the library is loading in Windows. I was having a hard time tracing everything that was going on in the C/C++ code, so I was not sure if/when the calls were available.

Do you have any interest or opposition if I were to attempt to add functionallity to sage to allow for tuner locking? I was thinking of adding a get/set method to CaptureDevice that would default to return not locked. I know that the sage core would need to be modified to check to see if the tuner is locked prior to utilizing the tuner for live or recorded tv.

Quote:
Originally Posted by Narflex View Post
1. Yes, should be....it appears to be in the DShowPlayer DLL file.

2. I'd think it would be output format...it should autodetect input format.

3. It's likely for multiple program transport streams; 0 would mean use the 'primary' one (whatever that would be defined as).

4. Yeah, looks right....the remuxFile method in there is what'd I'd use as my guide to try it out (and looks like you already were thinking that).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about HDHomeRun (Not Prime) TechBill Hardware Support 27 06-13-2017 08:24 AM
Does SageTV 7 support HDHomerun Prime? LabyrinthMike Hardware Support 14 02-18-2015 04:32 PM
HDHomeRun Prime on Woot 5/24 ranger The SageTV Community 6 05-25-2012 07:10 PM
HDHomerun Prime? cenwesi Hardware Support 26 04-19-2011 05:40 PM
HDHomeRun 68 channel remap limit / Native QAM tuning? taylork Hardware Support 40 07-11-2008 04:50 AM


All times are GMT -6. The time now is 02:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.