HDMI for Channels

For what it's worth, I have the same issue. Not 100% of the time, maybe 30% of the time though. So I too am wondering what the disconnect might be, and how to mitigate it? It feels like a timing issue perhaps, but I'm not sure how to best troubleshoot that. As you mention, pressing play fixes it every time. I don't think having the script send two play commands would work, it might end up pausing 70% of the time, lol. Anyway, the error is from the Channels app, not from the IPTV box (as in, the signal is live) so I don't think it's got anything to do with any of the devices in the chain going to sleep or not waking up in time. But maybe we can insert a pause somewhere?

I'm curious if anyone else sees this a lot and gets past it by pressing play. Hoping we can share strategies to fine tune this, so unattended recordings can be more reliable, if at all possible.

1 Like

This is clever, and I'm curious to learn more. Is it still working reliably for you? What does the command look like? Thanks for sharing such great info in this thread!

Occasionally, I get the error screen too - but, more frequently, I see another issue - per my previous post on this topic, I have found that HDMI capture works better when you put the streaming box (in my case the Onn TV 4K) to sleep - this disconnects the signal to the HDMI encoder - the prebmitune.bat script then wakes up the box - with my encoder, this resets the audio and video such that they are in-sync - if I prevent the Onn from sleeping, then A/V will eventually become out of sync for some reason

I think there is an issue associated with transitioning from the static home screen of the Onn box - to playing video in the YTTV app - although my setup is probably working better than ever right now, this transition causes some issues when you start to view the video - in some cases, the audio is ahead of the video, and the video appears to play back at greater than 1X to catch up - at some point, it catches up and A/V are sync'ed - other times, channels just displays a spinning circle and doesn't seem to fix itself, so I have to exit and re-tune the channel - other times, it just works - sometimes, pressing the forward arrow fixes things - in any event, I don't have things working at 100%, but pretty good - hopefully we can collectively figure out a way to make this process error free...

Sure, here's my keep alive script. I run it with screen and then detach from the screen session (same way I run the proxy server). One of these days I'll properly make them into launchd targets.

#!/bin/sh

while [ /bin/true ]; do
        echo ""
        date
        echo ">>> Connecting to 10.0.250.136"
        adb connect 10.0.250.136
        echo ">>> Sending keyevent 224"
        adb -s 10.0.250.136 shell input keyevent 224
        echo ">>> Sending keyevent 221"
        adb -s 10.0.250.136 shell input keyevent 221
        echo ">>> Sleeping for 1600"
        sleep 1600
done

PS: seems to work but I have not recorded anything longer than 2 hours at a time of late.

I had an SMAYS combo (usb + ethernet) that gave me nothing but problems on both Fire TV MAX and the the new Onn streamer. Would just hang up such that dhcp requests never got to my router. Had to remove power to reset it. Switched to a UGreen adapter and no more problems.

1 Like

Talking through this a bit: I think the error is very generic and there is likely to be more than one cause. It's obviously a pain to troubleshoot since it doesn't happen consistently.

There is one case that I can reproduce every time with the hardware I'm using.

  1. Put Android device to sleep.
  2. Reboot HDMI streamer (power cycle or reboot from the web GUI). Note: make sure you don't have a video preview running in the web ui after the reboot as that will start the stream before Channels does.
  3. Tune channel via Channels app.

This will cause generate a "connection lost" error in Channels as the video stream will temporarily drop out when it switches from the "no signal" image to the actual video stream. The stopbmitune.sh script executes because the stream drops out at the HDMI encoder level.

For this one specific issue I don't see any place where one could insert a pause to correct it. In the current implementation the entire tuning process is triggered by the http request to load the video stream so we can't perform any actions prior to that connection being established.

The Channels Team has expressed in the past that they don't want to open the can of worms that would be automatic retries so that's likely out.

The proxy app could perhaps be modified to always return a video stream even if the source is unavailable? This seems to be common among the other plugins (MLB, ESPN, etc). I think this is probably the best path forward as it won't require changes to Channels itself.

@tmm1 if you don't mind me asking, do you have intentions of continuing development of this proof-of-concept code you shared? I might be interested in contributing (or starting a separate, greenfield project) to take some of the ideas we've have learned and put them in a more robust platform. I however, wouldn't want to do so if you were anticipating adding this natively to Channels.

1 Like

Interesting notes, thanks. I haven't experienced ant A/V sync issues thus far, using FMUser encoders, one with a Onn TV 4K and another with a Chromecast with Google TV dongle. Been a few weeks now and I leave streams playing for many hours. On YouTube TV, at least. If I do notice A/V sync issues, since I am pretty sensitive to that, I will experiment more with forcing sleep and wakeup events. Thanks again for sharing in such detail, it helps us all figure out the best way to forge ahead!

Testing out a new Android TV / Google TV device

Feels 4* faster than Amazon Fire Stick and Google Chromecast 4K.

Has ethernet which is a bonus.

Streaming quality is about the same as Amazon 4K but its much faster navigating menus and in basic operations.

Glad to know I'm not the only one seeing this. I wish I had the know-how to suggest a solution. If there were a way to "test" the connection (which maybe there isn't), it seems like this would solve other issues, too — for example, I recall some of you were using a method that was much quicker in tuning channels, but it wasn't reliable. If testing the connection were possible, that could be the first try, with the more reliable method the fallback. It's a shame that isn't possible, because the time it takes to connect is really the sole downside of this right now (well, aside from cost).

Any chance you could at some point use the stop watch on your phone and time how long from selecting. a channel until it comes up? With the Onn devices, it is about 13 seconds for me.

Thanks. I looked there on the Onn device, and it didn't have those color options, unfortunately. I'll have to look to see if they're somewhere else in the settings.

It took about 6 seconds from sitting on home screen to a playing hulu video. This is consistent after the 1st launch.

What are you using to power the adapter? I just got the Cable Matters adapter, and it's still showing my Onn box as connected via WiFi. I'm plugging the micro-USB cable into the Onn box, and I've tried plugging the USB-A male part into a couple different power adapters (such as the one that used to come with iPads), and still nothing.

1 Like

I used an Anker USB-A charger to test - the Onn box still had WiFi checked and otherwise looked like it was on WiFi but a status menu indicated “Ethernet Connected” and I verified externally that it was using the wired connection

I am finding this experimental project exceptionally fun and also a little reassuring looking toward possible future TVE and even future Broadcast roadblocks. I started out with just a single channel URayCoder HEVC H.265 H.264 Live HDMI Video Encoder with a Chromecast with Google TV (HD) Streaming Stick.

But decided right away I would kick myself constantly if I didn't get the 4 channel URayCoder 4K 4 Channels H.265 H.264 HDMI IP Video Streaming Encoder (so I am using one of those now). I added a second Chromecast and my primary main tuner is now an onn Android TV 4K. I am keeping my 4th available HDMI port open because frankly I think my current usage will only kick in the second tuner occasionally and the third rarely. Though who knows, maybe I'll play around with one of my old FireTV 4k Max sticks.

I have to offer my profound thanks to everyone here who have been posting their research and development. In particular @tmm1 for the original files. But also to @JT-DFW and @Fofer whose constant reports and updates and scripts I have Frankensteined into something that is working very well for me. BTW: I am doing a Windows setup for androidhdmi-for-channels, so I am using .bat files instead of .sh.

One thing I would like to see is maybe a modification/addition to the androidhdmi-for-channels program file to optionally run a maintenance script if it detects that all tuners have been inactive for a period of time. Currently I am running a nightly scheduled task to reboot the "tuners" and then put them to sleep. I would like to find a way to detect if all the tuners have been inactive for an hour and just simply do a cleanup reboot and put them to sleep till they are needed next.

In the interest of fair sharing, here is my current script batch files. There are three of each script, with only differences being the ip addresss of the 2 chromecast and 1 onn. These batch files of course need coding optimization and cleanup. They are a work in progress for me.

bmitune.bat script

@echo off
set "p1=%1"
set link=""
if "%p1%"=="nbc" set link=https://tv.youtube.com/watch/vsHPIz9ZC-4?onboard=1
if "%p1%"=="fox" set link=https://tv.youtube.com/watch/yVKpCICuh-A?onboard=1
if "%p1%"=="msnbc" set link=https://tv.youtube.com/watch/q6bWEVqhP8o?onboard=1
if "%p1%"=="e" set link=https://tv.youtube.com/watch/4XA2gdEOngg?onboard=1
if "%p1%"=="bravo" set link=https://tv.youtube.com/watch/P12seiJcdYo?onboard=1
if "%p1%"=="oxygen" set link=https://tv.youtube.com/watch/_XptfCraPjM?onboard=1
if "%p1%"=="usa" set link=https://tv.youtube.com/watch/8xN3o2PSL5s?onboard=1
if "%p1%"=="syfy" set link=https://tv.youtube.com/watch/uSfozGAsGMk?onboard=1
if "%p1%"=="cnbc" set link=https://tv.youtube.com/watch/GIBoX-XF5i0?onboard=1
if "%p1%"=="golf" set link=https://tv.youtube.com/watch/XK34g7QRvGk?onboard=1
if "%p1%"=="nfl" set link=https://tv.youtube.com/watch/_pYg9qMKKIA?onboard=1
if "%p1%"=="newsnation" set link=https://tv.youtube.com/watch/ZIzM3eNrylg?onboard=1
if "%p1%"=="mtvclassic" set link=https://tv.youtube.com/watch/YPB9f0dageg?onboard=1
if "%p1%"=="bbcnews" set link=https://tv.youtube.com/watch/g5BmB1qXulc?onboard=1
if "%p1%"=="smithsonian" set link=https://tv.youtube.com/watch/E7D0KRZIUso?onboard=1
if "%p1%"=="magn" set link=https://tv.youtube.com/watch/9dTo5rwwTjU?onboard=1
if "%p1%"=="nik" set link=https://tv.youtube.com/watch/cN5V1eeO3E4?onboard=1
if "%p1%"=="just" set link=https://tv.youtube.com/watch/EBdQc7HoF_E?onboard=1
if "%p1%"=="twcyt" set link=https://tv.youtube.com/watch/P_w3HTppc6E?onboard=1
if "%p1%"=="twc" (
	adb -s 192.168.1.135:5555 shell monkey -p com.weathergroup.twc 1
	waitfor ClearOutSpecialWeatherStatement /t 20
	adb -s 192.168.1.135:5555 shell input keyevent 20 66
	goto END
)

if "%link%"=="" goto END

c:\platform-tools\adb -s 192.168.1.135:5555 shell am start -a android.intent.action.VIEW -d %link% -n com.google.android.youtube.tvunplugged/com.google.android.apps.youtube.tvunplugged.activity.MainActivity

:end

The prebmitune scripts are

@echo off
set CONNECT=connect 192.168.1.135:5555
set WAKE=input keyevent KEYCODE_WAKEUP
set HOME=input keyevent KEYCODE_HOME

adb %CONNECT%
adb %CONNECT%
adb %CONNECT%
adb -s 192.168.1.135:5555 shell %WAKE%
adb -s 192.168.1.135:5555 shell %WAKE%

And the stopbmitune scripts are

@echo off
rem c:\platform-tools\adb -s 192.168.1.135:5555 shell am force-stop com.google.android.youtube.tvunplugged
c:\platform-tools\adb -s 192.168.1.135:5555 shell am force-stop com.weathergroup.twc
c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_HOME
rem c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_SLEEP

Oh, and the nightly maintenance batch file is

@echo off
c:\platform-tools\adb connect 192.168.1.194:5555
c:\platform-tools\adb -s 192.168.1.194:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.194:5555 shell am force-stop com.google.android.youtube.tvunplugged
c:\platform-tools\adb -s 192.168.1.194:5555 shell am force-stop com.weathergroup.twc
c:\platform-tools\adb -s 192.168.1.194:5555 shell input keyevent KEYCODE_HOME
c:\platform-tools\adb -s 192.168.1.194:5555 reboot

c:\platform-tools\adb connect 192.168.1.137:5555
c:\platform-tools\adb -s 192.168.1.137:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.137:5555 shell am force-stop com.google.android.youtube.tvunplugged
c:\platform-tools\adb -s 192.168.1.137:5555 shell am force-stop com.weathergroup.twc
c:\platform-tools\adb -s 192.168.1.137:5555 shell input keyevent KEYCODE_HOME
c:\platform-tools\adb -s 192.168.1.137:5555 reboot

c:\platform-tools\adb connect 192.168.1.135:5555
c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.135:5555 shell am force-stop com.google.android.youtube.tvunplugged
c:\platform-tools\adb -s 192.168.1.135:5555 shell am force-stop com.weathergroup.twc
c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_HOME
c:\platform-tools\adb -s 192.168.1.135:5555 reboot

waitfor GiveTimeToFullyReboot  /t 90

c:\platform-tools\adb connect 192.168.1.194:5555
c:\platform-tools\adb -s 192.168.1.194:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.194:5555 shell input keyevent KEYCODE_SLEEP

c:\platform-tools\adb connect 192.168.1.137:5555
c:\platform-tools\adb -s 192.168.1.137:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.137:5555 shell input keyevent KEYCODE_SLEEP

c:\platform-tools\adb connect 192.168.1.135:5555
c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_WAKEUP
c:\platform-tools\adb -s 192.168.1.135:5555 shell input keyevent KEYCODE_SLEEP

That is really promising, as there are some TV Everywhere channels that take that long. I wish I had an unlimited budget for this project, to try out different devices to see what the fastest one is. I’m not well-versed in the Android world to know what the fastest processor is considered to be.

As I spend more money on this, I keep telling myself that the money isn’t just for the gear, but for the fun of it, just like other people have expensive hobbies. :slight_smile:

2 Likes

It's quite a nice box. It has ADs stripped away from the home screen and seems well engineered. If I was to purchase another box to add to my streaming setup it will definitely be these going forward.

I hear you. I've already spent more money on this random project than I would care to admit. :smile:

2 Likes

So much for channels being an inexpensive alternative :laughing: on the HDMI work-around.

Watching, but not spending yet! Playing with scripts on my *ix box and Android TV devices tho.

1 Like

Yeah, I’ve actually spent around just as much for the hdmi experiment as I did to get the Synology Channels server I use. Lol.

1 Like