HDMI for Channels

OK, so for those of you using the ah4c project with DirecTV or DTVStream, an app update started rolling out several weeks ago -- though my sticks only got it yesterday. Thanks to @gfhartzell for letting me know of its existence.

I've made some preliminary changes to scripts/firetv/directv/bmitune.sh to support the new app version. I'll push a container update soon, after I've done additional testing.

However, for anyone that wants in on the fun now -- there's only one function tuneChannel() that appears to need modification, and here it is:

#Tuning is based on channel name values from $m3uName.
tuneChannel() {
  channelName=$(awk -F, '/channel-id='"$channelID"'/ {print $2}' m3u/$m3uName)
  channelName=$(echo $channelName | sed 's/^/"/;s/$/"/')
  numberOfBackspaces=25
  clearSearchBackspaces=$(for ((i=0; i<$numberOfBackspaces; i++)); do echo -n " KEYCODE_MEDIA_REWIND"; done)

  directvMenu="input keyevent KEYCODE_MENU; sleep 6"

  directvSearch="input keyevent KEYCODE_DPAD_LEFT; \
                 input keyevent KEYCODE_DPAD_UP; \
                 input keyevent KEYCODE_DPAD_CENTER; sleep 1; \
                 input keyevent KEYCODE_DPAD_CENTER; sleep 1"

  directvClearSearch="input keyevent$clearSearchBackspaces"

  directvTune="input keyevent KEYCODE_MEDIA_PLAY_PAUSE; sleep 1; \
               input keyevent KEYCODE_DPAD_DOWN; \
               input keyevent KEYCODE_DPAD_DOWN; \
               input keyevent KEYCODE_DPAD_DOWN; \
               input keyevent KEYCODE_DPAD_CENTER"

  $adbTarget shell $directvMenu
  $adbTarget shell $directvSearch
  $adbTarget shell $directvClearSearch
  $adbTarget shell input text "$channelName"
  $adbTarget shell $directvTune
}

I'm only able to test with my DTV credentials, and we have seen some slight differences for those with DTVStream credentials in the past -- so if you try this out, be sure to give me feedback here, especially if you have DTVStream.

EDIT: Small change to the tuneChannel() function to make clearing the search field more easily configurable. Hard coded moves replaced with a loop.

2 Likes

Good news! The fix is in and eary manual tuning testing looks good with DirectvStream. I will do further testing with scheduled recordings tonight.
Thank you for the fix

Recordings went ok Its looking good here!

1 Like

Same in my testing. Multiple DTV/ah4c recordings -- all good. The Aussie Open recordings I've been doing, via the Tennis Channel on my server in the US, are looking fabulous here in Portugal on a 55" TV. CDVR + ah4c + Tailscale = remote TV excellence! :slight_smile:

3 Likes

I've started a new thread specific to the dockerized version of the ah4c project, mostly because there's so much outdated information here related to the early days of this project. Hopefully, this will make it easier to differentiate between what ah4c is best for, and where ADBTuner is preferred:

3 Likes

It seems that the two major forks of this project both use Android sticks and ADB but that wasn't an option for me as a Spectrum user as there is no app for Android/Fire TV. I actually started out using the chrome tab capture but with a dedicated i5 8500t I was still getting consistent stutters every few minutes. With that machine taking around 10w idle and 25w during streaming, I didn't want to throw any more power at it.

My next try started with the original github ah4c project using a Link Pi Enc1-v3 being fed by a Spectrum 110-H set top box. I had a pretty janky script that used a switchbot mini to blast ir signals for tuning. The streaming quality was great and the tuning speed was reasonable, but annoyingly the 110-H actually has certain channels only in SD. These same channels play just fine in HD both through the website and the apps.

My next step was to add a USB HDMI capture dongle to the Link Pi with a Roku 3800x streaming stick. I already had the stick and saw that there was an api that supported starting the Spectrum app and pressing buttons. For this, I made an even jankier script that used key presses to bring up the guide and scroll through channels 4 at a time to get to the right channel. It was actually pretty reliable but tuning speed could be up to around 20s to get from the farthest channels. This solution also had the drawback of requiring that the roku app stayed on and streaming. I toyed with letting it sleep, but starting the Spectrum app from scratch and tuning was unreliable and would take on the order to 40s when it worked.

The solution that I settled on is still based on the original ah4c repo but I've replaced the STB and Roku with a couple of used Apple TVs that I picked up on ebay for ~$40. Another user, @chasut, posted about a solution with Apple TV via Home Assistant and also linked to the Apple TV python library that Home Assistant uses. It turns out that python library comes with a utility called atvremote that actually has everything needed without even getting into the python. Setting up and connecting to the Apple TV is through a guided wizard and then tuning is just a single command.

atvremote -s $1 launch_app=spectrumTV://watch.spectrum.net/livetv/$2?linkorigin=sirilivetunein&idtype=tms

$1 is the ip address of the paired Apple TV and $2 is the tmsid for the channel that you can grab off the Spectrum web player. Tuning is quick and reliable and stopping the channel returns home so I'm no longer streaming 24/7. I'm still working on a smoothness issue with my Google TV sticks but I'm sure it's something to do with those sticks and my Link Pi settings as the streams are completely smooth on all of the other platforms that I've used.

Overall I'm very satisfied with end result. This was originally motivated by getting Nick Jr and Tennis channel working again but now I've also gained access to a bunch of Spectrum sports channels and premium movie channels that I mostly ignored since I couldn't get them into Channels.

Thanks to the devs and many users that have posted their experiences and helped me get this up and running! I'm happy to share more details of my setup, but honestly the pyatv tools take most of the work out of it.

6 Likes

Excellent!

My setup is still running on the original go app on the Mac mini that hosts CDVR. I think I will follow your lead and try moving over to ah4c in docker on my NAS just to clean things up a bit.

Would you mind sharing your environment variables used for ah4c? Particularly those for the tuners and encoders. My command will be a little different but the reference will help me figure out what I need to do.

over the last couple of months my experience with this little bodged-up solution has been far better than expected. The only issue in that time has been an auto update of TVOS that presented a modal information screen that needed to be cleared. Turning auto update off is an easy solution. I also completely removed the prebmitune.sh bit from the process. With the direct tune I could see no value and saved almost a half second in tune time.

I recently prioritized this over TVE in CDVR, so far so good. Picture is just as good, and better in many cases. Plus I have access to [almost] every channel in my subscription.

I feel fully prepared for any coming apocalypse with TVE.

3 Likes

I think I got my terminology a bit mixed up but I'm not using the ah4c docker container, I'm also still just using the original go app. Like you, I've gotten rid of the prebmitune.sh. The other change that I've made is to add in a small delay to the start of the stream just to prevent the stream showing the atv home screen or spectrum splash screen.

That's a good tip on the auto updates. I just got hit with that so I've also now disabled auto update. For now I've still got TVE ahead in priority but that's because I do a lot of recordings on TVE available channels and only have 2 atv tuners and want to keep them open for Nick Jr. I'm also feeling prepared for the TVE apocalypse. The question is... whether to add another Enc1-v3 for 4 tuners total or... go for the Enc5-v2.

Where did you place the delay in the code? That is on my list if things to do as well.

I am going to tinker with going to ah4c in docker and happy to share once I get there. It is either that or wrap the go app in "forever" or something so that it will auto start and run in the background. At this point I have had zero issues with tuning reliability (other than the update thing) so don't even know where to start with hardening.

FWIW, I started with the Enc1-v3 but they were not available in December. So I added two of the Uraycoders for a total of 3 tuners. My thinking was that by having it fully modular with individual encoders, I could add/upgrade one at a time as needed. I don't know if that is smart or not, but that is what I did. I would really like to add surround sound, but as of now, not only do the encoders not support it, but the Spectrum app doesn't yet either. To me, the improved sound is more important than 4K. Either way it isn't cheap, but oh so satisfying.

For the delay, I moved the execution of the start script from the Read() function to the tune() function before the call to http.Get(). I'm not very far removed from a Hello World level with Go so it's very possible that wasn't the best thing to do, but it appears to have achieved the result I wanted. Currently I've got the go application running as a service but containerizing it to package up the different pieces would be a great move.

Do you notice any difference in quality between the Link Pi and Uraycoders? Also what device do you use on the client side for CDVR? I'm currently mostly using the Google TV with Chromecast but after playing around a bit with the Apple TVs as tuners, the dead simple ad free UI is appealing.

I am with you on Go, just reading it makes my head hurt. What I think I understand is that the result is not so much a delay in the tuning, but just tuning BEFORE the url is passed to CDVR. That would be a superior solution in this context. But then again, I could be reading it wrong!

In my experience the Uray produces a [slightly] better result. I don't think it is worth the price difference. But enough that they are in the first two slots in the tuner bank. That said, you would need pretty highly calibrated eyes to tell the difference. IMHO, the key to this whole approach is having a quality feed on the input. I think the encoding bit is more of a commodity until you get up to the high-end stuff.

I long ago sold out to apple, so all my TVs use the Apple TV box. I really like them and that silly remote. That is why I had a box full of old ones laying around just for this project.

@icnerm

I am working on getting spectrum to work also. I had also tried to use a Roku and also can't use my FireTV sticks or Onn 4k's because of the lack of a spectrum app. I was looking on ebay and was thinking about picking up a couple 3rd gen apple boxes. One of the sellers say it is reset to factory defaults but only the apps already installed are available and you can't install any additional ones including spectrum tv app. I am not at all familiar with apple tv's. I don't know if this standard for 3rd gen or not. Can you recommend which ones you are using?

Thank you

AFAIK those won't work because they don't support the App Store so you cannot load the Spectrum app. You will need at least the 4th gen. If you discover otherwise, please let me know. I have a box full of those too.

I am using 2 of the older 4Ks and 1 of the original 4th gen. All work great.

If you're going for a multi tuner setup, one thing I found was that it is usually cheaper to get Apple TV units that don't come with a remote. As long as you have 1 remote, it's easy to pair with each unit to go through setup. Once they're set up, you shouldn't really need the remote. Also once they're set up, you can control them with atvremote if you go that route or any iphone or ipad. If you really need to, it's also really easy to just re-pair them with the remote that you do have.

1 Like

I tried to replicated moving start script with no luck. I just have no understanding of that io.reader thing.

What I did do is completely remove the dependence on the bash scripts and instead running the curl command directly in main.go. After a lot of trial and error I got it to work. Just wow. I didn't expect it to make that much difference. It tunes much faster and by the time the stream comes live the tuning is complete; little to no Spectrum navigation stuff. Really slick.

Based on these results, I am convinced that there is more room to improve. I have no idea what I am doing, but it seams to be working. I think this could be a no-compromise solution to both replacing both TVE and HDHR Primes.

Anyway, I am excited and thought I would share.

[Edit]
Tune times from a few random sampled channels using a stopwatch
HDHR OTA ~2.5s
HDMI Tuner ~ 2.6s
TVE ~3.6s

Interesting results! I'll have to play around with eliminating the script altogether as well. I only kept it around in case I wanted swap out what was being controlled but if there are gains to be had, it would probably be worth it.

With the system up and running, I've been looking at power consumption. Currently I've got an Apple TV 4k 2nd gen and an Apple TV HD 4th gen. Even though the 4k is newer, it idles at around 2.7w while the HD idles at 1.6w. While streaming, the 4k is around 3.5w and the HD is at 2.4w. This may be influenced by the fact that the 4k is running and streaming at 1080p while the HD is at 720p since it's connected to the USB HDMI input on the Link Pi. Another observation is that if the video preview is running on the home screen, the 4k goes to 2.9w idle while the HD goes to 2.2w.

TLDR: All of these thing sip power but the 4th Gen non 4k uses about 1w less than the 2nd gen 4k Apple TV and disabling the video preview saves a bit of power.

Thank you for the power data. Doesn't seem like much having 3 running 24hrs/day adds up quickly. I intend to move all this up to my server closet and don't need the additional power and heat load. They are currently tucked away in an AV cabinet, but don't want it there long term.

I am thinking that I may put the ATVs to sleep after a period of not being used. The only real downside is that the first tune coming from sleep takes ~7 seconds. Tuner 1 does most of the work, so this may be a good solution to minimize resource usage, particularly for tuners 2 and 3.

Also, the things tune lighting fast if I just have it exit to the Spectrum menu instead of going to the ATV Home Screen. Problem is that the Spectrum app is always running the last tuned channel in the background. So not only is their moving video, but the last channel stream is still active, using internet bandwidth. If the Spectrum app had a setting to go to a static screen, that would be ideal.

Can you show me the changes you made? I tried to do this but was not able to make it reliable but maybe I just need to look at it again with your changes!

I'd like to try this too, but there appears to be no application to install. Does anyone have some quick instructions on how to us this? Is it done through powershell (windows)?

This project looks cool, but there is too much info in this Thread for me to digest. I get the hardware requirements (encoder, Google Tv, etc.), but without rolling up my sleeves and getting hands on with everything it is hard for me to visualize all the necessary pieces to get this working.

My main point of confusion is all the steps necessary to have it change channels automatically so the streaming device can tune into the correct channel for recording. I'm sure I could eventually figure it out with all the information and help from others here, but it still sounds like a hodgepodge setup.

Some questions for the group...

  • Is this something that Channels DVR can add in to the CHDVR server eventually? If so, I will likely wait until the implementation is available.

  • Is it possible to use Home Assistant to automatically change the channels based on a request from the Channels DVR server? Android TV Remote - Home Assistant

  • Is there any advantage to using a encoder/decoder (instead of just an encoder). I see some device specifically state they decode as well. 4k Video Encoder-Decoder

  • Is it possible to replace the video encoder with a small intel NUC, something like THIS using hdmi to USB device? I believe the intel n95 can do hardware encode/decode for h.264 and h.265.