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

@krazijoe

Looking at the docker compose you posted, you may want to revisit the first post in this thread. The idea is that all of your specific changes should be made in the Environment section of Portainer-Stacks, and the compose itself typically does not need to be edited. Also each variable defined in the stack has comments next to it explaining its purpose.

The data is stored in the directories you choose to bind directories to in the container. The environment variables listed in the first post are not defaults, they are examples. You've done these bindings, by editing the compose directly:

Which means, based on what you chose to use on the host, you should find M3Us under /data/ah4c/m3u

Got cha...Thanks for the knowledge...I changed it to where I wanted it to be and updated. And I am doing it remotely so now it doesn't work...LOL. I assume it's because it needs to be reauthorized because there is no longer a valid key.

You should be able to just move the adb key files to the new location. Assuming /data/ah4c/adb was a valid directory to use in Unraid, you should see these files:

Move them, restart the ah4c container and I think you'll be in business.

You would think that after using unraid for 12 years now, I would have a grasp on it...I don't...LOL...I didn't know where they were pointed to. I am all set now. I revoked and then they came right back up and it's all working now. Thanks for your help.

I'm running both Channels and AH4C in Unraid Docker. Let me know if you need to compare notes.

1 Like

This message is coming from ADB -- and I've never seen it before. One thing that occurs to me is that perhaps your directory bindings to the container are invalid, and so your key files are lost on a reboot of your docker host.

Could you please post the docker compose you're using, along with your environment variables?

Definitely going to look at the ENC5 v2 and compare to my Uray. The pricing is very reasonable and at first glance looks like more available options. Thanks for the tip!

I had this message this morning on my ah4c instance, before i was re-prompted to allow the adb MAC access.

What directory do you have bound to /root/.android in your ah4c docker compose, and what's the contents of that directory on your Mac?

Hi. Here is the compose and the environment variables:

Compose:

version: '3.9'
services:
  ah4c:
    image: bnhf/ah4c:${TAG}
    container_name: ah4c
    hostname: ah4c
    dns_search: ${DOMAIN} # Specify the name of your LAN's domain, usually local or localdomain
    ports:
      #- 5037:5037 # Port used by adb-server
      - 7654:7654 # Port used by this androidhdmi-for-channels proxy
      - 7655:8000 # Port used by ws-scrcpy
    environment:
      - IPADDRESS=${IPADDRESS} # Hostname or IP address of this androidhdmi-for-channels extension to be used in M3U file (also add port number if not in M3U)
      - NUMBER_TUNERS=${NUMBER_TUNERS} # Number of tuners you'd like defined 1, 2, 3 or 4 supported
      - TUNER1_IP=${TUNER1_IP} # Streaming device #1 with adb port in the form hostname:port or ip:port
      - TUNER2_IP=${TUNER2_IP} # Streaming device #2 with adb port in the form hostname:port or ip:port
      - TUNER3_IP=${TUNER3_IP} # Streaming device #3 with adb port in the form hostname:port or ip:port
      - TUNER4_IP=${TUNER4_IP} # Streaming device #4 with adb port in the form hostname:port or ip:port
      - ENCODER1_URL=${ENCODER1_URL} # Full URL for tuner #1 in the form http://hostname/stream or http://ip/stream
      - ENCODER2_URL=${ENCODER2_URL} # Full URL for tuner #2 in the form http://hostname/stream or http://ip/stream
      - ENCODER3_URL=${ENCODER3_URL} # Full URL for tuner #3 in the form http://hostname/stream or http://ip/stream
      - ENCODER4_URL=${ENCODER4_URL} # Full URL for tuner #4 in the form http://hostname/stream or http://ip/stream
      - STREAMER_APP=${STREAMER_APP} # Streaming device name and streaming app you're using in the form scripts/streamer/app (use lowercase with slashes between as shown)
      - CHANNELSIP=${CHANNELSIP} # Hostname or IP address of the Channels DVR server itself
      #- ALERT_WEBHOOK_URL="" # For advanced users, tuning failure alerts can be sent via a webhook.

      - CREATE_M3US=${CREATE_M3US} # Set to true to create device-specific M3Us for use with Amazon Prime Premium channels -- requires a FireTV device
      - TZ=${TZ} # Your local timezone in Linux "tz" format
    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
    restart: unless-stopped

Environment Variables:

TAG=latest
DOMAIN=localdomain
IPADDRESS=10.10.10.27:7654
NUMBER_TUNERS=4
TUNER1_IP=10.10.10.21:5555
TUNER2_IP=10.10.10.163:5555
TUNER3_IP=10.10.10.94:5555
TUNER4_IP=10.10.10.12:5555
ENCODER1_URL=http://10.10.10.72/0.ts
ENCODER2_URL=http://10.10.10.72/4.ts
ENCODER3_URL=http://10.10.10.72/8.ts
ENCODER4_URL=http://10.10.10.72/12.ts
STREAMER_APP=scripts/osprey/directv
CHANNELSIP=10.10.10.4
CREATE_M3US=false
TZ=US/Eastern
HOST_DIR=/data

On your Docker host computer, what files do you see in /data/ah4c/adb?

I've written scripting for the Android kodi app to do the tuning. (I love how all these DIY TV technologies go around and around and touch each other. :slight_smile:)

kodi has a huge number of add-ons for various types of live streaming. We can use kodi for all the hard work of finding and decoding the streams (including DRM sometimes) and just run its player output through an HDMI encoder to capture it. Even if there is a dedicated app for particular content, kodi might be a better choice for scripting because it has a fairly rich API and doesn't depend on quirky adb remote control emulation with finicky delays.

You can find the chromecast/kodi_faves scripts in this branch of my fork of the repo. (If you try to go there a few days from now and find the links don't work, it's probably because I did a PR to the main repo and deleted my branch after it was merged. I'm just giving it some bake time before I do that.)

If you are not too git-savvy, here are direct links to:

Absolutely! They have worked really well for me and many others.

a dedicated mount in my own data drive

Is it a USB drive -- or is there any reason you can think of why the mount might not always be available?

From your screenshot:

screenshot-community.getchannels.com-2024.06.29-08_27_22

The fact that this folder has been modified in the last 9 days suggests a possible problem. These keys are static.

Here's mine for comparison:

screenshot-htpc6-2024.06.29-08_31_18

Note, that my adb folder hasn't been modified in over a year.

What do the Accessed, Modified and Created dates look like for the 3 files in the adb folder? There's only one that should show being modified since you set things up. These are the two that shouldn't have changed:

screenshot-htpc6-2024.06.29-08_42_41

screenshot-htpc6-2024.06.29-08_43_10

Only edited file seems to correspond with my needing to re-permission

@bnhf was mucking around with my setup and instead of a string of keyevents I figured out my app accepted the “search” aka input 84 - which would navigate me off the player and to another screen of the app, allowing me to then launch the next channel successfully.

May not be search, but certain apps may support other key events to reduce the amount of button presses needed.

Also with “are you still watching?” Prompts, what are your main ways to overcome this?

Edit: would a method to overcome it be as simple as sending a keyevent that the app does not use every now and then?

Great. Anytime you can use a keyevent to get you to a consistent place in the app is very helpful. BTW, I recommend using KEYCODE_SEARCH instead of 84 to improve script readability.

You can find a list of similar keyevents in text form here:

I haven't needed to implement anything like that myself, but I know others have. Generally, I'd suggest creating a script called keep_alive.sh that's run in the background by bmitune.sh. Get the PID for keep_alive.sh once it's running, and write it to a file under $streamerNoPort/keep_alive. Then when stopbmitune.sh is run, you can check for the presence of that file, and kill the script with that PID.

What keep_alive.sh does to prevent a Still Watching? pop-up may vary some from app to app. KEYCODE_BRIGHTNESS_UP followed by KEYCODE_BRIGHTNESS_DOWN might work.

1 Like

Yeah spot on.

Yeah atm I’ve just got a bash executable that checks for playstate=3 on adb and sends back the app name if that is detected.

Then I have it something along the lines of.

If “adb playstate=3 check” = “my app”
Echo “media is playing”
Keyevent
Sleep 3600 (hour)
sudo “bash executable”
Else
Echo “media is not playing”
Sleep 3600
Sudo “bash executable”
Fi

Probably not the most ideal check but hopefully will work for me.

This way it’ll just check for media playing every hour and hopefully the key event will
Prevent the timeout.

Doing it this way as I’ve still got my tuner through an edited ADBTuner still as I haven’t got around to setting up portainer and all your channels mods :stuck_out_tongue:

Had a weird thing happen. Not sure why but my M3U, that I made changes to, was reset back to the default. All the changes I made were gone and I had to recreate all my changes. What would cause that?

1 Like