AndroidHDMI for Channels (ah4c): A virtual channel tuner using HDMI Encoder(s) + streaming stick(s)

Just got the following:
HDMI Encoder
FireStick TV (4K)
Google TV (4k)

and so I want to test.
So I enable ADB on the Google TV - Done
Got the ENCODER on the home network and have its ip address

now is there a doc or docs to complete the test. If this works then I try the other device (Firestick)

What brand of encoder did you get?

What streaming app are you hoping to use?

I got this encoder:
EXVIST H.265 1080P
https://www.amazon.com/dp/B08FDZ2VNZ?ref=ppx_yo2ov_dt_b_product_details&th=1
as a test, but also found one for $65 on order to try as well. I only plan on having a HDHomeRun, Firestick and Google TV for now.

As for the app to start with. For Firestick/FireTv let's go with Freevee (anything here)
For the GoogleTV my son has 3 months free of Youtube TV and so any local off that like NBC, CBS would be a good test.

If you have YTTV, and want to get things up-and-running as quickly as possible, I'd suggest you use the ADBTuner project:

Once you get familiar with the concepts, if you want to work up some scripts for apps that don't have deeplinks, you can circle back here.

First of all, thank you so much @bnhf for setting this up! I have everything generally up and running, but am seeing a couple of issues and wanted to check that I hadn't messed anything up and what the best way to workaround these issues is.

I am using this for DirecTV Stream on a Fire Stick. So I've set STREAMER_APP=scripts/firetv/directv. However, if I use the directv.m3u in Channels then some of the channel names don't quite match (largely if they have an "HD" suffix or not) so the search results don't return anything and things get stuck. I then tried switching to the dtvstream.m3u and that worked for some channels and not others, again largely because of the "HD" suffix issue.

Looking at the code I see this line in the bmitune.sh file:

m3uName="${STREAMER_APP#*/*/}.m3u"

Now if I'm reading that right it means that the name of the streamer app/script and the m3u need to match or it might pull the name of the station from the "wrong" m3u file. And in my setup the names of the script and m3u are different.

What's the best way to fix that? Should I just duplicate your firetv/directv scripts and give them a unique name and have it match to a new m3u file? (I'm probably going to create a new and large m3u file for my entire DirecTV Stream package so that I can use this method as the default ahead of TVE in Channels.) Or am I missing something and have it misconfigured some way?

Thanks for your help!

That is a known issue between having DTV and DTVStream credentials, and it's why there's basically a duplicated set of scripts under scripts/firetv/dtvstream, so switch your STREAMER_APP variable to that and it'll improve the situation.

@gfhartzell has been the primary maintainer of dtvstream.m3u, but like me he uses just a subset of the channels available. So it's very possible that the channels he uses are the ones that are working for you. Hopefully he'll see this discussion, and between the two of you can expand dtvstream.m3u to include all of the channels you want.

If you run into any troublesome channels, due to multiple matches in the search, we do have a section for such "problem children" -- so one way or another, we should be able to get you to 100% success. Though channel tuning is not fast using this method, it's quite reliable once you have everything setup properly. And for recordings at least, tuning accuracy is what matters -- speed is a distant second.

Ah ha! I didn't realize there was already a duplicate set of scripts because I didn't see them here: https://github.com/sullrich/ah4c/tree/main/scripts/firetv

I'll try that and work on a full dtvstream.m3u for my full list of channels. I'll share that here and you can decide if it makes sense to include (and I can open a PR or whatever you prefer). Admittedly it may not be ideal because I'm grandfathered into an old package that they call "Package: MGM+ + FreePreview + Free MAX + Unlimited Hours of Cloud DVR + NBA League Pass + Gotta Have It + DTVN EE - Enhanced Technology Fee + 20 In-Home Streams". Catchy!

Right you are! They're in the build though, and I'll add them to the repo along with at least one other that's in the queue from the Netherlands.

The marketing team must have been on vacation when they named that package! If we need to do another version of the DTV scripts/M3U for you, that's fine -- but if we can make it happen with the current DTVStream toolset, that'd would be ideal.

Just an FYI the dtvstream.m3u is for Philadelphia, PA and the HBO entiries are untested,
Also I found using the iPhone app to see the channel names sorted by number helped especially to find the search names for my locals. Olivetin now does the best job for finding the channel id. Have at it!

2 Likes

My encoder is the URay 4K 4 Channels H.265 H.264 HDMI IP Video Streaming Encoder, 2 Firesticks, 2 onn's. Everything is currently laid on my bench still. They are all powered by their usb - plugged directly in wall.

I noticed that some of my recordings were hard to see on the tv - I call it dimmed - lite - not bright as the others. I started troubleshooting : its no particular channel, tuner or device or port on the encoder. I finally realized it was every other recording. I swapped tuners to different ports, reset a couple devices to factory - the issues doesn't follow anything traceable.

I can duplicate 100% every time. I start watching a channel from channels browser while also watching in vlc. Evrything looks great the first time. I'll stop the browser watching and see the vlc closes everything and goes the test pattern screen. I then restart watching again in the browser - and the browser window and the vlc window are dull /dim. Repeat the process and screen(s) are back to full color & brightness. I can reboot everything and the issue remains. I first thought something in the scripts wasn't actually clearing everything and shutting it down all the way - leaving something hanging the process, then the 2nd time it effects the picture - the 3rd time reset to normal. But I don't see anything weird when watching the vlc session, no flashing, jittering or sound issues.

This does not happen with abdtuner that I still have setup 1 channel for.

I checked with Uray and I have the latest firmware. Not sure how to test this any further to isolate the issue...

Can you check the display settings on the Android device when the picture looks bad? My two chromecasts will sometimes switch to 8-bit RGB which looks horribly washed out and I haven't found a consistent cause, or easy fix, other than changing the setting back or rebooting.

Also take a look into the "match content" settings on the Android device. Maybe the video mode is changing between sources and that's causing it to bug out?

That's an important clue. I wonder if the Fubo app needs to be force closed after each tune? If you're using "compatibility mode" in ADBTuner, then that could be the difference.

This is the function in stopbmitune.sh to modify:

#Stop stream
adbStop() {
  stop="input keyevent KEYCODE_BACK; \
        input keyevent KEYCODE_BACK; \
        input keyevent KEYCODE_HOME"
  #stop="am force-stop $packageName"
  $adbTarget shell $stop; sleep 2
  echo "Streaming stopped for $streamerIP"
}

I think I changed from the force-stop to the KEYCODE approach in the interest of faster tuning, but the app may be misbehaving when left running.

1 Like

So here's my first stab at a comprehensive dtvstream.m3u for my setup:

This is for nearly all of the channels that I receive on my package in the San Francisco Bay Area. I still need to add channels above #500 which would be HBO, Starz, regional sports networks, and a few others, but I wanted to get something up and running first.

I switched over to the dtvstream scripts with this m3u and so far everything seems to be working great!

2 Likes

Finally got some time to test this - and it seems to have solved that issue. The video looks good now with back-to-back captures - thank you! Whats the best way to lock that script to prevent future updates from overwritng?

Couple of other things:
I'm having issues on reboots with losing the ADB keys to the device. I have to restart the device and then restart ah4c container.

Once I get that resolved, the first time I try to watch a channel it stops on the Fubo profile stream, once I select that - I have to select "watch live" -using the remote of course. It seems to be fine after that for any subsequent channel watching.

I know you said I'm the only one using Fubo, I realize this isn't high on your list of issues to deal with. I've got a new server spun up to move everything to and trying to get it all tested beforehand. Any insight is appreciated... allot of this may be the Fubo app itself..

Preventing updates to custom scripts and M3Us is done using these two environment variables. You'd change them to false:

UPDATE_SCRIPTS=true
UPDATE_M3US=true

That suggests you don't have your persistent data directories setup correctly. That's handled by these three bindings:

    volumes:
      - ${HOST_DIR}/ah4c/scripts:/opt/scripts # pre/stop/bmitune.sh scripts will be stored in this bound host directory under streamer/app
      - ${HOST_DIR}/ah4c/m3u:/opt/m3u # m3u files will be stored here and hosted at http://<hostname or ip>:7654/m3u for use in Channels DVR - Custom Channels settings
      - ${HOST_DIR}/ah4c/adb:/root/.android # Persistent data directory for adb keys

And, this env var:

HOST_DIR=/data

Generally this is a simple as setting a parent directory (like /data in the example), but the approach can vary by the OS you're running on your Docker host.

This should be something that can be handled as part of the tuning process. We do have a test for active audio to work with, so maybe those two KEYCODES code be sent if audio isn't heard in x seconds after tuning?

I'll tackle this one first. This may be my lack of portainer skills as this is my first go at it.
I can see the 3 adb files on my Host (Ubuntu 20.04 server LTS) file manager @ /data/ah4c/adb.

This is the container volumes :
image

Do I need to map a container volume to the host?

That looks perfect actually. Those adb data files should be persistent with those settings. Go ahead and post your complete docker-compose and env vars, and I'll see if anything looks amiss elsewhere.

Have you tried using the bundled ws-scrcpy? That uses that same adb data, so maybe try connecting that way to be sure you're not prompted (as though it's a new connection) on the streaming device: http://<yourdockerhost>:7655 should get you there if you kept the standard ports.

@bnhf
Can you give me example for script /m3u files
To send adb number tuning? No need to open/close any app . Using android sat tuner.

If you can give me these 2 as example files . Thanks !

Channel 1: SVT1, press 1 on remote
Channel 10: Tv10, press 10 on remote

To do that, I'd suggest doing something pretty simple, which would be to pass the channel numbers via the M3U.

You could have this for an M3U -- though you'd want to add the Gracenote Station IDs between the sets of double quotes:

allente.m3u:

#EXTM3U
#EXTINF:-1 channel-id="1" tvc-guide-stationid="",SVT1
http://{{ .IPADDRESS }}/play/tuner/1
#EXTINF:-1 channel-id="10" tvc-guide-stationid="",Tv10
http://{{ .IPADDRESS }}/play/tuner/10

When you tune via Channels DVR, the channel number would be passed to this simple script:

bmitune.sh:

#!/bin/bash
#bmitune.sh for stb/allente

#Debug on if uncommented
set -x

#Global
channelID="$1"
streamerIP="$2"
adbTarget="adb -s $streamerIP"

#Trap end of script run
finish() {
  echo "bmitune.sh is exiting for $streamerIP with exit code $?"
}

trap finish EXIT

#Tuning is based on channel number values from allente.m3u
tuneChannel() {
  for (( digit=0; digit<${#channelID}; digit++ )); do
    keypress=${channelID:$digit:1}
    $adbTarget shell input keyevent KEYCODE_$keypress
  done
}

main() {
  tuneChannel
}

main

The channel number passed would be broken down into individual keycodes that need to be sent. prebmitune.sh and stopbmitune.sh need to exist but could each just send an echo "Script not required"

2 Likes

I decided to go ahead and setup my new server and start from scratch, so I pulled in the latest of everything. Your newest pull had more options than I had on the older version. As of now, everything is working. I made your suggested changes to not overwrite by changing to false. Doing some testing today and do a reboot of everything in the morning and see if they stick.

I really appreciate your help and time to assist me. If only you had a donate link...