google / sagetv

SageTV is a cross-platform networked DVR and media management system
http://forums.sagetv.com/
Apache License 2.0
267 stars 174 forks source link

Transcoding (placeshifter plumbing) for miniclient users #340

Open ojones-sage opened 7 years ago

ojones-sage commented 7 years ago

Would it be possible to add a whitelist of non-transcoding ip subnets (either in UI or properties) to the next release? I am hoping to test the miniclient over a "fat" LAN link.

Ultimately hoping to bump the feature request to increase the transcoding resolution settings exposed to stuckless's miniclient and see about switching to a more modern file format but believe those are more involved feature requests. This is being active discussed with stuckless and others.

https://forums.sagetv.com/forums/showthread.php?t=64522&page=2

Narflex commented 7 years ago

You can already set this in the placeshifter settings dialog. But it's totally insecure for playing back non MPEG container content.

Jeff Kardatzke Sent from my Android

On Jul 18, 2017 8:13 AM, "ojones-sage" notifications@github.com wrote:

Would it be possible to add a whitelist of non-transcoding ip subnets (either in UI or properties) to the next release? I am hoping to test the miniclient over a "fat" LAN link.

Ultimately hoping to bump the feature request to increase the transcoding resolution settings exposed to stuckless's miniclient and see about switching to a more modern file format but believe those are more involved feature requests. This is being active discussed with stuckless and others.

https://forums.sagetv.com/forums/showthread.php?t=64522&page=2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/sagetv/issues/340, or mute the thread https://github.com/notifications/unsubscribe-auth/ANEIDKyrH3iNKnoyE4-3AAY9meu9Izyuks5sPMs9gaJpZM4ObfwB .

ojones-sage commented 7 years ago

Thanks Jeff - I have tested this using the pc placeshifter. However I thought the miniclient (impersonates a hdxxx?) forced transcoding for any remote ip. Re security - I personally connect my sites over a IPSec tunnel so can avoid opening unhardened ports.

Narflex commented 7 years ago

It shouldn't transcode if you explicitly disable it, that's why that option is there. ☺️

Jeff Kardatzke Sent from my Android

On Jul 18, 2017 10:21 AM, "ojones-sage" notifications@github.com wrote:

Thanks Jeff - I have tested this using the pc placeshifter. However I thought the miniclient (impersonates a hdxxx?) forced transcoding for any remote ip. Re security - I personally connect my sites over a IPSec tunnel so can avoid opening unhardened ports.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/sagetv/issues/340#issuecomment-316134940, or mute the thread https://github.com/notifications/unsubscribe-auth/ANEIDD_inii8oyO8YWrVxcBMEz1AKoeQks5sPOmVgaJpZM4ObfwB .

CraziFuzzy commented 7 years ago

@ojones-sage I think transcoding or not is determined on the client-side, so if you wanted a white-list capability, you'd need to do that in the client. I think when you are talking about miniclient, you're talking about the android version, correct? In there, I think the setting for 'Streaming Mode' is what you want. Pull I believe is the mode you are looking for to grab the original stream untouched.

ojones-sage commented 7 years ago

CrazyFuzzy & Jeff - I tried to test this in my lab setup (am sure you are right) but haven't been able to recreate the conditions yet. Will test site to site this weekend. Thanks for the encouragement and input!

ojones-sage commented 7 years ago

CraziFuzzy & Jeff,

It's been a few weeks (needed access to fast remote link to test) but I was able to test the effectiveness of the "pull" option in the android miniclient. We continued the discussion on the forums (link below) including log snippets but basically UI appears to override the detected bandwidth and put bandwidth for comparison against the "min bandwidth for no transcode" level at 1k below the level specified in properties if the LAN is <10MB. Is there any way to get at the 10MB override and disable that logic?

https://forums.sagetv.com/forums/showthread.php?p=609365#post609365

"The bandwidth is first measured and reported. Then if it's less than 10M but >= the 'min_for_no_transcode' value, it "fakes" the bandwidth to be 1k less than then no_transcode value. That's why you see 1999k. In your first case, the BW was 5M so met that window. I don't claim to know how the logic is supposed to work but that's what's in the code.

It sure seems like that setting effectively does nothing below 10M and 10M is the hard min limit."

Narflex commented 7 years ago

Oh yeah...I forgot about that condition. That was added when people started having higher bandwidth connections and we're getting errors in pull mode because the firewall didn't have that port open (and shouldn't for security reasons).

If you want, you can simply add another property setting to that conditional and then use that to disable this for yourself. I'd approve a change like that. :)

ojones-sage commented 7 years ago

Jeff / CrazyFuzzy- Please be gentle my coding skills are not on the same level as even the amateurs here.

Am I hunting up the right tree by adding an additional item to the conditional that looks up a new entry in the Properties file (I assume that is what Sage.getInt does)? I'd make that entry have a default value of 0 such that if it is set in the properties file to 1 then transcoding would be forced (and if that entry is missing then the miniclient bandwith control functions work as they appear to be intended.

Thread.currentThread().setPriority(oldPriority);
             if (!mcsr.isLocalConnection() && uiBandwidthEstimate < 10000000 &&
-                uiBandwidthEstimate >= Sage.getInt("miniplayer/min_bandwidth_for_no_transcode", 2000000))
+                uiBandwidthEstimate >= Sage.getInt("miniplayer/min_bandwidth_for_no_transcode", 2000000) && Sage.getInt("miniplayer/wan_prevent_push", 0)=1)
             {
               if (Sage.DBG) System.out.println("Detected non-LAN connection under 10Mbps but above set limit (" + uiBandwidthEstimate +
                   "), force it to transcode mode");
Narflex commented 7 years ago

Almost, replace this text:

Sage.getInt("miniplayer/wan_prevent_push", 0)=1

with

Sage.getBoolean("miniplayer/wan_prevent_push", true)

and that would be correct. Boolean is better to use than an int in this case since it's just an on/off setting (and the int value would have needed a '==' after it to test for equality rather than the single '=' which assigns a value). :)

On Sun, Aug 20, 2017 at 1:05 PM, ojones-sage notifications@github.com wrote:

Jeff / CrazyFuzzy- Please be gentle my coding skills are not on the same level as even the amateurs here.

Am I hunting up the right tree by adding an additional item to the conditional that looks up a new entry in the Properties file (I assume that is what Sage.getInt does)? I'd make that entry have a default value of 0 such that if it is set in the properties file to 1 then transcoding would be forced (and if that entry is missing then the miniclient bandwith control functions work as they appear to be intended.

Thread.currentThread().setPriority(oldPriority); if (!mcsr.isLocalConnection() && uiBandwidthEstimate < 10000000 &&

  • uiBandwidthEstimate >= Sage.getInt("miniplayer/min_bandwidth_for_no_transcode", 2000000))
  • uiBandwidthEstimate >= Sage.getInt("miniplayer/min_bandwidth_for_no_transcode", 2000000) && Sage.getInt("miniplayer/wan_prevent_push", 0)=1) { if (Sage.DBG) System.out.println("Detected non-LAN connection under 10Mbps but above set limit (" + uiBandwidthEstimate + "), force it to transcode mode");

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/sagetv/issues/340#issuecomment-323608466, or mute the thread https://github.com/notifications/unsubscribe-auth/ANEIDKRMpYBtEoJ6heUQ-5N6FQa4Rgwtks5saJGUgaJpZM4ObfwB .

-- Jeffrey Kardatzke jkardatzke@google.com Google, Inc.

ojones-sage commented 6 years ago

Jeff or others - I'm wondering if anyone can help me test the fix referenced in the issue above? I'm not sure it worked as we intended.

I am trying to make the android miniclient stream without transcoding and am running into further bandwidth test based stumbling blocks. Basically for asymmetric connections (Cable) on the client-side, I have observed unpredictable bandwidth tests in the logs that results in push with transcoding down to 352x240. It appears that the non-lan flag is getting set no matter what settings I apply in the Sage.Properties file. I have tested the connection extensively (I am able to achieve near wire speed downloads from my server over a hardware VPN). Due to the difficulty of getting reliable bandwidth test results is there another way we could hardcode the transcoder on/off?

I raised this issue with Stuckless to see if he thought there would be a client-side fix but he believes it needs to be resolved on the server side. My source TV content is h264 generated by OPENdct in a MPEG2 TS container after real time transcoding via FFMPEG. Theoretically I can control the bandwidth of the live TV source material from the tuner side if neccesary if I can get control back over the transcoding between miniclient and server.

Thanks in advance for any ideas where to look!

Narflex commented 6 years ago

Post the server log file...that'll be needed to help figure out what's going on here.

ojones-sage commented 6 years ago

Thanks Jeff - The best time-chop in the log occurs @Tue 1/2 22:28:04.349 (The first few tests were conducted after forcing the connection over a 10baseT connection which resulted in a detected connection speed of ~874Kbps). The client and server were both local but set-up on different subnets after the first two connections the rest were run without speed restriction (other than the shield's wifi link).

sagetv_0.txt Sage.txt

ojones-sage commented 6 years ago

Also as a cross test - after switching the "prevent push" variable to true in Sage.Properties I reran the test (again forcing a 10baseT connection) and the log file is attached (time chop @ Tue 1/2 23:16:02.556). sagetv_0._test.txt

Thanks in advance for any insights!

Narflex commented 6 years ago

Do you have this set in the Sage.properties file on the server?

miniplayer/wan_prevent_push=false

If not, then that's your problem. :)

ojones-sage commented 6 years ago

Hi Jeff - I do have miniplayer/wan_prevent_push=false in my properties (see my sage.properties file renamed as Sage.txt in the post from two days ago.

Narflex commented 6 years ago

Then you must not be running a version of SageTV with that change in it. Because if that property is set to false, then there's no way it can be printing this log entry:

Detected non-LAN connection under 10Mbps but above set limit

ojones-sage commented 6 years ago

Jeff - Based on your comment above I installed 9.1.8 over 9.1.7 (which I thought posted dated the wan_prevent_push change) to remove any doubt about the version. I am not sure if 9.1.7 just missed the commit above or something else was wrong but I think this is now working! Of course slow connections won't stream correctly uncompressed, but on connections that are fast enough (and just don't test properly) streaming is feasible. In case anyone is curious, 9Mbps is insufficient - audio has pops / video frames are dropped, 13 Mbps appears smooth but with some audio hiccups and 17 Mbps does the trick (both audio and video are acceptable). Source material is cable-card recorded in 1080p (transcoded during record) via OpenDCT. Streaming speed was controlled via pfSense's QOS limiter in the router.

66cobra commented 6 years ago

I was uber-excited about ability to stream non-transcoded at first, but after playing with it over the past week, I came across a couple of use cases that had some issues - for example - if you use a mobile device that clears the threshold, but connection is unreliable (crappy wifi, or lte coverage changed due to physical location, e.t.c.) it can cause issues on the mobile client, since the setting is in the Sage.properties. Have you guys considered tying it to ye olde "Media Extender Conversion Quality" under detailed settings? That way the client will be able to control the stream quality. If I understand correctly, that setting was for MediaMVP, so most likely it is no longer used...