Well I finally got my 3 encoder system up and running. It seems to be working but I have not gotten into it enough to find the long record issues others are getttng ("are you still here"). My config is running on an Mac M2, a 4 channels encoder (encoder), two MECOOL Android TV boxes (MECOOL) and a Chromecast dongle (CC). Many thanks to the smart people on this thread!
After pulling together many examples/suggestions from others, I am using this code for this 3-channel system. I tried to eliminate any unnecessary items in the scripts. Maybe it will help someone.
The encoder ip is 192.168.0.168 and the video feeds for ports 1,2 and 3 are:
http://192.168.0.168/0.ts
http://192.168.0.168/4.ts
http://192.168.0.168/8.ts
The three Android dongles are at 192.168.0.27, 192.168.0.29 and 192.168.0.118.
I renamed the prebmitune.sh, bmitune.sh and stopbmitune.sh to append the fourth octet of the ip address to make it clear which dongles use which shell files.
For example the first MECOOL dongle (192.168.0.27) uses these scripts:
prebmitune-27.sh
bmitune-27.sh
stopbmitune-27.sh
Similar sets of scripts exist for the other two dongles (x.29 & x.118) for the second and third tuner.
From the main.go file, here are the tuner declarations:
var (
tunerLock sync.Mutex
tuners = []tuner{
{
url: "http://192.168.0.168/0.ts",
pre: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/prebmitune-27.sh",
start: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/bmitune-27.sh",
stop: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/stopbmitune-27.sh",
},
{
url: "http://192.168.0.168/4.ts",
pre: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/prebmitune-29.sh",
start: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/bmitune-29.sh",
stop: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/stopbmitune-29.sh",
},
{
url: "http://192.168.0.168/8.ts",
pre: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/prebmitune-118.sh",
start: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/bmitune-118.sh",
stop: "/Users/chrisyoungers/GoLang/androidhdmi-for-channels-main/stopbmitune-118.sh",
},
}
)
prebmitune-27.sh
#!/bin/bash
IPADD="192.168.0.27:5555"
CONNECT="connect 192.168.0.27"
IS_ASLEEP=`adb -s 192.168.0.27:5555 shell dumpsys display | grep mScreenState=OFF`
WAKE="input keyevent KEYCODE_WAKEUP"
HOME="input keyevent KEYCODE_HOME"
adb $CONNECT
# YouTube TV sometimes fails to load video if the app is already open when waking up from sleep.
if [ $IS_ASLEEP ];
then
adb -s $IPADD shell $WAKE; sleep 2
fi
adb -s $IPADD shell $HOME; sleep 2
bmitune-27.sh
#!/bin/bash
IPADD="192.168.0.27:5555"
#NBC
if [ $1 = "nbc" ]; then CODE="9iwfkw-dMAw"; fi
#MSNBC
if [ $1 = "msnbc" ]; then CODE="q6bWEVqhP8o"; fi
#E!
if [ $1 = "e!" ]; then CODE="ILTrUfLFrHI"; fi
#Bravo
if [ $1 = "bravo" ]; then CODE="xNk2Sv4t4Tc"; fi
#Oxygen
if [ $1 = "oxygen" ]; then CODE="v4upAc0UExk"; fi
#USA
if [ $1 = "usa" ]; then CODE="DJ7m0fdLKEY"; fi
#SYFY
if [ $1 = "syfy" ]; then CODE="2_WogcoZ1cY"; fi
#CNBC
if [ $1 = "cnbc" ]; then CODE="GIBoX-XF5i0"; fi
#Golf
if [ $1 = "golf" ]; then CODE="XK34g7QRvGk"; fi
#NFL Network
if [ $1 = "nfl" ]; then CODE="_pYg9qMKKIA"; fi
#NFL Network
if [ $1 = "newsnation" ]; then CODE="ZIzM3eNrylg"; fi
#MTV Classic
if [ $1 = "mtvclassic" ]; then CODE="isxl2N52bUQ"; fi
#BBC News
if [ $1 = "bbcnews" ]; then CODE="g5BmB1qXulc"; fi
#Smithsonian Channel
if [ $1 = "smithsonian" ]; then CODE="c05ACdzJxiE"; fi
#Send the command
adb -s $IPADD shell am start -a android.intent.action.VIEW -d https://tv.youtube.com/watch/$CODE -n com.google.android.youtube.tvunplugged/com.google.android.apps.youtube.tvunplugged.activity.MainActivity
stopbmitune.sh
#!/bin/bash
IPADD="192.168.0.27:5555"
adb -s $IPADD shell input keyevent 86