ADBTuner: A "channel tuning" application for networked Google TV / Android TV devices

Good morning to you as well. I hope that you're enjoying a nice holiday weekend.

In performing more testing this morning, I'm finding that when using the default mode configuration, the channel pauses in the DTV app, and the app stays open. You have previously mentioned that tuning was faster from this state. I agree that tuning is faster and more reliable when keeping the last channel paused with the app open. I'm not sure why the DTV app closed overnight and dumped all of the tuners to the "apps only" home page on the ONN boxes.

The default config pauses the app and leaves it running. You can also use Media Home (button) to go back to Home Screen instead of pause. This will also leave the app running in the background, and will lead to faster tuning.

Overnight is likely sleep state of the Onn 4K cause the app to hang a bit in resume.

Hmm... I thought that I had set them to not allow sleeping. I'll have to check my developer settings.

I wonder if the ADBT "Keep Device Awake" feature, set to use the "com.att.tv" package would do the trick?

Not a bad idea triggering a keep awake. Not sure if that would leave a video playing constantly.

I’m gonna grab lunch but will fire up my legacy Onn 4K boxes for some testing this afternoon.

Share any quirks you find, happy to test. I think I enjoy the troubleshooting these automations setups more than watching actual television shows.

As you suspected...keep awake triggered all of the boxes to play, rather than holding with a paused screen. I don't need that much traffic constantly running through the network. I know that when you launch the app, it automatically starts playing the last watched channel. With the app launch preference set to "Live TV" it plays full screen. Even with the launch preference set to "Home", the last channel resumes play in a window on the home screen.

I bet that's why the YouTube TV app worked better. It allowed you to disable "auto-play on start".

Funny that you say that you prefer troubleshooting to actually watching TV. I guess I'm kinda the same way. I can't relax and enjoy programming if things aren't working the way I want them to. I'm already on my fifth day of obsessively fiddling with this dadgum contraption.

As a longtime user of DirecTV with ah4c (I switched to YTTV a few months ago), I'll suggest what I found as the answer for reliability -- which didn't used to be possible with ADBTuner (but maybe is now?).

For me, the sequence was to launch the app first, get to the point where the last channel was streaming (by detecting active audio) -- and then send the deeplink. This was the behavior from the point of an app update sometime last year until I quit using DTV in April.

It's possible they've changed the app again, but at least in my experience of many hundreds of hours of watching and recording -- this is the way.

EDIT: As a side note, the sequence I followed always put my Fire TV 4K Max devices to sleep at the end of a tuning cycle -- no unwanted power consumption or un-needed Internet traffic happening.

Also, keep in mind with these encoders, if there's an active stream or even a static menu they're doing at least some encoding -- ranging from a little (semi-static menu) to a lot (active stream).

So, I did some research on the DirecTV app. It answered a couple of questions I had been wondering about.

Q1: Why did it seem that when a recording or live viewing completed and the channel was released by ADBTuner, the channel would stay paused for a while and then spontaneously start playing again?

A1: As with many DVR or streaming clients, there is a limit to the live TV buffer. In the case of DirecTV, it is about one hour. Maybe less, if you run out of space on the device. When the buffer is exceeded, the pause is released, starting to play from the paused point.

Q2: When the streams were all paused last night, why were all of the DirecTV apps closed and the tuners returned to the home screen of the devices?

A2: After four hours of continuous non-stop playing without interaction from the remote, the app will ask "Are you still watching?" If no response is made, the app automatically closes.

The keep awake function should likely override these buffer and are you still viewing issues and keep the channels alive constantly. Certainly, this is not ideal. It is probably better to release the app shortly after each viewing or recording.

That being said, the key to getting these DirecTV apps tuning efficiently will be what @bnhf suggested:

How do I/we achieve this goal? Is it as simple as creating a new configuration/mode json for the DirecTV channels to use? Something similar to the custom config @spammedeeper recommended to me earlier? If so, what shall I change, if anything?

I have about a 2-1/2 year history with DTV and ah4c -- first with remote control emulation, and more recently with deeplinks. I feel like I've been down just about every rabbit hole including this one. As you've discovered, pausing the stream in lieu of a "stop" is really not a viable option.

Several of us have worked on this problem (search the ah4c thread), which has been something of a moving target as the app is updated. I'm not aware of any working solution here. I do include tesseract ocr in the ah4c image, and theoretically one could start to do screen grabs as the 4 hour mark approaches. Figuring out how to prevent the pop-ups would be the best, but I never found the answer.

In my Xfinity script, which has the same 4 hour pop-up, I can prevent it by sending a down arrow using an ad hoc script. This script is created during channel tuning, and sends the keycode a couple of minutes before the pop-up would otherwise occur:

tuneChannel() {
  $adbTarget shell am start -n $packageName/$packageAction https://www.xfinity.com/stream/live/$channelName/$channelID/$channelName
  echo -e "#!/bin/bash\n\nwhile true; do sleep $KEEP_WATCHING; $adbTarget shell input keyevent KEYCODE_DPAD_DOWN; done" > ./$streamerNoPort/keep_watching.sh && chmod +x ./$streamerNoPort/keep_watching.sh
  [[ $KEEP_WATCHING ]] && nohup ./$streamerNoPort/keep_watching.sh &
}

The same kind of thing could be done with screen grabs starting a couple of minutes before the 4 hour mark.

The active audio check is something I use quite a bit in ah4c, both for this purpose and to confirm a successful channel tune. I even use it to deal with sports blackouts. I'm not sure if ADBTuner has anything like this available for use in custom configs:

#Check for active audio stream with maxDuration, preTuneAudioCheck, sleepBeforeAudioCheck and sleepAfterAudioCheck as arguments
activeAudioCheck() {
  local startTime=$(date +%s)
  local maxDuration=$1
  local minimumLoudness=-50
  local sleepBeforeAudioCheck=$3
  local sleepAfterAudioCheck=$4
  local preTuneAudioCheck=$2
  
  while true; do
    sleep $sleepBeforeAudioCheck
    checkLoudness=$(ffmpeg -t 1 -i $encoderURL -filter:a ebur128 -map 0:a -f null -hide_banner - 2>&1 | awk '/I:        /{print $2}')

    if (( $(date +%s) - $startTime > $maxDuration )); then
      echo "Active audio stream not detected in $maxDuration seconds."
      if [ $preTuneAudioCheck = "false" ]; then
        echo "Active audio stream not detected after tuning completed"
        echo "Killing app and re-tuning..."
        $adbTarget shell am force-stop $packageName; sleep 2
        tuneChannel
        exit 0
      else
        exit 1
      fi
    fi

    if (( $(echo "$checkLoudness > $minimumLoudness" | bc -l) )); then
      echo "Active audio stream detected with $checkLoudness LUF."
      break
    fi

    echo "Active audio stream not yet detected -- loudness is $checkLoudness LUF. Continuing..."
    sleep $sleepAfterAudioCheck
  done
}

This has been an important function in ah4c to keep tuning times as reliable (and short) as possible.

Been testing for a few hours after pulling one of my Onn 4K out of mothballs. Still working on write up but wanted to let you know in will share details soon. DTV App is finicky. Thanks for sharing your findings.

This one I can share quick info on. Osprey Boxes don’t have the 4 hour time out (if you want to disable it). Not that I’d leave Osprey Boxes running 24/7 as they get warm, but a full day of sports in the background, yeah.

I understand from you and @bnhf that the Osprey boxes with AH4C are the way to go with DirecTV. I'm hesitant to invest in equipment that is dedicated to a single provider.

I'm hoping that we can get ADBTuner working well with DirecTV. I'd rather throw some funds at newer onn boxes like the 4k plus or pro devices. At least there's more flexibility as they accommodate Peacock and Paramount Plus deeplinks in addition to DTV and YTTV. Also, I could repurpose them as Channels DVR Clients at some point down the road.

No doubt! For anyone starting new with DTV, AH4C with Osprey boxes are the way to go. Power On Tune channel, power off. Tuning is simple, reliable and fast. I set up AH4C and just kinda left it alone. In 2023.

That said, I’ve been spending most of my time lately in this thread. I love to tinker. I became super encouraged when I found Deep Links actually worked in the DTV app. My two Onn 4K boxes were fine to play with, but I wanted to compare to the new Plus model. So I bought some.

Agree, we should get your existing Onn boxes working as a Parts Bin solution. Although the Plus boxes are faster, the ultimate stream quality is nearly identical between the plus and regular 4K boxes. I will help.

It's easy to lose track of time when you're trying to chase down elusive tech quirks. Thank you very much for dedicating so much time and effort to this pursuit.

I did look at the specs of the different onn boxes. The 4k is wifi 5, the others wifi 6. The 4k and plus have 2GB ram, pro has 3GB. Storage: 4k:8GB, Plus:16GB, Pro:32GB. The processors are all fairly similar.

I'm just beginning to learn a little of this stuff as it relates to ADBTuner. It was only this past week when I learned how to use a json editor in very most basic terms. :laughing: I have no idea how to create these configuration json files for ADBT. I'm interested to see what commands can be used and how much may carry over from the AH4C setup. (which I know even less about).

Been testing today with the goal of reliable tuning using DTV App and Onn 4K boxes. I pulled one of my Onn 4K (O4K) out of mothballs, put into production to test with the newer Onn 4K Plus (O4KP) boxes.

General Findings

  • On my network, the O4K Boxes (WiFi5) had at least 2-3 times greater network latency than the O4KP Boxes (WiFi6).
  • From cold start, the DTV App launches in about half the time on the O4KP versus the O4K.
  • Once stream has started, the DTV app video quality is about the same on O4K and O4KP.
  • When the O4K is in standby by or Doze (deep sleep), the wake up command introduces a good bit of network latency which I don't see on the O4KP boxes.
  • The O4K has another latency spike once the DTV App is open, likely as it tries to start the preview video for last channel tuned.
  • If the DTV app is left open, or tuning fails leaving the app in limbo, it will not reliably respond to Deep Links. In fact, it made one of my O4KP boxes stop responding to physical remote commands.

Comments

Right off the bat, I will be the first to admit my WiFi testing is not scientific. Comparing WiFi5 to WiFi 6 is not direct, and everyone has a different RF environment in their homes.

Less interesting is the latency difference, but the impact activity seems to have on latency. The O4K would, lightly, blip when resuming from sleep and during DTV app start up. I suspect this is the CPU at play. The O4KP does not seem to be bothered by the activity. As observed during reboots, app launches and overall UI responsiveness, the O4KP CPU is noticeably faster. I've also noticed in previous testing my O4K boxes are not predictable, don't always act the same. I suspect this is also CPU related, thermal throttle as the O4K boxes can get warm. Granted, they are a few years old.

Testing and Results

I focused most of my testing on DirectTV App quirks. As mentioned earlier, the app can get set into a "wonky" state. It just stops responding to ADB and will leave the tuner open in ADBTuner. This is not ideal. I found restarting the DTV App fresh at each tune is the best hope for response to deep link. This does mean tuning is not as fast as leaving the app open, but I could not find a predictable way to do this, at least on the O4K boxes.

Next I worked around the little latency blips I experienced. I realized the O4K needs a small delay from sleep to home screen, before launching the DTV app. Coming out of sleep, the load of launching the DTV app added enough latency to periodically fail ADBTuner connection. Sometimes this was a failed tune, other times a tuner left open. Adding just a few second delay between the ADBTuner pre-tune and tuning commands, via custom config, did the trick. This even seems to work around resume from Doze/Deep sleep.

Lastly, I worked to keep tuners from being locked in ADBTuner. I found powering down the device at end of tune would not only save power, but make the device less "busy" for the next time the device was called to tune. And it cuts down CPU time, both on the O4K and my LinkPi.

In attempt to simulate worst case scenarios, I tested the O4K box while my other four tuners were live. I also put the O4K into deep sleep to test slow, wake response. During my few hours of testing, the O4K worked pretty well. Tuning was was in the 12 second range.

Recommendations

In case you skipped to this section in TLDR fashion, here is what I recommend.

  • Open a fresh copy of the DTV app at each tune.
  • Disable any unnecessary network settings on O4K to limit CPU and Network Load.
  • Power down the O4K when tuning completes.
  • Use the awesome ADBTuner custom configs for better control (see sample below).

ADBTuner Custom Config for Onn 4K

{
    "name": "DirecTV App - Onn 4K",
    "author": "spammedeeper",
    "version": "0.1",
    "description": "Reliable Tuning of DTV out of Doze",
    "uuid": "94634da2-badb-4a16-b150-add7075870ac",
    "global_options": {
        "wait_for_video_playback_detection": true,
        "use_fixed_delay": false,
        "fixed_delay_seconds": 0,
        "check_for_and_clear_whos_watching_prompts": false
    },
    "pre_tune_commands": [
        "input keyevent 3",
        "sleep 2"
    ],
    "tune_commands": [
        "am start -W -a android.intent.action.VIEW -S -d '||TARGET_URL_OR_IDENTIFIER||' '||TARGET_PACKAGE_NAME||'"
    ],
    "post_tune_commands": [
        "input keyevent 3",
        "input keyevent 26"
    ]
}

Few tidbits on the config above:

  • This config was tested specifically on Onn 4K (2023), but also works with Onn 4K Plus.
  • The Pre Tune sleep value can be 1 or 2 seconds. You will need to test. When you get to 3 seconds, you may start getting close to the Channels DVR timeout.
  • In the Tune Commands line, the -S switch is what closes the app right before opening the app again. This is faster than closing DTV app in the Pre Tune section.
  • Key Event 3 is HOME, Key Event 26 is POWER (button)

General Settings to Change

The following list contains settings I changed, trying to limit any unnecessary network latency and CPU activity on my O4K. They helped a tiny bit, nothing major, but they are how I tested.

  • Apps Only Mode for Home Screen (Profile Setting)
  • Turn off HDMI CEC under Display & Sound
  • Turn off Casting Support
  • Turn off Scanning Always Available in Network & Internet
  • Turn Cast controller to Never under System.
  • Turn Off Scan for nearby devices under System
  • Turn off Mobile data always active under Dev Options
  • Turn all Animations (three of them) to Animation off under Dev Options
  • Turn ON Disable USB audio routing under Developer Options

Wrap Up

I think there is value in exploring this Onn 4K and DirecTV combo in ADBTuner. I know many users have Onn 4K boxes, which are perfectly fine for 1080P video. And DirecTV Genre Packs can be attractive if they offer the channels you need.

My goal with any Channels playground project is reliable tuning. Most of my television viewing is by recording, so I don't mind slower tuning speeds. When I do watch live TV, it's not to channel flip, so again speed is not a big deal for me. If you are looking for a more cable like experience, need turning response, Android TV with YouTube TV or AH4C/Osprey Boxes with DirecTV are better experiences.

Where this project focused on making best use of Onn 4K boxes, I have mentioned the Plus boxes many times. They are noticeably faster then the standard Onn 4K and an excellent value at $30, but they are not the only choice. I hear the Google Streamer is nice, as is the Onn 4K Pro, both more expensive. If I make more time, maybe I'll do some DTV testing on some of these boxes, along with my dormant NVIDIA Shields. Maybe test out this "Ethernet" the kids keep talking about. /s

Anyhow, I hope this info helps. I've been taking notes throughout the day. Happy to continue testing or answer any questions.

Happy Streaming.

2 Likes

So if I'm reading all of these posts correctly, the DTV situation is as follows:

  1. The app cannot be left open because it will stream video forever.
  2. The app cannot be left running in the background because sometimes, not always, it will fail to load the next deeplink.
  3. Standard "compatibility mode" in ADBTuner can be reliable, but it may be too slow on some device resulting in time outs.

Is this correct?

Perhaps a configuration that just starts the stream after 10 seconds (well 10 seconds + tuner reservation time, + the built in 5 seconds wake up time for sleeping devices) would be a reasonable compromise?

The stream might include some of the app opening sequence, but I guess it's better than nothing if you are using a slower device?

{
    "name": "DTV Test",
    "author": "",
    "version": "0",
    "description": "Loads content via deep link URLs (where supported) and starts the stream after a fixed amount of time.",
    "uuid": "fe98787d-799d-46a4-8178-ddfa5c0b3dcf",
    "global_options": {
        "wait_for_video_playback_detection": false,
        "use_fixed_delay": true,
        "fixed_delay_seconds": 10,
        "check_for_and_clear_whos_watching_prompts": true
    },
    "pre_tune_commands": [
        "input keyevent KEYCODE_MEDIA_STOP",
        "am force-stop '||TARGET_PACKAGE_NAME||'",
        "sleep 2"
    ],
    "tune_commands": [
        "am start -W -a android.intent.action.VIEW -d '||TARGET_URL_OR_IDENTIFIER||' '||TARGET_PACKAGE_NAME||'"
    ],
    "post_playback_start_commands": [],
    "post_tune_commands": [
        "am force-stop '||TARGET_PACKAGE_NAME||'",
        "input keyevent KEYCODE_HOME"
    ]
}

Somewhat related, I pushed an update (20250831-1) to the development version this morning.

In this update, the default Compatibility Mode configuration now navigates to the Home Screen after closing the app. This should help in situations where quitting the app might bring another app to the foreground that is playing video.

For testing purposes, I added a new default configuration named Deep Links - Compatibility Mode - Show Tuning Process. It does exactly what the name suggests. It runs the provided commands and then immediately starts streaming to the playback device.

2 Likes

Another excellent post @spammedeeper. Good detail and thorough. I have not tried DTV but if I get some free time I will try it out with my ONN 4K Pro boxes. I'm a little short on tuners right now. My 4 x ccwgtv boxes no longer work since they upgraded to android 14 and I'm holding out buying more for now. I want to see if they upgrade the ONN 4K Pro (rumors) but not sure how long I can wait. I've offloaded my TCM recording to TVE which has worked good for the oldies for the grandparents. I like using YTTV for the quick tuning and very reliable recording with ADBTuner. It may cost a little more but I would rather pay a little more than be getting asked why something is not working!

Hats off to @turtletank and @spammedeeper for all their work!

I apologize if you have answered this already, but have you tried using the default deep link configuration with Fubo? It seems to work fine in my testing.

Thanks for all the support you have been providing in this thread. Quick question, when you say "keep tuners available" here what are you referring to? There should be nothing on the Android side that could keep a tuner locked within ADBTuner. In a worst case scenario, a failed tuning attempt, the tuner might stay locked for 20-40 seconds after the tune fails, but putting the Android device to sleep shouldn't change this. If I'm missing something, please let me know. I would like to fix the bug if there is one!

Happy to assist. I will write up a how to on building a custom config later today.

As to tuners locks, I found during testing that shutting down the app, or making the device sleep, seemed to more reliably release the tuner. This is not something I tested for specifically, more something I noticed in the hours of testing. On that note, the most current dev build has been pretty stable for me.

I wasn't able to get the standard deep link to work with Fubo. I came up with a custom config that works most of the time. I think it's something with the ONN 4k pro box. I actually started using the Fubo Bridge which to my surprise still has most of the channels in the clear. So for now at least, I only need ADB Tuner for a few channels.
I expect this to change.

Thanks for all your work on this project. It is truly amazing in my view.

1 Like