HDMI for Channels

I've been trying a number of things with the Spectrum app on a Roku for several days to no avail. I suppose you could brute force a channel with a script by assuming the channel that pops up is the last one played, which always seems to be the case, but the script would be flying blind.

The Roku's API is indeed easy, and thanks for the example script snips. Wouldn't that be an interesting turn of the worm if these become the defacto easy option as a front-end for the HDMI input into Channels!

2 Likes

Yep, that would be an interesting twist indeed... now I'm thinking, which device has more exclusive apps, channels or other content otherwise unavailable to AppleTV, that could be leveraged somehow as yet another Custom Channel...?

https://www.fiercevideo.com/video/roku-channel-bulks-up-exclusive-content

For my "dual tuner HDMI" setup currently in motion, I may end up being happiest with one of each deployed... one Android TV dongle and one Roku, helping aggregate even more content on-demand to an AppleTV by way of Channels DVR served on a Mac... for the best of all worlds! Muuahahahaaaaa....

3 Likes

What is the likelihood that Roku's API is a permanent "feature"?

I am not well versed in their ecosystem, but what else uses this API and would likely continue to be supported forever?

I think the APIs to launch apps via native IP control on both Google TV and Roku devices will stick around for a long time, lots of high-end AV systems like Crestron, Control4 and Savant rely on that sort of remote control.

What's I'm not so sure of is, which specific 3rd party apps will allow deep-linking directly to specific live TV channels, like YTTV does? As well as whether or not their links are static long enough to rely on, for stuff like this. I feel like stringing together long macro commands of keypresses or searching channel names wouldn't be nearly as quick or reliable.

I believe the roku remote app on ios and android uses these apis

1 Like

Xfinity provides a web remote to control the cable box. Has anyone try to automate this from scripting tool?

LOL. Yeah I did see the humor in using a Roku device with Channels when I was testing it.

I do also like how easy it is to disable all of the ads on the Roku and remove every app except for YouTube TV. Though I presume one could remove apps from Google TV via adb and install an alternate "launcher."

On a side note, and I don't want to get too far off topic, but I did immediately notice, and confirmed by video frame comparison (view full screen, look at the grass/pitcher's mound/batter's disappearing nose), that at least for YouTube TV the Roku video is noticeably less detailed compared to the Google TV (Walmart "onn") device. Something to consider when choosing a device I guess.

It will definitely be less reliable because apps are updated on the regular and key sequences could change. Anything with an API will be way more reliable.

Interesting observation. Which Roku device are you using?

The video's labelling says Roku Express?

1 Like

Roku Express 4K+

Potentially millions of Android TVs and phones come with malware preinstalled | Ars Technica)

Google Support: Ensuring your Android TV OS device is secure

Google kills me sometimes. From the " Ensuring your Android TV OS device is secure" link:

What to do if your device isn’t Play Protect certified

If your device isn't Play Protect certified, we recommend you contact your device manufacturer. Ask for a fully tested, Play Protect certified device.

:rofl:

Has anyone here set this up yet with more than one HDMI source? Asking because I did that today, and am almost there, but not quite successful, and am guessing it's another oversight right under my nose.

For clarity's sake, these are my assigned IP addresses, everything is connected.

10.0.1.21 = Channels DVR server (Mac Mini)

10.0.1.172 = HDMI-IPTV stream box 1
connected to:
10.0.1.122 = Onn streamer (4K)

10.0.1.171 = HDMI-IPTV stream box 2
connected to:
10.0.1.97 = Chromecast with Google TV (HD)

On the original setup with just 1 tuner, it would tune directly to the desired channel. Now, with the added code for two tuners, the new one listed first, when I choose a show on a channel to watch via the guide, I see it is streaming the proper HDMI output, it's just not launching YTTV. It's not streaming the desired channel. I'm left staring at the newer device's Google TV home screen.

I've screenshot the error message below:

adb: more than one device/emulator

Is that expected? Maybe I've set this up incorrectly or my expectations are wrong.

Here's what I've done so far, to review the basics. I've added a second IPTV→HDMI encoder of the same make/model, gave it its own IP address, and plugged in a second HDMI source. This one is a 4K Onn streamer. I set it up with the same apps and developer access as I did on the first device, and I also authorized adb control. I confirmed YTTV is logged in, and working.

I copied prebmitune.sh, bmitune.sh, and stopbmitune.sh. I am using those for tuner 1 and prebmituneb.sh, bmituneb.sh and stopbmituneb.sh are for tuner 2.

I edited prebmitune.sh to match the appropriate IP address. I added the 2nd "tuner" to the main.go file and rebuilt the executable. But it's still not handling the final step of launching YTTV to the correct channel. Maybe these screens will help explain:

I created one Custom Channels setup for all these channels, the only IP address referenced there is the CDVR server itself. Do I need to create a second Custom Channels setup?

Anyway, hopefully there's something simple I'm missing and my adventures will help teach others too. Or maybe I incorrectly assumed this configuration is supported, and we're expected to use a single encoder with multiple HDMI inputs instead?

Regardless, I'm still having lots of fun with this experiment, so any advice or feedback appreciated.

Need to read full post. Might have to edit response. But for now are you specifying your android devices when you send adb commands. You have to do this like so:

adb -s 10.0.1.172 shell " blah blah"

The relevant script for each android device has to specify it so that adb can know which one to send the command to.

So for your second device that would use bmituneb.sh, prebmituneb.sh and stopbmituneb.sh you need to check each to make sure that the ip address for you second devices is correct.

1 Like

Hmm, OK, thanks. I did edit the main.go file before creating the new executable. Here's that excerpt:

The original bmitune.sh didn't have any IP addresses in it, so I copied it to bmituneb.sh as an identical copy. You're saying I should customize each of these lines (on both files?) to include explicit IP addresses each time, for every channel change command?

Here are my other files, if it helps any:

prebmitune.sh:

prebmituneb.sh:

And stopbmitune.sh and stopbmituneb.sh are identical:

Should I only be editing bmitune.sh and bmituneb.sh in order for these "dual encoders as tuners" to work? If so, how should this command, for example, be formatted instead?

 #NBC
if [ $1 = "nbc" ];then
HOME="input keyevent KEYCODE_HOME; sleep 1"
adb shell am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/9iwfkw-dMAw?onboard=1 -n com.google.android.youtube.tvunplugged/com.google.android.apps.youtube.tvunplugged.activity.MainActivity
fi
2 Likes

Yes every "adb" must change to "adb -s x.x.x.x"

2 Likes

Here is a copy of part of mine. Remember that my links might be different because I use an nvidia shield.

#!/bin/bash
IPADD="192.168.1.171:5555"
HOME="input keyevent KEYCODE_HOME; sleep 3"
PRIME1="input keyevent 19 19 19 19 19 19; sleep 2; input keyevent 21 21 21; sleep 2; input keyevent 22; input keyevent 23; sleep 1"
PRIME2="input keyevent 19; sleep 1"
PRIME3="input keyevent --longpress 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67"
SEARCH1="input keyevent 66; sleep 2"
SEARCH2="input keyevent 66"


#SMITHSONIAN
if [ $1 = "155" ];then
adb -s $IPADD shell "am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/E7D0KRZIUso?onboard=1"
fi

#NFL
if [ $1 = "723" ];then
adb -s $IPADD shell "am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/_pYg9qMKKIA?onboard=1"
fi

#GOLF
if [ $1 = "724" ];then
adb -s $IPADD  shell "am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/XK34g7QRvGk?onboard=1"
fi

Much of the variables laid out at the top are necessary only if we were tuning the the automation method and not with directly links. I just keep them here in case I ever have to revert back to using that google helper version.

You can change the links for the channels if they are different for you and use names instead of numbers like you seem to be doing. The variable to change is the IPADD variable at the top so that the adb program knows which android device to direct the command to.

Remember to do your "chmod +x bmitume.sh" on the file if you are creating a brand new one and discarding or moving the one you currently have.

You will then copy and exact replica of it when you have added all your channels

sudo cp bmitune.sh bmituneb.sh

You will then go into your newly created bmituneb.sh file and change the IPADD variable to the ip addres of your second device.

To test that you have them sending to the correct device in each case simply navigate to the folder containing them in your terminal and tune

./bmitune.sh 155

Or any channel number (or name) you have configured. You should see it tuned in vlc if that program directed to your encoder device ip.

Oh, and be sure to put the IPADD variable in your other two scripts for each device where you see it placed at the top in the example I have given

#!/bin/bash
IPADD="192.168.1.171:5555"
STOP="am force-stop com.google.android.youtube.tvunplugged; sleep 2"

#Stop Video
#adb -s $IPADD shell $STOP
adb -s $IPADD shell input keyevent  86

In this example I have chosen not to exit YTT for faster tuning in case I have something else to view or record.. The command just exits the live stream.

1 Like

Thanks @boukmandutty and @tmm1, that was exactly the nudge I needed. All of that made total sense, and I appreciate the time you took to explain it all.

I now have both encoder/tuners online and operational. I was able to set up concurrent recordings, one on each AndroidTV dongle. Even just tuning from channel to channel from the Live Guide on my AppleTV client is working better than before. I'm not sure how to manually select a "tuner" or to prioritize one over the other — or even how to discern which one is being used — but CDVR seems to be figuring out which one to use, on-the-fly.

I will say, the Onn TV device's interface feels a tiny bit faster than the CCwGtv dongle, but not enough to care which one takes priority, since both will be mostly dedicated to YTTV channels anyway. And both of their streams are getting encoded to 1920x1080 regardless. The overall user experience with these HDMI sources feels noticeably improved with an additional tuner to serve up these otherwise "lost" channels to CDVR. I've noticed channel surfing between then still has some hiccups and I have to move a bit slower than I do when surfing "regular" channels, but overall it's certainly working better and faster than it was before.

This is great.

I'd been thinking about asking about such tweaks, hoping to minimize the time it takes to surf to another channel, and your instructions beat me to the punch. I'm trying that out now and it seems to be working pretty well! Certainly faster than it was with the original stopbmitune.sh. bringing me back to the home page with every exit. With this tweak, any speed difference in the tuning of the Onn device vs. the CCwGtv dongle via the prebmitune.sh script is pretty much imperceptible. This change shaves off 2-3 seconds from each channel change, Now they only take 1-2 seconds each.

Again, this is great.

One piece I also found useful was incorporating a cheap HDMI splitter with the Onn streamer, so I could feed its output direcly to the TV when I want to play around with an Android TV device, and not be restricted to HD output via the IPTV encoder and Channels.

The next project of course, is straightening up all the equipment involved :laughing:

If anyone still reading is on the fence and scared to try this, don't be. I'm certainly no coder but here I am now with two IPTV>HDMI tuners feeding a bunch of desired live TV streams into Channels DVR. If the ingredients are within your budget and you want to maximize what your CDVR setup is able to work with, my advice is, don't be intimidated, the fantastic folks here are eager to help, and you may enjoy it as a fun and educational experiment too.

Thanks again, everybody!

4 Likes