HDMI for Channels

Here's the full output:

08-19 13:15:06.060  3437  3437 I ContextMenuFilteredStationListManager: Setting last tuned station to be: Station{mUserStationPreference=UserStationPreference(id=Key(baseKey=BaseKey(stationKey=Showtime,, source=com.sling/com.movenetworks.livetv.LiveTvInputService), profileId=amzn1.actor.person.did.AMC26YQNZB325Y2YB7L3JSVTAFBYTTB42F3ZD5O2KY4IEACGUC45GJAJ56TUYB3NSK6GCWB4), lastTuneTime=1692472503446, tags=[FAVORITE], userRanks=[StationRank(groupId=favorite, rank=0)], hashedKey=42b5b2ac8cd03cbe01520392e54d0bf57283c04e9f3fbb7ed3795073bad1d34b), mStationMetadata=StationMetadata{mPackageName='com.sling', mStationKey='Showtime,', mTifName='Showtime', mDisplayName='Showtime', mDisplayNumber='', mEnhancedLogoUrl='https://m.media-amazon.com/images/S/msa-images/station-images/49addf8a29b25a490628b5e67dbd3677-tms_21868._FMpng_SY540_.png', mLocalLogoPath='content://android.media.tv/channel/17/logo', mAmazonId='amzn1.p11cat.station.f4981c13-4df8-52f2-8723-132293b163d0', mTifChannelId=17, mTsid=0, mOriginalNetworkId='1079', mServiceId='0', mAffiliateCallsign='SHOWHD', mAffiliateName='Showtime HD', mMetadataExpirationTime=1692727485745, mAttributes=[ENTITLED, HDTV], mGenres=[], mProviderGenres=[], mRankingOptions={}, mPlaybackInputId='com.sling/com.movenetworks.livetv.LiveTvInputService', mPlaybackChannelUri='content://android.media.tv/channel/17', mChannelType='TYPE_OTHER', mServiceType='SERVICE_TYPE_AUDIO_VIDEO', mExternalIdType='gracenote_ontv', mExternalIdValue='21868', mPlaybackDeepLinkUri='slingtv://watch.sling.com/1/channel/7f5f5993457648d68db2fa5d5103cbcc/watch?linkContext=amazonLiveTV&trackingId=amazon-gracenote', mBrowsable=false, mSearchable=false, mShortName='null', mBarkerChannelId=-1, mUid=17, mInternalChannelNumber=1.7976931348623157E308}}

So should I try this as my URL?:

mPlaybackDeepLinkUri='slingtv://watch.sling.com/1/channel/7f5f5993457648d68db2fa5d5103cbcc/watch?linkContext=amazonLiveTV&trackingId=amazon-gracenote'

Using the @boukmandutty structure above -- something like:

am start -a android.intent.action.VIEW -d slingtv://watch.sling.com/1/channel/7f5f5993457648d68db2fa5d5103cbcc/watch?linkContext=amazonLiveTV&trackingId=amazon-gracenote

EDIT: Definitely works for the current movie, we'll see if the ID is persistent.

Unfortunately it does change when grabbing the URL from the browser -- but we might be on to something using the @turtletank logcat | grep "mPlaybackDeepLinkUri". It's a different ID altogether. I'll confirm back on the next change of show.

Interesting. I don't have any fire tv devices. I using mainly Nvidia shields and so all that is required for each channels is the address that corresponds to what you see in the web browser.

It seems unlikely it has anything to do with specific hardware or Android OS version, as once the previous movie ended and I stopped streaming, I couldn't use that link again in my computer's browser either.

@turtletank @boukmandutty Unfortunately, the mPlaybackDeepLinkUri isn't persistent either. A soon as you stop the stream, and try to "tune" again it gives an error message. So it looks like we'll need to stick with a keyevent approach for Sling TV.

What I've put together appears to work reasonably well, though of course, slower than using deep links. Thanks to you both for the assistance.

@turtletank @boukmandutty After walking away from the keyboard for a few minutes, I think I have it. It's a bit of a mash-up, but the ID we were after is embedded in the link that shows up when you click on a given channel icon in the (browser) guide:

So the link looks like this for "Showtime Showcase" when not playing anything:

https://watch.sling.com/dashboard/grid_guide/grid_guide_favorites/1/channel/b24b20f009e94eb1ad2441a19f98b7ff/browse

And for that channel the correct deep link would be:

https://watch.sling.com/1/channel/b24b20f009e94eb1ad2441a19f98b7ff/watch

All testing I've done so far has confirmed that this structure works. :slight_smile:

1 Like

Nice find!

So....I installed ADB on my windows PC.

I'm trying to send voice commands to play channels from a specific app.
The end goal is to get this to work with the TDS TV+ (tivo) app.
I have been able to send voice commands with adb, but this is either not possible, or I just don't have the syntax figured out.
I have tried with Hulu, Fubo and TDS TV+.
I usually get a response of not being able to find what I'm looking for.
I guess this works with YTTV, but I don't currently have that, and its not my goal anyway.

Any pointers appreciated.

Could you post a couple of examples of commands you're trying to send? And, maybe a screenshot of what the TDS TV+ app interface looks like?

And to give you and idea of what it might look like to tune to a channel using keyevents (remote control emulation) -- here's a snippet from my bmitune.sh script. There's more to it, but this is the tuning core:

#Tuning is based on channel name values from directv.m3u.
tuneChannel() {
  channelName=$(awk -F, '/channel-id='"$channelID"'/ {print $2}' m3u/directv.m3u)
  channelName=$(echo $channelName | sed 's/^/"/;s/$/"/')
  
  directvMenu="input keyevent KEYCODE_MENU; \
        input keyevent KEYCODE_MENU; \
        input keyevent KEYCODE_MENU; \
        input keyevent KEYCODE_MENU"

  directvSearch="input keyevent KEYCODE_DPAD_RIGHT; \
        input keyevent KEYCODE_DPAD_RIGHT; \
        input keyevent KEYCODE_DPAD_RIGHT; \
        input keyevent KEYCODE_DPAD_RIGHT;
        input keyevent KEYCODE_DPAD_DOWN; sleep 3; \
        input keyevent KEYCODE_DPAD_CENTER; sleep 3"

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

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

In plain language, I'm turning the channel number into a text string that I know matches only one channel. Then I'm invoking the DTV menu, navigating to the search box, and entering that text string. Easy concept, but takes a bit of work to make it reliable -- which is what a lot of the rest of this script, and a couple of others are about.

Just pushed an update to bnhf/ah4c:test and bnhf/ah4c:latest -- they're both the same now and include the websocket version of scrcpy. My scripts for Sling TV are included, along with a sling.m3u which only has movie channels in it atm.

The scripts leave the Sling app running, which makes for super-fast tuning, but I've seen the occasional black screen this way. You can comment/uncomment the following in stopbmitune.sh to force close the app on exit, which is gives slightly slower, but more reliable tuning:

#Stop stream
adbStop() {
  stop="input keyevent KEYCODE_BACK; \
        input keyevent KEYCODE_BACK; \
        input keyevent KEYCODE_HOME"
  #stop="am force-stop $packageName"
  $adbTarget shell $stop; sleep 2
  echo "Streaming stopped for $streamerIP"
}

This ah4c (super-charged version of androidhdmi-for-channnels) container can be run standalone, as one of two ah4c containers, or in addition to ADBTuner -- so lots of options.

Attempting to setup this today with uraycoder, FireTV MAX and directv. docker for windows desktop
and it all looks setup ok,picture looks good through the encoder and VLC. I can even see and use the h264 converter and change settings by clicking. however when i try to play in channels it restarts the connection.
error message : 2023/08/20 17:29:51.751564 [ERR] Could not start stream for M3U-FiretvDTV ch13543 USA Network HD: M3U: Get "http://192.168.1.195:7654:7654/play/tuner/242": dial tcp: lookup 192.168.1.195:7654: no such host
Any ideas?

The extra :7654 is the problem. We changed a while back to using the port together with the IP address rather than hard-coded in the M3U. Scripts and M3U files are not replaced automatically, so yours may be from before the change. The port should be together with the hostname or IP in the IPADDRESS environment variable (which it appears to be, and is why it's doubled).

The current directv.m3u 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
#EXTINF:-1 channel-id="501" tvc-guide-stationid="19548",HBO HD East
http://{{ .IPADDRESS }}/play/tuner/501
#EXTINF:-1 channel-id="502" tvc-guide-stationid="59368",HBO2 HD East
http://{{ .IPADDRESS }}/play/tuner/502
#EXTINF:-1 channel-id="503" tvc-guide-stationid="59363",HBO Signature HD East
http://{{ .IPADDRESS }}/play/tuner/503
#EXTINF:-1 channel-id="504" tvc-guide-stationid="19566",HBO West HD
http://{{ .IPADDRESS }}/play/tuner/504
#EXTINF:-1 channel-id="505" tvc-guide-stationid="59355",HBO2 West HD
http://{{ .IPADDRESS }}/play/tuner/505
#EXTINF:-1 channel-id="506" tvc-guide-stationid="59839",HBO Comedy HD
http://{{ .IPADDRESS }}/play/tuner/506
#EXTINF:-1 channel-id="507" tvc-guide-stationid="59357",HBO Family East HD
http://{{ .IPADDRESS }}/play/tuner/507
#EXTINF:-1 channel-id="509" tvc-guide-stationid="59845",HBO Zone HD
http://{{ .IPADDRESS }}/play/tuner/509
#EXTINF:-1 channel-id="618" tvc-guide-stationid="59305",FOX Sports 2 HD
http://{{ .IPADDRESS }}/play/tuner/618
#EXTINF:-1 channel-id="exit" tvg-logo="http://{{ .IPADDRESS }}/static/logos/exit.png",Exit DirecTV
http://{{ .IPADDRESS }}/play/tuner/exit
#EXTINF:-1 channel-id="reboot" tvg-logo="http://{{ .IPADDRESS }}/static/logos/reboot.png",Reboot FireTV
http://{{ .IPADDRESS }}/play/tuner/reboot

You could hand edit the file to remove the hard-coded :7654, or delete the m3u file (and the firetv/directv scripts for that matter to get the latest), which is probably a better option. You can rename your scripts and current m3u if you've modified them and want to integrate your previous work into the new files.

Once you've deleted the files, go into Portainer-Stacks and update (use the slider to get the latest image too). Check the Portainer logs for the container, and you should see the latest scripts and m3u file copied over to your data directory.

I tried the shortcut method by editing the M3U and got a step closer but no go.
Of course scorched earth was neccessary to get it working correctly. Up and running ok!
Thank you for your quick response.

May get lost in this massive thread.

But for anyone with 1 tuner and struggling with stream limits on quick channel changes or want to hold the first stream on if another client connects - might have the solution for you.

If you run your M3U file through xteve and set the following settings - xteve will mange the stream limit, instead of channels (which aims to change channels as quick as possible)

xteve settings:

Playlist m3u settings - 1 tuner

Stream buffer - Xteve

Buffer size - 0.5mb (not sure if this matters)

Timeout for new connection - 600+ (I set it at 1000ms just incase since I can barely tell the difference)

Channels settings:

Load xteve m3u into a Custom Channel

Set stream limit to have no limit.

Done very brief testing on this and seems to work how I am wanting. Will edit this post if I run into any issues.

3 Likes

Just added support for SiliconDust HDHomeRun thanks to @Edwin_Perez's kind donation. You will see a new m3u file which works with the firetv/hulu set of scripts. Note that firetv/hulu also supports youtube links as well.

With this in place we are ready for ATSC 3!

4 Likes

Would you please explain this? I’ve been using HDH for a while with Channels.

Do you have any local ATSC 3.0 channels that are restricted by DRM? Because at the very least there seems to be a use case in that context that is brewing.

Sure! Instead of Channels pulling the MPEG stream directly from HDHR a Android device runs the HDHR client and we record that via HDMI which sidesteps the silly encryption/drm game.

3 Likes

Ah! I understand. I think I’m lucky enough to not have those… Yet.