HDMI for Channels

Thanks! I got it to work manually, still trying to figure out the go syntax to run the Windows batch files instead of bash shell scripts, go build is bombing out. Looks like I need to escape some chars.

Here's my bmitune.bat to launch NBC channels via the app:

@echo off
set p1=%1
set link=""
set IP=192.168.1.94:5555
set PKG=com.nbcuni.nbc.androidtv

if "%p1%"=="nbc" set link=nbctve://live/nbc
if "%p1%"=="msnbc" set link=nbctve://live/msnbc
if "%p1%"=="usa" set link=nbctve://live/usa
if "%p1%"=="syfy" set link=nbctve://live/syfy
if "%p1%"=="cnbc" set link=nbctve://live/cnbc
if "%p1%"=="golf" set link=nbctve://live/golf

c:\platform-tools\adb -s %IP% shell am start -a android.intent.action.VIEW -d %link% -n %PKG%/com.nbc.nbctvapp.ui.main.view.MainActivity

For anyone wondering how to get the Android default activity for an app (the -n param in the start command above), the command is:
adb shell cmd package resolve-activity --brief "pkgname"

where pkgname is the NBC package name here (com.nbcuni.nbc.androidtv), you get these by running:
adb shell pm list packages "filter"
where filter is nbc in this case to only show the NBC packages

I might be miss-understanding what you are saying... but all you need to do is make sure the main.go file says the right names... mine has this

	tuners = []tuner{
		{
			url:   "http://192.168.1.168/0.ts",
			pre:   "C:\\androidhdmi-for-channels-main\\prebmitune.bat",
			start: "C:\\androidhdmi-for-channels-main\\bmitune.bat",
			stop:  "C:\\androidhdmi-for-channels-main\\stopbmitune.bat",
		},
		{
			url:   "http://192.168.1.168/4.ts",
			pre:   "C:\\androidhdmi-for-channels-main\\prebmitune2.bat",
			start: "C:\\androidhdmi-for-channels-main\\bmitune2.bat",
			stop:  "C:\\androidhdmi-for-channels-main\\stopbmitune2.bat",
		},
		{
			url:   "http://192.168.1.168/8.ts",
			pre:   "C:\\androidhdmi-for-channels-main\\prebmitune3.bat",
			start: "C:\\androidhdmi-for-channels-main\\bmitune3.bat",
			stop:  "C:\\androidhdmi-for-channels-main\\stopbmitune3.bat",
		},
	}

I see 2 big advantages for YTTV users to use the NBC app for the NBC channels: 1-the links appear to be more permanent and 2-it doesn't take up one of your 3 allowed streams

I am going to modify my bmitune.bat file when I get home to use a combination of NBC and YTTV (only for the non NBC channels, like BBCNews)

BTW - isn't Bravo an NBC channel?

Yeah had to figure out (again) that you need to escape the backslashes in Windows, ugh.

1 Like

I'd be interested to hear how this works out when launched this way. When using as Stream Links, I found the NBC app to be an unreliable train wreck, loading some times, not loading other times, and giving me errors at times.

1 Like

Looking over here at Stream Link URLs - have you all tried this format?

nbctve://live/$NETWORK

Yay, got it all working with the Onn 4K and the Uray encoder! Pretty slow to wake and start the NBC app then have the app start the stream, from what I've seen it's about 20-25 secs total. That's fine for recording which is all need, don't care about live. I'm using H.265, 1920x1080@60fps, 8k VBR, MPEG-TS.

Here's my pre and post tune scripts for anyone curious, I force close the app and put the box to sleep after a tune which is why the app takes longer to startup I'm sure.

prebmitune.bat

@echo off
set IP=192.168.1.94:5555

c:\platform-tools\adb connect %IP%
c:\platform-tools\adb -s %IP% shell input keyevent KEYCODE_WAKEUP
rem c:\platform-tools\adb -s %IP% shell input keyevent KEYCODE_HOME

stopbmitune.bat

@echo off
set IP=192.168.1.94:5555
c:\platform-tools\adb -s %IP% shell am force-stop com.nbcuni.nbc.androidtv
c:\platform-tools\adb -s %IP% shell input keyevent KEYCODE_HOME
c:\platform-tools\adb -s %IP% shell input keyevent KEYCODE_SLEEP
1 Like

Yeah if you look at my bmitune.bat script above I put those in as params for the NBC app and it worked. Thanks!

I'm hoping here that with the pre- and post- tune scripts that allow for stopping the app that it might work ok with a fresh start every time. Who knows, but I don't have much choice anyway since I'm not subbing to YTTV.

FWIW I went back and edited earlier posts that had wrong channel mappings to hopefully minimize any confusion. I also wanted to add, that the 14 channels I've got set up are still working fine for me, the links haven't changed, so the verdict may still be out on their relative (im)permanence.

This is good to keep in mind. Not just for folks who don't have YTTV's unlimited plan, but also for folks set up to be sharing the YTTV family subscription in other households.

Not a bad idea, I may mix-and-match too. Maybe just for a few channels. I'll experiment over the weekend.

Yeah, as interactive apps their UI's are pretty bad, but if we can launch straight to a live channel's stream reliably, and just use Channels UI for everything else, it seems like something to consider. That YTTV splash / outer space scraping sound is growing more annoying by the hour and this would cut down on that, at least...

Yes.

One thing to consider about H265 is that it makes comskip take a MUCH MUCH longer time to scan the files after recording stops. In my case it was quite excessive so I landed back on H264.

By the way, I came across this:

It appears to be a semi-automated way to get the channel links for YTTV - perhaps it could be the basis for a future way of keeping YTTV links refreshed...

2 Likes

Nice find. It's a bit out of date as the url and some other things have changed but it's generally the same.

That being said, if you are going to be in the dev console you might as well just scrape the page using JavaScript.

Paste in developer console on tv.youtube.com/live:

const channelRows = document.querySelectorAll("div.container.ytu-epg-row");
results = []
for (i = 0; i < channelRows.length; ++i) {
   var network = channelRows[i].querySelector(".network-title").innerHTML
   var targetLink = channelRows[i].querySelector(".tenx-thumb > a.yt-simple-endpoint.style-scope.ytu-endpoint").href
   if (network && targetLink && targetLink.includes("watch")) {
      results.push({
         networkName: network,
         targetLink: targetLink
      })
   }
}
console.table(results);

This will give you a nice table of data like this:

And if you want JSON data you can right click on the "array()" at the bottom and choose "copy object" to copy a JSON representation of the results to your clipboard.

It should be a pretty simple task to write a small script to take this JSON data and spit out a bmitune.sh file and an m3u playlist. I will do that tomorrow if someone doesn't beat me to it.

4 Likes

Has anyone been able to run the NBC app on the Onn TV 4K? I am getting "unable to connect" "please check your internet connection and try again" on two different boxes - one connected to the encoder and one to a TV.

Had some high strangeness this evening. My newer mecool device prompted for are you still there within 3 minutes after starting a recording?

At this point not sure what is going on as the stream just started. I am sticking with the original amazon fire tv 4k ultra until I can get this figured out. Will start testing random shows on my 2nd tuner with these new devices - more info to come!

EDIT: I have added checks to my tune in script and keep alive handler. I am now making note of what station is "tuned in" and during my keep alive checks if the stream is not playing it will attempt to recover by tuning in again.

Keep alive checker: Monitors streams and restarts if needed. Also attempt to keep the player thinking someone is hitting buttons. · GitHub
My tune in script: tmm1/androidhdmi-for-channels hulu tuner script · GitHub
My stop script: Stop playing media · GitHub

Hopefully this can give inspiration for anyone else wanting to make the process a bit more refined/robust.

1 Like

Yeah I wouldn't have posted all that info about how I got it to work if it didn't actually work. :grinning: But not long after I had it working on the ONN yesterday, I tried to launch NBC again from the channels guide just to see how it worked over time and I got an endless stream of three dancing dots in the middle of the NBC app. I then tried to run the NBC app manually and it got content not available when I selected the live tab. Force close the app, clear cache, clear data, still didn't work.

So then I installed the app on my Samsung phone and it also got content not available, so it wasn't an ONN issue. Strangely enough, the app worked fine on my Apple TV. Go figure, but I hope this isn't a recurring issue with NBC on Android.

is it possible to extend the timeouts when tuning a Channel using HDMI ? maybe adding a wait in the M3U ? Right now it is 20 seconds. There are so many things that can interfere with tuning. I do not watch HDMI lifetv but do record... so wait time is not an issue. I seem to be off by a second or so but Channels DVR timeout after 20s.

1 Like

Well, I figured out that the NBC app is the only streaming app that I have on any device (Nvidia Shield, FireTV or Onn) that doesn't like DNS ad blockers like Adguard. I have two Adguard DNS servers which serve to cut down on the number of annoying pop-ups, etc. on web sites. I also block any outgoing DNS traffic for devices with hard coded DNS servers that attempt to bypass the Adguard servers. The NBC app will only come up when I disable Adguard. I didn't have enough time to get it to work properly with Adguard turned back on (by trying to create an exception rule), so will have to continue trying tonight.

On another note, when trying to download a backup of the URaycoder firmware, Windows flagged the file as containing a virus and removed it. I contacted URay - they suggested that Windows made a "mistake". They did send me the latest .bin file to try and update the encoder. I added a rule to block any outgoing internet traffic from the encoder.

If you use androidhdmi-for-channels there won't be any timeout problems. It sends the encoder stream immediately and runs the scripts in the background.

How is everyone handling the inevitable mess of hardware that comes with this project?
Once you get multiple devices involved and add ethernet adaptors and such it quickly gets out of hand.

As an on-theme, temporary solution I decided to shove everything into an onn. cable organizer I happened to pick up while I was in the store.

The goal being to have a single box with one electrical and one ethernet connection that I can throw in the closet with my other home automation stuff and forget about. This is very much function over form lol.


Contents:

2x "LinkPi ENC1v2" HDMI encoders
Amazon | Aliexpress

2x "Chromecast with Google TV (4k)"
Amazon | Walmart

2x "Vemont USB C hub / ethernet adaptor"
Amazon

1x Ubiquiti UniFi Flex Mini 4-Port Switch
B&H Photo
I have other Unifi gear so this made sense, it might not if you don't already have a Unifi setup. This was helpful as it can be easily powered via usb-c or PoE.

1x USB 2.0 A Male to DC 5.5x2.5mm Barrel Jack Power Cable Adapter 5V (2-pack)
Amazon
I don't know if this is true for all of these devices, but the ENC1v2 encoders will happily work with a 5v power input from a USB connection. This eliminates two AC adaptors.

So the box has one ethernet cable and two usb-c cables coming out of it. The usb-c cables connect to a 2-port Anker charger I had lying around so it only takes up one AC outlet.

As I said, function over form, but it works and now I don't have to look at a pile of gear sitting on a shelf. The box is decently ventilated and according to the web UI the encoders do not get any warmer then they did when just sitting out in the room.