themacks / ply

An HLS server for the HDHomeRun Plus
20 stars 6 forks source link

Have ply send optimal video transcode based on roku-hdhomerun displaytype #6

Open pompous-stranger opened 9 years ago

pompous-stranger commented 9 years ago

I recently submitted a pull request (https://github.com/computmaxer/roku-hdhomerun/pull/5/files) to roku-hdhomerun that attaches a query string to the POST/tune channel method of wallop/ply to report what displaytype the requesting Roku is set to, i.e. SD or HD.

My proposed patch has ply use that information to select the optimal video transcode for the requesting display.

themacks commented 9 years ago

Thats certainly a good idea. I'd implement it a bit different though. On the roku-hdhomerun side, I would think you would want to set an actual GET variable, so:

url = getBaseWallopUrl() + "/channels/" + channelNum + "/tune?quality=" + getHDorSD()

Then in ply instead of checking that the entire query string matches, you can just check the GET variable.

hdhr_quality = "mobile"
get_data = web.input(quality="")
if get_data.quality == "HD":
    hdhr_quality = "heavy"
elif get_data.quality == "SD":
    hdhr_quality = "internet480"
devices = db.getDevices(dbase)
hdhr.stream.startStream(channel,devices,hdhr_quality)

The only issue I have with either implementation is that "mobile" is the default quality until the roku-hdhomerun channel is updated.

Thoughts?

pompous-stranger commented 9 years ago

Your code works for me in testing here (Roku XD|S aka 2100X and the HDMI Stick).

I took the implication in your last paragraph to mean you would prefer the device's Default Profile be left alone. Unfortunately the only way to do that is to strip the ?transcode= line out of the url entirely. I tried it blank aka ?transcode= and by ?transcode=default and my HDTC-2US was not happy. So now I'm passing the entire ?transcode=heavy/internet480 part in the hdhr_quality/quality variable, which is probably inelegant, but:

"Just to clear things up, when using a TC device, if no transcode option is specified in the HTTP URL (or in the set vchannel/set program command on the command line), the default is used." (https://www.silicondust.com/forum/viewtopic.php?f=68&t=18308#p109583)

Also I added the ffmpeg settings that work best for my devices in a comment. I suspect the one you're using is only tested with a Roku 3?

themacks commented 9 years ago

Yea I'm using it with a Roku 3. I don't see a way to have the default be HD either, but that shouldn't really be much of a problem to be honest. Feel free to submit another pull request with the updated code (since you've been able to test the SD side of things), and I'll test it here and merge it in.