HDMI for Channels

Quick self follow up.

After playing around for a bit, I've gotten this far:

  • I enabled 'developer' mode on my onn device
  • I confirmed that adb sees and connects to my device via IP by running:
    adb -s 192.168.1.177 shell input keyevent KEYCODE_HOME from the docker container
    and seeing my device go 'home'
  • I created a custom channel and the guide populates with a few Youtube TV channels
  • I attempt to 'watch' from channels and it just closes the window without streaming anything

Nothing in the log indicates an error

Your Custom Channels setup should look something like this:

Your M3U, hosted by the container, should look something like this:

#EXTM3U
#EXTINF:-1 channel-id="8" tvc-guide-stationid="25102",KAET PBS 8
http://{{ .IPADDRESS }}/play/tuner/8
#EXTINF:-1 channel-id="10" tvc-guide-stationid="21209",KSAZ FOX 10
http://{{ .IPADDRESS }}/play/tuner/10
#EXTINF:-1 channel-id="12" tvc-guide-stationid="20507",KPNX NBC 12
http://{{ .IPADDRESS }}/play/tuner/12
#EXTINF:-1 channel-id="212" tvc-guide-stationid="45399",NFL Network HD
http://{{ .IPADDRESS }}/play/tuner/212
#EXTINF:-1 channel-id="216" tvc-guide-stationid="45526",NBA TV HD
http://{{ .IPADDRESS }}/play/tuner/216
#EXTINF:-1 channel-id="217" tvc-guide-stationid="60316",Tennis Channel HD
http://{{ .IPADDRESS }}/play/tuner/217
#EXTINF:-1 channel-id="219" tvc-guide-stationid="82547",FOX Sports 1 HD
http://{{ .IPADDRESS }}/play/tuner/219
#EXTINF:-1 channel-id="241" tvc-guide-stationid="59186",Paramount Network HD
http://{{ .IPADDRESS }}/play/tuner/241
#EXTINF:-1 channel-id="242" tvc-guide-stationid="58452",USA Network HD
http://{{ .IPADDRESS }}/play/tuner/242

Mine is named directv.m3u.

Here's another M3U example for YouTube TV -- this one was using deep links, whereas in my case I used KEYEVENTs:

#EXTM3U
#EXTINF:-1 channel-id="aRGFZpHQkzY" tvc-guide-stationid="10518",NBC
http://{{ .IPADDRESS }}/play/tuner/aRGFZpHQkzY
#EXTINF:-1 channel-id="q6bWEVqhP8o" tvc-guide-stationid="16300",MSNBC
http://{{ .IPADDRESS }}/play/tuner/q6bWEVqhP8o
#EXTINF:-1 channel-id="ILTrUfLFrHI" tvc-guide-stationid="17561",E!
http://{{ .IPADDRESS }}/play/tuner/ILTrUfLFrHI
#EXTINF:-1 channel-id="xNk2Sv4t4Tc" tvc-guide-stationid="31555",Bravo
http://{{ .IPADDRESS }}/play/tuner/xNk2Sv4t4Tc
#EXTINF:-1 channel-id="v4upAc0UExk" tvc-guide-stationid="21744",Oxygen
http://{{ .IPADDRESS }}/play/tuner/v4upAc0UExk
#EXTINF:-1 channel-id="DJ7m0fdLKEY", tvc-guide-stationid="11208",USA
http://{{ .IPADDRESS }}/play/tuner/DJ7m0fdLKEY
#EXTINF:-1 channel-id="2_WogcoZ1cY" tvc-guide-stationid="24533",SyFy
http://{{ .IPADDRESS }}/play/tuner/2_WogcoZ1cY
#EXTINF:-1 channel-id="GIBoX-XF5i0" tvc-guide-stationid="10139",CNBC
http://{{ .IPADDRESS }}/play/tuner/GIBoX-XF5i0
#EXTINF:-1 channel-id="XK34g7QRvGk" tvc-guide-stationid="14899",Golf
http://{{ .IPADDRESS }}/play/tuner/XK34g7QRvGk

This one was named youtubetv.m3u. Either would be stored in the bound m3u directory on the host computer.

I have configured Youtube TV as my custom channel like this:


my m3u looks like this:

#EXTM3U
#EXTINF:-1 channel-id="aRGFZpHQkzY" tvc-guide-stationid="10518",NBC
http://192.168.1.128/play/tuner/aRGFZpHQkzY
#EXTINF:-1 channel-id="q6bWEVqhP8o" tvc-guide-stationid="16300",MSNBC
http://192.168.1.128/play/tuner/q6bWEVqhP8o
#EXTINF:-1 channel-id="ILTrUfLFrHI" tvc-guide-stationid="17561",E!
http://192.168.1.128/play/tuner/ILTrUfLFrHI
#EXTINF:-1 channel-id="xNk2Sv4t4Tc" tvc-guide-stationid="31555",Bravo
http://192.168.1.128/play/tuner/xNk2Sv4t4Tc
#EXTINF:-1 channel-id="v4upAc0UExk" tvc-guide-stationid="21744",Oxygen
http://192.168.1.128/play/tuner/v4upAc0UExk
#EXTINF:-1 channel-id="DJ7m0fdLKEY", tvc-guide-stationid="11208",USA
http://192.168.1.128/play/tuner/DJ7m0fdLKEY
#EXTINF:-1 channel-id="2_WogcoZ1cY" tvc-guide-stationid="24533",SyFy
http://192.168.1.128/play/tuner/2_WogcoZ1cY
#EXTINF:-1 channel-id="GIBoX-XF5i0" tvc-guide-stationid="10139",CNBC
http://192.168.1.128/play/tuner/GIBoX-XF5i0
#EXTINF:-1 channel-id="XK34g7QRvGk" tvc-guide-stationid="14899",Golf
http://192.168.1.128/play/tuner/XK34g7QRvGk
#EXTINF:-1 channel-id="_pYg9qMKKIA" tvc-guide-stationid="34710",NFL
http://192.168.1.128/play/tuner/_pYg9qMKKIA
#EXTINF:-1 channel-id="ZIzM3eNrylg" tvc-guide-stationid="91096",NewsNation
http://192.168.1.128/play/tuner/ZIzM3eNrylg
#EXTINF:-1 channel-id="isxl2N52bUQ" tvc-guide-stationid="59054",MTV Classic
http://192.168.1.128/play/tuner/isxl2N52bUQ
#EXTINF:-1 channel-id="g5BmB1qXulc" tvc-guide-stationid="89542",BBCNews
http://192.168.1.128/play/tuner/g5BmB1qXulc
#EXTINF:-1 channel-id="c05ACdzJxiE" tvc-guide-stationid="65799",Smithsonian
http://192.168.1.128/play/tuner/c05ACdzJxiE

the 128 address is that of the docker container that's serving the m3u, so that seems odd.

oh shoot.. I just realized that I needed to add the port number to the ip address environment vars

1 Like

@bnhf Thanks for all the help.. OK, I'm one step closer!

I have updated the Portainer Env VARS to add the 'port' numbers to the ip addresses:

And now I get an error in the log

2023/08/08 10:59:18 [EXECUTE] Finished running .//prebmitune.sh in 920.425ยตs
2023/08/08 10:59:18 [ERR] Failed to run pre script: fork/exec .//prebmitune.sh: no such file or directory 192.168.1.177:5555

You're missing your STREAMER_APP env var. S/B scripts/onn/youtubetv for you.

Excuse my ignorance here, .. so for youtube tv it would be
scripts/onn/youtubetv .. got it.

What if I wanted to use my Chrome TV for multiple sources?

It's likely the same scripts will work for both.

1 Like

Still getting the error, but now with the path

2023/08/08 11:21:52 [ERR] Failed to run pre script: fork/exec ./scripts/onn/youtubetv/prebmitune.sh: no such file or directory 192.168.1.177:5555

and the scripts are there.

root@ah4c:/opt/scripts/onn/youtubetv# pwd && ls -l
/opt/scripts/onn/youtubetv
total 12
-rwxr-xr-x 1 root root 948 Aug  8 09:08 bmitune.sh
-rwxr-xr-x 1 root root 419 Aug  8 09:08 prebmitune.sh
-rwxr-xr-x 1 root root 167 Aug  8 09:08 stopbmitune.sh

Is it possible that it's not running from opt ?

I'll update STREAMER_APP to /opt/scripts/onn/youtubetv

Nope:

2023/08/08 11:30:05 [ERR] Failed to run pre script: fork/exec .//opt/scripts/onn/youtubetv/prebmitune.sh: no such file or directory 192.168.1.177:5555

Could you post screenshots of your current ah4c stack and the environment variable section please?

version: '3.9'
services:
  ah4c:
    image: bnhf/ah4c:latest
    container_name: ah4c
    hostname: ah4c
    dns_search: localdomain # 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 ah4c proxy
    environment:
      - IPADDRESS=${IPADDRESS} # Hostname or IP address of this ah4c 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_SMTP_SERVER="smtp.gmail.com:587"
      #- ALERT_AUTH_SERVER="smtp.gmail.com"
      #- ALERT_EMAIL_FROM=""
      #- ALERT_EMAIL_PASS=""
      #- ALERT_EMAIL_TO=""
      #- ALERT_WEBHOOK_URL=""
      - TZ=${TZ} # Your local timezone in Linux "tz" format
    volumes:
      - /data/ah4c/scripts:/opt/scripts # pre/stop/bmitune.sh scripts will be stored in this bound host directory under streamer/app
      - /data/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
      - /data/ah4c/adb:/root/.android # Persistent data directory for adb keys
    restart: unless-stopped

(note, I'm not mounting a /data directory atm.. should I?)
and the env vars:

IPADDRESS=192.168.1.128:7654
TUNER1_IP=192.168.1.177:5555
ENCODER1_URL=http://192.168.1.129/0.ts
CHANNELSIP=192.168.1.170
TZ=US/Pacific
NUMBER_TUNERS=1
STREAMER_APP=scripts/onn/youtubetv

When you exec into the container you'll be in the working directory -- I just did it and it's /opt.

Also, could you post the full Portainer log for this container since container start-up?

Confirmed, connecting to the container from portainer puts me in /opt

Here's the startup log

    
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
connected to 192.168.1.177:5555
Existing ./scripts/onn/youtubetv/prebmitune.sh found, and will be preserved
Existing ./scripts/onn/youtubetv/prebmitune.sh found, and will be preserved
Existing ./scripts/onn/youtubetv/bmitune.sh found, and will be preserved
Existing ./scripts/onn/youtubetv/bmitune.sh found, and will be preserved
Existing ./scripts/onn/youtubetv/stopbmitune.sh found, and will be preserved
Existing ./scripts/onn/youtubetv/stopbmitune.sh found, and will be preserved
Existing directv.m3u found, and will be preserved
Existing foo-fighters.m3u found, and will be preserved
Existing hulu.m3u found, and will be preserved
Existing youtubetv.m3u found, and will be preserved
[START] androidhdmi-for-channels is starting
[ENV] Not loading env
[ENV] IPADDRESS                  192.168.1.128:7654
[ENV] ALERT_SMTP_SERVER          
[ENV] ALERT_AUTH_SERVER          
[ENV] ALERT_EMAIL_FROM           
[ENV] ALERT_EMAIL_PASS           
[ENV] ALERT_EMAIL_TO             
[ENV] ALERT_WEBHOOK_URL          
[ENV] ALLOW_DEBUG_VIDEO_PREVIEW  
[ENV] Creating tuner             1
[ENV] ENCODER1_URL               http://192.168.1.129/0.ts
[ENV] TUNER1_IP                  192.168.1.177:5555
[ENV] CMD1                       
[ENV] TEECMD1                    
[ENV] PRE SCRIPT                 ./scripts/onn/youtubetv/prebmitune.sh
[ENV] START SCRIPT               ./scripts/onn/youtubetv/bmitune.sh
[ENV] STOP SCRIPT                ./scripts/onn/youtubetv/stopbmitune.sh
[ENV] REBOOT SCRIPT              ./scripts/onn/youtubetv/reboot.sh
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET    /favicon.ico              --> github.com/gin-gonic/gin.(*RouterGroup).StaticFile.func1 (2 handlers)
[GIN-debug] HEAD   /favicon.ico              --> github.com/gin-gonic/gin.(*RouterGroup).StaticFile.func1 (2 handlers)
[GIN-debug] Loaded HTML Templates (11): 
	- config.html

	- logs.html

	- m3us.html
	- routes.html
	- status.html
	- 

	- edit.html
	- editm3u.html
	- index.html
	- status_and_logs.html
	- stream.html
[GIN-debug] GET    /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (2 handlers)
[GIN-debug] HEAD   /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (2 handlers)
[GIN-debug] GET    /                         --> main.run.func1 (2 handlers)
[GIN-debug] GET    /routes                   --> main.run.func2 (2 handlers)
[GIN-debug] GET    /play/tuner:tuner/:channel --> main.run.func3 (2 handlers)
[GIN-debug] GET    /m3u/:channel             --> main.run.func4 (2 handlers)
[GIN-debug] GET    /env                      --> main.run.func5 (2 handlers)
[GIN-debug] GET    /logs/text                --> main.run.func6 (2 handlers)
[GIN-debug] GET    /logs                     --> main.run.func7 (2 handlers)
[GIN-debug] GET    /status/andlogs           --> main.run.func8 (2 handlers)
[GIN-debug] GET    /logs/json                --> main.run.func9 (2 handlers)
[GIN-debug] GET    /video                    --> main.run.func10 (2 handlers)
[GIN-debug] GET    /status                   --> main.statusPageHandler (2 handlers)
[GIN-debug] GET    /api/status               --> main.apiStatusHandler (2 handlers)
[GIN-debug] GET    /stream                   --> main.run.func11 (2 handlers)
[GIN-debug] GET    /test/webhook             --> main.run.func12 (2 handlers)
[GIN-debug] GET    /test/email               --> main.run.func13 (2 handlers)
[GIN-debug] GET    /status/channelsactivity  --> main.run.func14 (2 handlers)
[GIN-debug] GET    /edit                     --> main.run.func15 (2 handlers)
[GIN-debug] POST   /save                     --> main.run.func16 (2 handlers)
[GIN-debug] POST   /m3usave/:file            --> main.run.func17 (2 handlers)
[GIN-debug] GET    /m3us                     --> main.run.func18 (2 handlers)
[GIN-debug] GET    /editm3u/:file            --> main.run.func19 (2 handlers)
[GIN-debug] GET    /config                   --> main.run.func20 (2 handlers)
[GIN-debug] POST   /configsave               --> main.run.func21 (2 handlers)
[START] androidhdmi-for-channels is ready
[GIN-debug] Listening and serving HTTP on :7654

No need to mount /data -- it'll be created for you if it doesn't exist. Look for it on the host if you like.

Hmmm... Everything looks correct so far. :confused: What happens if you exec into the container and run ./scripts/onn/youtubetv/prebmitune.sh from the /opt directory?

root@ah4c:/opt# ./scripts/onn/youtubetv/prebmitune.sh              
bash: ./scripts/onn/youtubetv/prebmitune.sh: cannot execute: required file not found

I think I figured out the problem. The scripts do not have proper line endings, they're DOS, not UNIX..

Running dos2unix prebmitune.sh fixed it, and...
naturally got me to the next error:

2023/08/08 12:26:40 [ERR] Failed to run start script: fork/exec ./scripts/onn/youtubetv/bmitune.sh: no such file or directory

so now I'm converting all three scripts in the folder..

UPDATE: I've converted all three scripts to the 'proper' UNIX format, and I now see a stream, but unfortunately it's not tuning, it's just the HOME page.

nothing obvious in the log file.

Side note, thank you for all your help today

Excellent catch -- I see that in the source now too. These were some of the original sample scripts, so they likely won't be right for you anyway, but it'll be nice to at least see more meaningful errors.

OK, so not tuning, and the only hint I see in the log file is this:

2023/08/08 12:33:43 [EXECUTE] Finished running ./scripts/onn/youtubetv/bmitune.sh in 4.936328ms
2023/08/08 12:34:31 [IO] io.Copy: write tcp 172.22.0.2:7654->192.168.1.170:34430: write: broken pipe

Check out the mecool/youtubetv scripts on Github, that should be a better starting point than the onn/youtube scripts. The onn scripts are samples from the early days of this project. You can also look at my firetv/directv scripts, although those are oriented towards KEYEVENT style tuning rather than deep links.