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

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

1 Like

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?

1 Like

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

I believe there is a variable UPDATE_ M3Us that you can set to false.

By design. If you don't want your scripts and/or M3Us updated you need to set their env vars accordingly. For example, these values would prevent either from ever being updated:

UPDATE_SCRIPTS=false
UPDATE_M3US=false

Be sure to read through the comments in the ah4c docker compose, so that you're familiar with what each variable does.

That is what I thought...Thanks!

Yeah, I thought so, just wanted to make sure. I set it to False...Appreciate the answer to a bad question...

Anybody else using the Ospreys seeing DTV ads all of a sudden? I've been getting a screen advertising other DTV subscription channels - with a "Press OK to dismiss".

It eventually closes after about 10 seconds, but the problem is it prevents tuning to the requested channel and records the last channel that was used. It's getting more frequent in the past 2 days...

Is there an easy way to detect text in a video stream so that I can send ADB commands to get the NBC banner to go away? Every once in awhile the NBC app likes to throw up a stupid ad banner at stream start that never disappears, so all I need to do is look for the text "Not now" and if it appears just simply do a down and then enter to make it go away.

The ah4c container includes tesseract now, for just that purpose. Here's an example of a function using it, where a video frame is captured, and then searched for occurrences of any of these three words Guide\|WHAT'S\|SPORTS:

tuneCheck() {
  local sleepBeforeTuneCheck=$1

  sleep $sleepBeforeTuneCheck
  ffmpeg -i $encoderURL -frames:v 1 -y $streamerNoPort/screencapture.jpg -loglevel quiet
  tesseract $streamerNoPort/screencapture.jpg $streamerNoPort/screencapture
  grep -q "Guide\|WHAT'S\|SPORTS" $streamerNoPort/screencapture.txt

  if [ $? == 0 ]; then
    echo "Deeplink tuning appears to have failed. Killing app and re-tuning..."
    $adbTarget shell am force-stop $packageName
    tuneChannel
  else
    echo "Deeplink tuning appears to have been successful!"
  fi
}

In this example, I'm killing the app and re-tuning if the app appears to be "stuck" on the landing page. However, you could send whatever ADB commands you like instead.

Thanks! Yeah I figured you had that in, did some googling on my own and here's the windows commands to check for this in NBC app.

ffmpeg -i %ENCODER_URL% -v 0 -frames:v 1 out.png
"c:\Program Files (x86)\Tesseract-OCR\tesseract" out.png out
find /I "Maybe" out.txt >nul
if not errorlevel 1 (
        adb -s %IP% shell input keyevent KEYCODE_DPAD_DOWN
        ping -n 2 localhost >nul
        adb -s %IP% shell input keyevent KEYCODE_DPAD_CENTER
        ping -n 2 localhost >nul
      )
)
del out.png out.txt

Have no idea whether this will work because the ad banner is random, will have to wait and see but I tested this out and it works with other random text. For some reason ffmpeg takes about 6 seconds to run this on my PC, any way to speed this up? Doesn't really matter I guess because my monitor script runs in background after video is started by bmitune.

Update: did work this morning for an Olympics ad overlay, text to look for was 'Maybe later'.

Finally spent some time figuring why I couldn’t get this to work. Made a print of all my settings then deleted everything. Recreated container using Synology container manager using all my previous settings. Watched the stick thru the pass-thru on the encoder and acted on the ADB prompt (probably my issue all along).

It seems to take a long time to tune (1-1/2 minutes) but that's probably just my setup. I hope that quickens up when I move from my test server.

One issue I did find is that when I attempt to tune to "E", it brings up both "A&E" and "E" channels, then it selects the A&E channel. Is there a way to make it search for the channel number rather than the channel number?

So, my next steps will be:

  1. Set up container on main DVR
  2. Set up Olive Tin using Portainer on test DVR.
  3. Get some new sticks and a multi-port encoder

Synology DSM 7
Directv Stream
Firestick 4K
Uray Single port Encoder

1 Like

With remote control emulation, reliability has been emphasized over speed, but that does slow things down. With my previous setup, it was more on the order of 30 seconds as I recall. You'll probably want to switch to a FireStick 4K Max 2, to speed things up.

Not sure if you've been following this thread, but deeplinks can now be derived for both DTV and DTV Stream. It's a bit of an advanced skill to get them, but it can be done. The deeplinks are different depending on what type of DTV customer you are, and where you live.

I've been using deeplinks for the last couple of months, and they've been working well with ah4c. It's definitely faster, and maybe a bit more reliable -- though both methods are good. Something to think about doing if you're confident with your computing skills, but something of a hill to climb if you're not.

Yep, It's time to do a Firestick trade in again.

My main reason in getting this to work is the upcoming Olympics. Other than the tuning delay, I'm quite happy because I can record events that I want. I plan to install the container on my main DVR NAS today thus freeing up the test DVR NAS for additional testing.

I think my next step will be setting up using Portainer rather than the Synology Container Manager. Portainer is already installed on the test NAS. I'll install Olive Tin and go from there. Having a test NAS helps with the WAF.

I'll look into deep links after I feel more comfortable with Portainer and Olive Tin.

On an off topic question, I'm wondering if the FireTV Live project would accomplish the same thing since I'm only looking at 20-30 channels.

Sounds good. Portainer has many more features, is cross-platform, and will allow you to use Project One-Click.

Taking it a step at a time is a great approach.

It would, but I think you're better off with what you're using now. Both are using remote control emulation, but the LiveTV approach is something I'd only recommend if that's the only option.

1 Like

Keep getting these errors in Channels now whenever I try to tune anything. I did not change anything, it just started happening. I have rebooted everything and restarted everything. Same issue.

2024/07/23 19:17:32.693980 [HLS] Stopping transcoder session ch1016-dANY-ip10.1.1.205 (out=0s finished=false first_seq=0 last_seq=-1)
2024/07/23 19:17:33.807774 [ERR] Failed to start stream for ch1016: M3U: GET: http://10.1.1.201:7654/play/tuner/216: 500 Internal Server Error
2024/07/23 19:17:33.807877 [HLS] Couldn't generate stream playlist for ch1016-dANY-ip10.1.1.205: M3U: GET: http://10.1.1.201:7654/play/tuner/216: 500 Internal Server Error
2024/07/23 19:17:33.807940 [HLS] Stopping transcoder session ch1016-dANY-ip10.1.1.205 (out=0s finished=false first_seq=0 last_seq=-1)

For some reason I had to reauthorize the player. Not sure if it's because of the Update to the Osprey. Seems to be ok now.