HDMI for Channels

I found you a solution of sorts. If you tune the channel from the guide once it turns on cc. If you tune it a second time it turns it off:

#/bin/bash
IPADD=192.168.1.171

#STARZ
if [ $1 = "842" ];then
sh /opt/opendct/stopbmitune0.sh
adb -s $IPADD shell "am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/-Y5vv28gO_I?onboard=1; sleep 9"
adb -s $IPADD shell " sleep 8; input keyevent 19; input keyevent 20; sleep 1; input keyevent 21 21 21 21 21 21; sleep 1; input keyevent 22 22; sleep 1; input keyevent 23"
fi

The first thing is to stop YTT if it is playing. Next it tunes the channel of choice. Finally after waiting for the channel to tune it turns on cc (or turns off if it is on).
If you go back to guide or stop and then tune the same channel it should tune and do the opposite with cc (turn it off if it is on or on if it is off).

You might have to tweak the timing based on your device. What I have here works on a NVIDIA shield.

3 Likes

That is amazing — thank you for that!

My first HDMI encoder box just arrived, I will be diving in to tinker after dinner tonight. I’m excited about this new project.

2 Likes

@tmm1 with people starting to have a play around with this I was thinking,

Would it be worth having some sort of indication (unsure the best implementation of this) on the guide if someone is already tuning a channel so that other users/clients will know and can join the same channel or avoid changing the current channel (with it being hdmi there can only be one?)

Not sure if I had it set up weird but the other day I was trying to quickly switch channels when the custom channel was set to 1 stream limit and was getting an error that all the streams were taken.

I had one encoder a while back dusted it off hooked up to my Shield fired up the HDHomeRun App tuned to HBO and can watch in Channels DVR.

#EXTM3U
#EXTINF:-1 channel-id="Testencoder" channel-number="1.2" tvc-guide-placeholders="86400",Testencoder
http://192.168.50.237:8080/0.ts

1 Like

Next Step is to create an M3U for all channels then find a way to change the channels in the HDHR App.

Hm, I wonder if would be possible to use fHDHR as a tuner for one of these encoders and then present it as a HDHR tuner to channels.
Setup a origin within fHDHR that would essentially run the adb command to change the channel.

2 Likes

I dont remember where I backed up my adb scripts for that app when I used to feed it into sagetv. It was so clunky and atrociously designed. How do you get rid of the osd after tuning? Does it automatically disappear?

1 Like

Yes it disappears ... I just wanted to show it was the HDHR App. The m3u would have to launch a command to change the Channel.

2 Likes

I purchased and returned a “URayCoder UHE265-1L.“ It was one of the h265 models with an hdmi output. It worked well enough but the video was terribly over saturated and there was nothing I could do to correct that.

Switched it out for this “J-Tech Digital” model. It’s h264 only but has no image saturation issues. If you keep the input and output at 720p60 the cpu load drops to ~25% and the latency drops so much you can actually use the remote with the connected device without having to wait two seconds for the results of each button press to be displayed. I’m good with this. There is likely a “URayCoder” or other brand of this exact device. The software is basically the same (very bad and full of security issues lol).

I have it connected to the 4k “onn” brand Google device from Walmart ($20).

I found it better to set the device itself to go to sleep after being idle for 20 minutes instead of having it sleep immediately when the stream closes. I just have it configured to force quit the YouTube TV app before and after loading a channel via a URL to make sure it doesn’t load a channel behind the timeline where the user can’t fast forward to “live.”

I really only did this because I thought it would be an interesting project but was surprised at how effective it is. With some refinement I think this could definitely be a reasonable way to get streaming TV content into Channels DVR.

3 Likes

Got HDMI Box #1 installed last night. Pretty cool, thanks for the heads up about that eBay deal, @boukmandutty! So I factory reset it, see that it defaults to a 192.168.1.xxx address. I had to change my laptop's IP to connect directly and manually configure it for my network.

I also turned on HLS, under the "Access" menu, it was "closed" (?) by default:

The stream I'm using for this box is http://10.0.1.171:8080/hls/show.m3u8
Still learning as I go...

1 Like

I left my HLS off and used the MPEGTS stream. I think that would require less resources and complexity on the encoder, and should reduce latency.

In your screenshot I think that's listed as Main HTTP and available at http://10.0.1.171:8080/main`

2 Likes

How do you go about firing these commands/scripts? Instead of using terminal every time?

3 Likes

You would need to install golang (apt install go, brew install golang, or download from golang.org)

Then download the git repo for androidhdmi-for-channels

Run go build in that folder and it will make a androidhdmi-for-channels program you can run. That program acts as a proxy between the DVR and the ADB device, and runs the shell scripts for you when the DVR requests a specific channel or closes a stream.

4 Likes

OK, thanks for that, I changed HLS back to "closed," and then rebooted the box, and I've got it now streaming with http://10.0.1.171:8080/main instead, as my Custom Channel 99000. I also changed Stream Format, from HLS to MPEG-TS, to match.

Now to figure out the Mac server side of things, and adb commands to tune into NBCU channels via YTTV. I'll hopefully get to that in a few days.

I found my old hdhomerun app from my windows days on teh sagetv website. Opendct would be used to execute


adb.exe -s 192.168.1.215 shell am force-stop com.silicondust.view; monkey -p com.silicondust.view -c android.intent.category.LAUNCHER 1; sleep 5; input keyboard text %c%; input keyboard text 0; input keyevent KEYCODE_DEL; sleep 2; input keyevent 66;

As you know %c% is the channel number sagetv would put in so if you put an actual channel number in there it should tune if you test the command (provided the interface hasn’t changed since I last messed with it)

A tuning script might be something like:


@echo off
set "myvar2=%2"
set "myvar=%1"
if "%myvar%"=="" set /p "myvar=Enter Value: " || set "myvar=Default Value"
goto %myvar%

rem first device ip
:192.168.1.171
goto %myvar2%
goto end.

rem second device ip
:192.168.1.215
goto %myvar2%
goto end

:731
rem TBS
adb -s %myvar% shell (commands for button sequence to tune channel goes here)
exit

Should be easy to convert into a linux script if needed.

3 Likes

Here you go:
bmitune.sh:

#!/bin/bash
IPADD="192.168.1.171:5555"

#SYFY
if [ $1 = "752" ];then
adb -s $IPADD shell "am force-stop com.silicondust.view; sleep 1"
adb -s $IPADD shell "monkey -p com.silicondust.view -c android.intent.category.LAUNCHER 1; sleep 5"
adb -s $IPADD shell "input keyboard text 752 ; input keyboard text 0; input keyevent KEYCODE_DEL; sleep 2; input keyevent 66;"
fi

#USA
if [ $1 = "732" ];then
adb -s $IPADD shell "am force-stop com.silicondust.view; sleep 1"
adb -s $IPADD shell "monkey -p com.silicondust.view -c android.intent.category.LAUNCHER 1; sleep 5"
adb -s $IPADD shell "input keyboard text 732 ; input keyboard text 0; input keyevent KEYCODE_DEL; sleep 2; input keyevent 66;"
fi

I recall when testing this that I had to do the weird thing you will see where I put in a zero then delete it. It is because of how the app was set up and how the build in keyboard would behave when certain buttons were pressed while running it.

You will need a stop script similar to the one that we use to make sure it has stopped before tuning:
stopbmitune.sh


#!/bin/bash
IPADD:"192.168.1.171"

adb -s $IPADD shell "am force-stop com.silicondust.view; sleep 1"

If you dont do that it will keep running in the background after you are done. Your pre-tuning script will depend on your particular needs.

1 Like

Still waiting for someone to get this to work with the Spectrum TV app. I can get rid of my over the WAN setup if this works out.

The problem you’re going to run into is the Spectrum app is not supported on Android TV. You could try sideloading the mobile version, which might actually work in this case because you wouldn’t need to use a remote to control it

Curious… What does the Spectrum TV app run on?

1 Like

I’m using the Spectrum App on Apple TV, recording through the encoder.