HDMI for Channels

Yes, no casting involved. 720p, 1080p and even 4K should be possible with the right encoder. Keep in mind that some of the streaming services will start you at a modest resolution to get the stream going quickly -- but then it should improve rapidly.

2 Likes

Glad to hear it’s not casting but rather opening in the apps! Will get to the software side in the coming weeks :slightly_smiling_face:

I believe you’re using DTVStream. The Notre Dame/Navy game is gonna broadcast today at 1:30 pm (Central time) in 4K on channel 105. Just wondering if you are gonna try a 4k test thru your encoder system.

Love the idea, but unfortunately no channel 105 here. I'm actually a satellite customer, and there are some differences when using DTVStream.

I’ve been thinking about setting up an encoder but have hesitated. If Stream is gonna be doing some 4K games, it’s probably time for me to stop procrastinating.

I searched and found how to install Portainer on my old Synology NAS. If I get it working there, it should be simple to get it moved to the main NAS. I’d prefer to having it run on my NAS than my old Windows machine.

It's a pretty interesting project really, and I've already done the work for DTV. You'll probably want to add some channels to the M3U (just the ones I wanted are in there so far), but other than that it's ready to go.

A four port URayCoder 4K, with four FireStick 4K Max devices is what I've done all the testing on -- though other combinations of gear should be fine. I'm using two for DTV and two for Sling -- using two separate containers.

If you're a fan of PoE, Uctronics makes a very nice Ethernet adapter that can also power the FireStick. I rack mounted my setup, as there are a few pieces and power cords to deal with, but it can all be PoE powered if you want to limit the clutter:

3 Likes

@bnhf ,

What kind of Rack do you have I am looking for one to fit a power supply switch and my Encoder and Firesticks mini Server... Nothing too large.

I Suck at Cable management.

My primary rack is a modified version of this 12U Startech unit. I added wheels, and a beefier bottom frame to mount them. It fits great in a space under some stairs, and I can wheel it out to get to the back.

I also have 8U and 2U Startech racks. The 8U is on a shelf (also under the stairs), and the 2U is mounted to the back of a piece of furniture in a loft area.

The quality is quite good on the Startech units. On the two larger units I have Coolerguys 1U fan assemblies in the top position -- that each have 6 small ultra-quiet fans (ordered separately).

These keystone patch panels will help with cable management. RJ-45, HDMI and USB keystone jacks are all easy to source and will allow you to bring connections from the back to the front of the rack where you want everything to terminate. Then, it's just a question of having a bunch of short patch cables to connect A to B.

@bnhf ,

Thanks for taking the post to posting this including the links ... I will start Planning this is definitely a great start.

2 Likes

I've updated the bnhf/ah4c:latest and bnhf/ah4c:test containers (they're the same currently) to the latest sullrich/ah4c (@KompilerDJ) code base. This includes the most recent m3u and scripts support for DirecTV and Sling TV.

Also, I've added UPDATE_SCRIPTS and UPDATE_M3US environment variables that can be used to force an overwrite of the m3u and script files in your persistent data directory. Normally these files are not overwritten if they already exist -- just in case you've added changes of your own.

Here's what it would look like in your Portainer environment variables section if you want to update the M3Us only to the latest versions from the repo. The files in question will be overwritten every time you launch or update the container, as long as the env var is set to true:

Also, for those that want to use a couple of encoder ports for one streaming service, and the remaining ports for another -- running two containers is an easy way to accomplish this.

Change the port mapping on the second container (7664 works well), and comment out the adb-server port (this is only needed for specialized scenarios). Also, the second ws-scrcpy needs its own port, so you can change that to 7665 (for example). The data directory bindings can typically stay the same.

As you can see below, the container_name and hostname values have been set to ah4c2.

The IPADDRESS env var would change from htpc6:7654 in my above screenshot to htpc6:7664 for the second container. Your second container's Custom Channels setup (on the Channels DVR Settings page) needs to reflect this alternate port number as well:

version: '3.9'
services:
  ah4c:
    image: bnhf/ah4c:latest
    container_name: ah4c2
    hostname: ah4c2
    dns_search: localdomain # Specify the name of your LAN's domain, usually local or localdomain
    ports:
      #- 5037:5037 # Port used by adb-server
      - 7664:7654 # Port used by this androidhdmi-for-channels proxy
      - 7665: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_SMTP_SERVER="smtp.gmail.com:587"
      #- ALERT_AUTH_SERVER="smtp.gmail.com"
      #- ALERT_EMAIL_FROM=""
      #- ALERT_EMAIL_PASS=""
      #- ALERT_EMAIL_TO=""
      #- ALERT_WEBHOOK_URL=""
      - UPDATE_SCRIPTS=${UPDATE_SCRIPTS} # Set to true if you'd like the sample scripts and STREAMER_APP scripts updated whether they exist of not
      - UPDATE_M3US=${UPDATE_M3US} # Set to true if you'd like the sample m3us updated whether they exist of not
      - 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
1 Like

I am using DTVStream and having some tuning issues. Are there different Scripts I should be using?
or modifications to make? If I Manually tune to USA for example and then have channels record it works. If I dont it just sits at the Home screen .

@gfhartzell

Can you post your log from Portainer-Containers from when you startup the container to when you try to tune USA?

Please use three backticks at the beginning and end of your log to make it easier to read and scroll through.

Also, it'd be helpful if you could post a screenshot of the environment variables section of your Portainer-Stack.

Attempting network tune for device http://192.168.1.227/0.ts 192.168.1.231:5555 242 
[EXECUTE] Running [./scripts/firetv/directv/prebmitune.sh 192.168.1.231:5555]
[EXECUTE] Stdout: 'already connected to 192.168.1.231:5555
Starting: Intent { cmp=com.att.tv/tv.youi.clientapp.AppActivity }
Waking 192.168.1.231:5555
prebmitune.sh is exiting for 192.168.1.231:5555 with exit code 0
'
[EXECUTE] Stderr: '+ streamerIP=192.168.1.231:5555
+ streamerNoPort=192.168.1.231
+ adbTarget='adb -s 192.168.1.231:5555'
+ mkdir -p 192.168.1.231
+ trap finish EXIT
+ main

+ adbConnect
+ adb connect 192.168.1.231:5555
+ local -i adbMaxRetries=25
+ local -i adbCounter=0
+ true
+ adb -s 192.168.1.231:5555 shell input keyevent KEYCODE_WAKEUP
+ local adbEventSuccess=0
+ [[ 0 -eq 0 ]]
+ break

e
+ packageLaunch=tv.youi.clientapp.AppActivity
+ packageName=com.att.tv
++ adb -s 192.168.1.231:5555 shell pidof com.att.tv
+ packagePID=19404
+ '[' '!' -z 19404 ']'
+ adb -s 192.168.1.231:5555 shell input keyevent KEYCODE_WAKEUP
+ adb -s 192.168.1.231:5555 shell am start -n com.att.tv/tv.youi.clientapp.AppActivity

Error type 3
Error: Activity class {com.att.tv/tv.youi.clientapp.AppActivity} does not exist.
+ echo 'Waking 192.168.1.231:5555'
+ touch 192.168.1.231/adbAppRunning
+ finish
+ echo 'prebmitune.sh is exiting for 192.168.1.231:5555 with exit code 0'
'
[EXECUTE] Finished running ./scripts/firetv/directv/prebmitune.sh in 2.439948063s
[EXECUTE] Running [./scripts/firetv/directv/bmitune.sh 242 192.168.1.231:5555]
[EXECUTE] Stdout: 'Not a special channel (exit nor reboot)
Current app in focus is com.amazon.tv.launcher
Current PID for this script is 801
Last channel selected on this tuner, no channel change required
bmitune.sh is exiting for 192.168.1.231:5555 with exit code 0
'
[EXECUTE] Stderr: '+ channelID='"242"'
+ specialID=242
+ streamerIP=192.168.1.231:5555
+ streamerNoPort=192.168.1.231
+ adbTarget='adb -s 192.168.1.231:5555'
+ trap finish EXIT
+ main
+ matchEncoderURL
+ case "$streamerIP" in
+ encoderURL=http://192.168.1.227/0.ts
+ specialChannels
+ packageName=com.att.tv
+ '[' 242 = exit ']'
+ '[' 242 = reboot ']'
+ [[ -f 192.168.1.231/adbCommunicationFail ]]
+ echo 'Not a special channel (exit nor reboot)'
++ adb -s 192.168.1.231:5555 shell dumpsys window windows
++ grep -E mCurrentFocus
++ cut -d / -f1
++ sed 's/.* //g'
+ appFocus=com.amazon.tv.launcher
+ echo 'Current app in focus is com.amazon.tv.launcher'
+ launchDelay
+ local lastChannel
+ local lastAwake
+ local timeNow
+ local timeElapsed
+ local maxTime=14400
+ mkdir -p 192.168.1.231
+ [[ -f 192.168.1.231/stream_stopped ]]
+ [[ -f 192.168.1.231/last_channel ]]
+ echo 801
+ echo 'Current PID for this script is 801'
+ lastChannel=242
+ lastAwake=1693230586
++ date +%s
+ timeNow=1693240029
+ timeElapsed=9443
+ ((  242 == 242  ))
+ ((  9443 < 14400  ))
+ echo 'Last channel selected on this tuner, no channel change required'
+ exit 0
+ finish
+ echo 'bmitune.sh is exiting for 192.168.1.231:5555 with exit code 0'
'
[EXECUTE] Finished running ./scripts/firetv/directv/bmitune.sh in 116.908466ms
[STATS] CPU usage: 4.214294686598494%
[STATS] Alloc = 2 MiB
[STATS] TotalAlloc = 50 MiB
[STATS] Sys = 15 MiB
[STATS] NumGC = 86
[STATS] Total memory: 32034 MiB
[STATS] Memory used: 3446 MiB
[STATS] Memory used percent: 10.75691740670537%```

Do you have the DirecTV app installed on the FireStick you're trying to use? This error message would suggest not.

yes its installed and its working

OK, so let's try this: Launch ws-scrcpy in a browser tab, which for you would be http://192.168.1.195:7655. Then click on shell, and enter: logcat | grep "ActivityManager: START.*cmp=" and post the output here. It should look something like this:

kara:/ $ logcat | grep "ActivityManager: START.*cmp="                                                                                                                                        
08-28 11:23:39.133   535  6146 I ActivityManager: START u0 {flg=0x10000000 cmp=com.att.tv/tv.youi.clientapp.AppActivity} from uid 2000
08-28 11:23:41.166   535  3701 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.att.tv cmp=com.att.tv/tv.youi.clientapp.AppActivity} from uid 10201
08-28 11:24:51.628   535   641 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext (has extras)} from uid 1000

Ctrl-C will break you out of that command. If there's no output, leave the command active and launch the DTV app, and then you should see output.

08-28 13:38:31.780   475   649 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext (has extras)} from uid 1000
08-28 13:39:28.931   475  7339 I ActivityManager: START u0 {flg=0x10000000 cmp=com.att.tv/tv.youi.clientapp.AppActivity} from uid 2000
08-28 13:39:41.801   475  1150 I ActivityManager: START u0 {act=android.intent.action.VIEW (has data) flg=0x10000000 cmp=com.amazon.venezia/.pdi.AppLaunchActivity (has extras)} from uid 10129
08-28 13:39:41.804   475 32509 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.att.tv cmp=com.att.tv/com.clientapp.MainActivity (has extras)} from uid 1000
08-28 13:39:56.221   475   649 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext (has extras)} from uid 1000
08-28 13:40:11.467   475  1394 I ActivityManager: START u0 {act=android.intent.action.VIEW (has data) flg=0x10000000 cmp=com.amazon.venezia/.pdi.AppLaunchActivity (has extras)} from uid 10129
08-28 13:40:11.470   475  1777 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.att.tv cmp=com.att.tv/com.clientapp.MainActivity (has extras)} from uid 1000
08-28 13:40:21.519   475   649 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext (has extras)} from uid 1000
08-28 13:41:01.983   475  1150 I ActivityManager: START u0 {act=android.intent.action.VIEW (has data) flg=0x10000000 cmp=com.amazon.venezia/.pdi.AppLaunchActivity (has extras)} from uid 10129
08-28 13:41:01.985   475  3215 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.att.tv cmp=com.att.tv/com.clientapp.MainActivity (has extras)} from uid 1000
08-28 13:45:08.924   475   649 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.amazon.tv.launcher/.ui.HomeActivity_vNext (has extras)} from uid 1000
08-28 13:45:39.539   475  1394 I ActivityManager: START u0 {act=android.intent.action.VIEW (has data) flg=0x10000000 cmp=com.amazon.venezia/.pdi.AppLaunchActivity (has extras)} from uid 10129
08-28 13:45:39.542   475  2172 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.att.tv cmp=com.att.tv/com.clientapp.MainActivity (has extras)} from uid 1000```