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

This is what i get

BOOM. Just like that, its working. Just have to make sure the apps have their defaults set up in advance :smiley:

WAYYY better than TVE or CC4C and more reliable too. The channel plays within seconds really

Heres the m3u. Just like the CC4C one. Should be golden for those with the 200 bucks for 4 months deal

#EXTM3U

#EXTINF:-1 channel-id="NBC Local" tvg-chno="6" tvc-guide-stationid="10991",NBC Local (WTVJ)
http://{{ .IPADDRESS }}/play/tuner/4db1d24ace55499893fc611683c2a88f

#EXTINF:-1 channel-id="LOCNOW" tvg-chno="100" tvc-guide-stationid="1410", LOCALNOW
http://{{ .IPADDRESS }}/play/tuner/37fd997d86ff4fdd869184648f7780c7

#EXTINF:-1 channel-id="USA (East)" tvg-chno="105" tvc-guide-stationid="58452",USA (East)
http://{{ .IPADDRESS }}/play/tuner/35b320ac77ce4a2fbaf685e401933dc1

#EXTINF:-1 channel-id="CC" tvg-chno="107" tvc-guide-stationid="62420", Comedy Central
http://{{ .IPADDRESS }}/play/tuner/7a0ff80be0c14f4da6b6cc510b9be57b

#EXTINF:-1 channel-id="lifetime" tvg-chno="108" tvc-guide-stationid="60150", LIFEHD
http://{{ .IPADDRESS }}/play/tuner/5f079b9fa8c3430fa692deb662d82d8e

#EXTINF:-1 channel-id="FOOD" tvg-chno="110" tvc-guide-stationid="50747",Food Network
http://{{ .IPADDRESS }}/play/tuner/4c8d7953714d4fa88a4d541d07fd031b

#EXTINF:-1 channel-id="HGTV" tvg-chno="112" tvc-guide-stationid="49788", HGTV
http://{{ .IPADDRESS }}/play/tuner/c763c4c3001f4a04970bca35000c0ded

#EXTINF:-1 channel-id="E! (East)" tvg-chno="114" tvc-guide-stationid="61812",E! (East)
http://{{ .IPADDRESS }}/play/tuner/eb6e6c19dbaa498cbe5acfc45d3f0ea7

#EXTINF:-1 channel-id="ae" tvg-chno="118" tvc-guide-stationid="51529", AETVHD
http://{{ .IPADDRESS }}/play/tuner/8ac3a961c5b0d48ebdd6c90b52cfec46

#EXTINF:-1 channel-id="HISTORY" tvg-chno="120" tvc-guide-stationid="57708", HISTORY
http://{{ .IPADDRESS }}/play/tuner/a0b2c49be7814fa4bf1e381b7f12ce55

#EXTINF:-1 channel-id="VICE" tvg-chno="121" tvc-guide-stationid="65732", VICE
http://{{ .IPADDRESS }}/play/tuner/7c17236f677446ec967b12002e713939

#EXTINF:-1 channel-id="SyFy (East)" tvg-chno="122" tvc-guide-stationid="58623",SyFy (East)
http://{{ .IPADDRESS }}/play/tuner/385c71f4210f457eb393041e36ed50b2

#EXTINF:-1 channel-id="BET" tvg-chno="124" tvc-guide-stationid="63236", BET
http://{{ .IPADDRESS }}/play/tuner/6197aeac25ae4d0f92b06b411fc021a6

#EXTINF:-1 channel-id="Bravo (East)" tvg-chno="129" tvc-guide-stationid="58625",Bravo (East)
http://{{ .IPADDRESS }}/play/tuner/76fef014faccdafbbca947aca264d9bf

#EXTINF:-1 channel-id="AMC" tvg-chno="131" tvc-guide-stationid="59337",AMC
http://{{ .IPADDRESS }}/play/tuner/21d18937ced74ecfbba333476d6f4270

#EXTINF:-1 channel-id="IFC" tvg-chno="133" tvc-guide-stationid="59444", IFC
http://{{ .IPADDRESS }}/play/tuner/0d9871a58b0e452eab0faf29ef28bc99

#EXTINF:-1 channel-id="BBCA" tvg-chno="135" tvc-guide-stationid="64492",BBC America
http://{{ .IPADDRESS }}/play/tuner/2a915617329d4e87b5a83b68c39b9229

#EXTINF:-1 channel-id="fx" tvg-chno="136" tvc-guide-stationid="58574", FXHD
http://{{ .IPADDRESS }}/play/tuner/2f5c3abe53004a3db6b236739c12a955

#EXTINF:-1 channel-id="TNT" tvg-chno="138" tvc-guide-stationid="42642", TNT
http://{{ .IPADDRESS }}/play/tuner/d74f03db90624c769e0c6d4c9745660d

#EXTINF:-1 channel-id="TBS" tvg-chno="139" tvc-guide-stationid="58515", TBS
http://{{ .IPADDRESS }}/play/tuner/f2763f605b2d4282a16d21f539512f76

#EXTINF:-1 channel-id="espn" tvg-chno="140" tvc-guide-stationid="32645", ESPNHD
http://{{ .IPADDRESS }}/play/tuner/ca0cad8dbb4a4e68962810d8a6aa8b6a

#EXTINF:-1 channel-id="espnu" tvg-chno="141" tvc-guide-stationid="60696", ESPNUHD
http://{{ .IPADDRESS }}/play/tuner/b716a5f8c9d34028973c560dda470329

#EXTINF:-1 channel-id="espnews" tvg-chno="142" tvc-guide-stationid="59976", ESPNWHD
http://{{ .IPADDRESS }}/play/tuner/5664957697054ba0a3937a1af221bd1a

#EXTINF:-1 channel-id="espntwo" tvg-chno="143" tvc-guide-stationid="45507", ESPN2HD
http://{{ .IPADDRESS }}/play/tuner/2ad976f9aa4b4796a52ae3d64b50db9c

#EXTINF:-1 channel-id="fs2" tvg-chno="149" tvc-guide-stationid="59305", FS2HD
http://{{ .IPADDRESS }}/play/tuner/2173abf2ce324fe6837c8ab10c4a22cd

#EXTINF:-1 channel-id="fs1" tvg-chno="150" tvc-guide-stationid="82547", FS1HD
http://{{ .IPADDRESS }}/play/tuner/0c6964d26bcd450cb7d8c8af10b9da20

#EXTINF:-1 channel-id="mlbn" tvg-chno="152" tvc-guide-stationid="62081", MLBHD
http://{{ .IPADDRESS }}/play/tuner/8dc2e07d8d954628a0a80231d18f8667

#EXTINF:-1 channel-id="mlbsz" tvg-chno="153" tvc-guide-stationid="55659", MLBSZ1
http://{{ .IPADDRESS }}/play/tuner/22ecb96246a64361a9d5ab879eae6ec9

#EXTINF:-1 channel-id="nfln" tvg-chno="154" tvc-guide-stationid="45399", NFLHD
http://{{ .IPADDRESS }}/play/tuner/2f5c3abe53004a3db6b236739c12a955

#EXTINF:-1 channel-id="nflrz" tvg-chno="155" tvc-guide-stationid="65025", NFLNRZD
http://{{ .IPADDRESS }}/play/tuner/7bd920fabfd242018e3e5ea5469b1e88

#EXTINF:-1 channel-id="nbatv" tvg-chno="156" tvc-guide-stationid="45526", NBATV
http://{{ .IPADDRESS }}/play/tuner/261371704fd24f8fb9f29e483ba45062

#EXTINF:-1 channel-id="nhln" tvg-chno="157" tvc-guide-stationid="58690", NHLHD
http://{{ .IPADDRESS }}/play/tuner/1f4b73a273aa4e588a320bae0b0c763b

#EXTINF:-1 channel-id="FUSE" tvg-chno="164" tvc-guide-stationid="59116", FUSE
http://{{ .IPADDRESS }}/play/tuner/fba55399460f4a7b8d3d436793dc0f90

#EXTINF:-1 channel-id="AXSHD" tvg-chno="167" tvc-guide-stationid="28506", AXSHD
http://{{ .IPADDRESS }}/play/tuner/fa61fd21b701452c92fd37a70770f460

#EXTINF:-1 channel-id="NICKJR" tvg-chno="169" tvc-guide-stationid="19211", NICKJR
http://{{ .IPADDRESS }}/play/tuner/4b83fba5aba1401d9bb00f1bf9a357b4

#EXTINF:-1 channel-id="disney" tvg-chno="172" tvc-guide-stationid="59684", DISNHD
http://{{ .IPADDRESS }}/play/tuner/0e183596617d4425b9026cbf9603984b

#EXTINF:-1 channel-id="CARTOON" tvg-chno="176" tvc-guide-stationid="60048", CARTOON
http://{{ .IPADDRESS }}/play/tuner/ab508c097c5b41cbb0626dcc3fc9470a

#EXTINF:-1 channel-id="FREEFORM" tvg-chno="180" tvc-guide-stationid="10093", FREEFRM
http://{{ .IPADDRESS }}/play/tuner/e4096cf09e774670beea3fd7c5887e09

#EXTINF:-1 channel-id="DSCHD" tvg-chno="182" tvc-guide-stationid="56905", Discovery
http://{{ .IPADDRESS }}/play/tuner/73653704f85b4bde9855ef29a6d3196e

#EXTINF:-1 channel-id="TLC" tvg-chno="183" tvc-guide-stationid="57391", TLC
http://{{ .IPADDRESS }}/play/tuner/793b8cc7bdca43d9acb91432e1ccd24d

#EXTINF:-1 channel-id="ID" tvg-chno="192" tvc-guide-stationid="65342", ID
http://{{ .IPADDRESS }}/play/tuner/23d8c4d8b9cc4ed19771ab26f45e9867

#EXTINF:-1 channel-id="TRVL" tvg-chno="196" tvc-guide-stationid="59303", TRAV
http://{{ .IPADDRESS }}/play/tuner/48fed0bf95ed4756ad5515e5c59bb64b

#EXTINF:-1 channel-id="natgeo" tvg-chno="197" tvc-guide-stationid="49438", NGCHD
http://{{ .IPADDRESS }}/play/tuner/0245123bd2154a74b101db99f3e96f11

#EXTINF:-1 channel-id="CNN" tvg-chno="200" tvc-guide-stationid="58646", CNN
http://{{ .IPADDRESS }}/play/tuner/eb6c608319dc4328a9aa5bea1307cbaf

#EXTINF:-1 channel-id="HLN" tvg-chno="202" tvc-guide-stationid="64549", HLN
http://{{ .IPADDRESS }}/play/tuner/06a8cbeef6ab42f387044dfc07981901

#EXTINF:-1 channel-id="foxnews" tvg-chno="205" tvc-guide-stationid="60179", FNCHD
http://{{ .IPADDRESS }}/play/tuner/e78cd8c7cca443cba7a70c6008c0291f

#EXTINF:-1 channel-id="MSNBC" tvg-chno="209" tvc-guide-stationid="16300",MSNBC
http://{{ .IPADDRESS }}/play/tuner/b708785d33964014896ab636042af863

#EXTINF:-1 channel-id="TRUTV" tvg-chno="242" tvc-guide-stationid="64490", truTV
http://{{ .IPADDRESS }}/play/tuner/68fb55b6e7e84cccaa24f4ef48006dde

#EXTINF:-1 channel-id="motortrend" tvg-chno="246" tvc-guide-stationid="31046", MOTORTREND HD
http://{{ .IPADDRESS }}/play/tuner/c7799d13850f4d67b7437e24e72d4f8b

#EXTINF:-1 channel-id="comet" tvg-chno="289" tvc-guide-stationid="97051", COMET
http://{{ .IPADDRESS }}/play/tuner/6ee46b954518414f88b9375c2cab191b

#EXTINF:-1 channel-id="charge" tvg-chno="290" tvc-guide-stationid="102148", CHARGE
http://{{ .IPADDRESS }}/play/tuner/a0fd1a33fa5840dfb466dc85db4b132d

#EXTINF:-1 channel-id="MGM+" tvg-chno="292" tvc-guide-stationid="68409", MGM+ Drive-in
http://{{ .IPADDRESS }}/play/tuner/f0111af39c5d4ff1b3ca6c57a27efcb5

#EXTINF:-1 channel-id="get" tvg-chno="373" tvc-guide-stationid="82563", GET
http://{{ .IPADDRESS }}/play/tuner/ab5068729265472a8d34d5a650c465b0

#EXTINF:-1 channel-id="bein" tvg-chno="392" tvc-guide-stationid="76950", BEIN1HD
http://{{ .IPADDRESS }}/play/tuner/9125fbd1c6cd4c93b01387201878f063

#EXTINF:-1 channel-id="tennis" tvg-chno="400" tvc-guide-stationid="60316", TENISHD
http://{{ .IPADDRESS }}/play/tuner/3d94848a5be145d98cd07107a0f33aed

#EXTINF:-1 channel-id="golf" tvg-chno="401" tvc-guide-stationid="61854", GOLFHD
http://{{ .IPADDRESS }}/play/tuner/e7c98734f996492187bb868ce5655a0e

#EXTINF:-1 channel-id="acc" tvg-chno="402" tvc-guide-stationid="111871", ACC
http://{{ .IPADDRESS }}/play/tuner/d3d1428e9fea47eab11a4f35f0bda64e

#EXTINF:-1 channel-id="secn" tvg-chno="404" tvc-guide-stationid="89714", SECH
http://{{ .IPADDRESS }}/play/tuner/412b4b124e7f425e9a4e2bbaddcbe168

#EXTINF:-1 channel-id="btn" tvg-chno="405" tvc-guide-stationid="58321", BIG10HD
http://{{ .IPADDRESS }}/play/tuner/0984387944df47b58a687d60babc2c43

1 Like

@slampman

I feel like you're somehow missing some of my responses to you. ah4c does not run on port 8000 it runs on port 7654. There's a utility called ws-scrcpy that runs on 8000, but ah4c itself is on 7654:

2 Likes

@slampman

I tried to read back through your issues but I may be missing some of it...

Could you repost your Portainer Stack as it is currently...
Also
What is your ip addresses for ...
Channels Server?
FireTv Streaming Stick?
Encoder?

What encoder are you using?
When you are trying to issue curl commands are you doing that from INSIDE the ah4c container?
Can you see the encoder output from VLC?

On the off chance someone is like me, and using Emby as a frontend for this project, you're going to want to point your Live TV URL directly to your deeplinks m3u file, NOT the exported m3u link from Channels. This will make tuning new channels significantly faster.

So for me, my "good" m3u URL for Emby Live TV is;

http://192.168.1.6:7654/m3u/dtvdeeplinks.m3u

Whereas the exported m3u URL from the custom channel source in Channels is;

http://192.168.1.6:8089/devices/M3U-DTV/channels.m3u

--

Feel free to use the exported EPG from channels in Emby Live TV for EPG data.

The latter would be just as fast if you add ?format=ts

1 Like

YEP. I looked at this 10 times and I didnt see it. Sorry about that :slight_smile:

I can work on doing the other apps and share (My5, Channel4, ITV) but I have a couple of other questions.
I see that prebmitune.sh has a reference to the iplayer app. How can I make that dynamic so that other apps can be used? Maybe pass the app name as a var? Or I could set an app name var in bmitune.sh within the tuneCHannel section so that it can be killed later but that may be a big of some ugly coding. I just need the app killed when the process is over as I have disabled sleep on the firestick.

adbWake() {
  packageLaunch="com.clientapp.MainActivity"
  packageName="uk.co.bbc.iplayer"

I see references to an audio check to determine if the stream has started. Is it possible to implement this in my process? This happened once and it would be nice to have it kill the app and retry (I did this manually and it worked the second time)
image

Being able to use multiple apps with a single instance of ah4c is something that's been on my mental wish list -- but that's somehow never turned into motivation to actually do it. However, I do have a plan on how to approach it, so if you're interested in helping to make it happen -- I'm in as well.

Probably the easiest way to do it is by using the same approach I'm using with DTV deeplinks, where I need to pass two arguments from the M3U to the scripts. And, I do that by including both of them after the last slash in the URL separated by a tilde (~).

So, for example your M3U could look like this:

#EXTM3U

#EXTINF:-1 channel-id="BBC1" tvc-guide-stationid="17153",BBC1 HD
http://{{ .IPADDRESS }}/play/tuner/iplayer~BBC1

And, in prebmitune.sh that value after the last slash in the URL is passed as $2, so we can parse just the first part in adbwake(). A simple name could be turned into the actual package name using a one line case statement that we could add additional packages to:

adbWake() {
  packageLaunch="com.clientapp.MainActivity"
  packageName=$(echo $2 | awk -F~ '{print $1}')
  packageName=$(case "$packageName" in "iplayer") echo "uk.co.bbc.iplayer";; esac)
  packagePID=$($adbTarget shell pidof $packageName)
  
  if [ ! -z $packagePID ]; then
    #$adbTarget shell input keyevent KEYCODE_WAKEUP
    $adbTarget shell am start -n $packageName/$packageLaunch
    echo "Confirming $packageName on $streamerIP"
    touch $streamerNoPort/adbAppRunning
  else
    #$adbTarget shell input keyevent KEYCODE_WAKEUP
    $adbTarget shell am start -n $packageName/$packageLaunch
    echo "Starting $packageName on $streamerIP"
  fi
}

main() {
  adbConnect
  adbWake
}

In stopbmitune.sh we'd use the same process as outlined above to get the package name, and then:

main() {
  bmituneDone
  adbStop
  #adbSleep
}

Comment out the adbSleep. Though I have to say I've had no problem putting my FireSticks to sleep in over a year of solid ah4c use.

In bmitune.sh, if you want to enable an active audio check after tuning, that's done in main():

main() {
  updateReferenceFiles
  matchEncoderURL
  #specialChannels
  #launchDelay
  #activeAudioCheck 42 true 0 1 # (maxDuration, preTuneAudioCheck, sleepBeforeAudioCheck, sleepAfterAudioCheck)
  tuneChannel
  #activeAudioCheck 24 false 5 1 # (maxDuration, preTuneAudioCheck, sleepBeforeAudioCheck, sleepAfterAudioCheck)
}

Just uncomment activeAudioCheck after tuneChannel, and pass the parameters you want as described in the comment. The 24 false 5 1 shown are probably a reasonable starting point.

One thing I've noticed is that the stream will hard stop at the end of a program. Like on the :30's or top of the hour. a 3 hour long episode/film will will happily play for all 3 hours no problem, but at the end of that 3 hour block, it cuts off and drops me back in the channel grid.

That definitely doesn't happen when using the CDVR server and client. Seems like it's either something with Emby, or the XML data. Two things you could test:

  • Does this happen when using the specific channel's URL, from the ah4c M3U, directly in VLC?

  • Assuming Emby has support for Live TV guide data -- what happens if Emby supplies that data, rather than using the Channels XML?

  • Does this happen when using the specific channel's URL, from the ah4c M3U, directly in VLC?

I just tested this, and no, it continued to play straight through in VLC without a problem.

  • Assuming Emby has support for Live TV guide data -- what happens if Emby supplies that data, rather than using the Channels XML?

Good question! I just flipped it from using the Channels XML to using the built-in Guide Data Source, now I need to wait until the bottom of the hour to re-test!

Is it possible to just use this with Hulu-live - just using the Hulu app on a ONN device? I tried using the Firetv files which is the only place I saw the Hulu files with no luck. After spinning it up - it was missing the common_function.sh which I just downloaded from Git. It launches, but get stuck on the profile screen - then just keeps rebooting the Hulu app. Just wondering if this possible - even with modifying the scripts...

It should be, but probably has never been tested on any other streaming stick. @KompilerDJ did all of the Hulu Live stuff, along with greatly enhancing the original ah4c Go code. Hopefully he'll see this message, and can let you know if his scripts still work with FireTV, and if they do, it might be just a question of changing package names or similar.

So I had the "something went wrong message" and I did uncomment the activeAudioCheck line. It looks like it detected the lack of audio but ended and threw and exit status 1. I'm guessing that there needs to be some more logic?

main() {
  updateReferenceFiles
  matchEncoderURL
  #specialChannels
  #launchDelay
  #activeAudioCheck 42 true 0 1 # (maxDuration, preTuneAudioCheck, sleepBeforeAudioCheck, sleepAfterAudioCheck)
  tuneChannel
  activeAudioCheck 24 false 5 1 # (maxDuration, preTuneAudioCheck, sleepBeforeAudioCheck, sleepAfterAudioCheck)
}

main

(not sure why this is highlighted green)


[EXECUTE] Stderr: '+ channelID='"17153"'
+ specialID=17153
+ streamerIP=10.100.12.22:5555
+ streamerNoPort=10.100.12.22
+ adbTarget='adb -s 10.100.12.22:5555'
+ packageName=uk.co.bbc.iplayer
+ m3uName=bbc.m3u
+ trap finish EXIT
+ main
+ updateReferenceFiles
+ mkdir -p 10.100.12.22
+ [[ -f 10.100.12.22/stream_stopped ]]
+ [[ -f 10.100.12.22/last_channel ]]
+ echo 1521
+ echo 'Current PID for this script is 1521'
+ matchEncoderURL
+ case "$streamerIP" in
+ encoderURL=http://192.168.12.16:8090/stream0
+ tuneChannel
+ case "$specialID" in
+ echo 'Tune BBC1'
+ adb -s 10.100.12.22:5555 shell am start uk.co.bbc.iplayer
      
9
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_CENTER
  
5
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_LEFT
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_DOWN
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_CENTER
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_CENTER
      
1
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_CENTER
+ activeAudioCheck 24 false 5 1
++ date +%s
+ local startTime=1726248761
+ local maxDuration=24
+ local minimumLoudness=-50
+ local sleepBeforeAudioCheck=5
+ local sleepAfterAudioCheck=1
+ local preTuneAudioCheck=false
+ true
     
5
++ ffmpeg -t 1 -i http://192.168.12.16:8090/stream0 -filter:a ebur128 -map 0:a -f null -hide_banner -
++ awk '/I:        /{print $2}'
+ checkLoudness=-70.0
++ date +%s
+ ((  1726248771 - 1726248761 > 24  ))
++ echo '-70.0 > -50'
++ bc -l
+ ((  0  ))
+ echo 'Active audio stream not yet detected -- loudness is -70.0 LUF. Continuing...'
      
1
+ true
      
5
++ ffmpeg -t 1 -i http://192.168.12.16:8090/stream0 -filter:a ebur128 -map 0:a -f null -hide_banner -
++ awk '/I:        /{print $2}'
+ checkLoudness=-70.0
++ date +%s
+ ((  1726248782 - 1726248761 > 24  ))
++ echo '-70.0 > -50'
++ bc -l
+ ((  0  ))
+ echo 'Active audio stream not yet detected -- loudness is -70.0 LUF. Continuing...'
    
1
+ true
  
5
++ ffmpeg -t 1 -i http://192.168.12.16:8090/stream0 -filter:a ebur128 -map 0:a -f null -hide_banner -
++ awk '/I:        /{print $2}'
+ checkLoudness=-70.0
++ date +%s
+ ((  1726248793 - 1726248761 > 24  ))
+ echo 'Active audio stream not detected in 24 seconds.'
+ '[' false = false ']'
+ echo 'Active audio stream not detected after tuning completed'
+ case "$specialID" in
+ echo 'Possible sports event blackout, so bumping channel down'
+ adb -s 10.100.12.22:5555 shell input keyevent KEYCODE_DPAD_RIGHT
+ echo 0
+ exit 1
+ finish
+ echo 'bmitune.sh is exiting for 10.100.12.22:5555 with exit code 1'

[EXECUTE] Finished running ./scripts/firetv/bbc/bmitune.sh in 53.813617736s
[ERR] Failed to run start script: exit status 1
[STATS] CPU usage: 9.868895723495477%
[STATS] Alloc = 3 MiB
[STATS] TotalAlloc = 46 MiB
[STATS] Sys = 20 MiB
[STATS] NumGC = 1324
[STATS] Total memory: 31941 MiB
[STATS] Memory used: 7427 MiB
[STATS] Memory used percent: 23.25177324610468%
[STATS] CPU usage: 9.604270987980568%
[STATS] Alloc = 3 MiB
[STATS] TotalAlloc = 52 MiB
[STATS] Sys = 20 MiB
[STATS] NumGC = 1339
[STATS] Total memory: 31941 MiB
[STATS] Memory used: 7407 MiB
[STATS] Memory used percent: 23.187602876525176%

Do you think the audio check needs more time, or are you looking for something specific to happen if audio isn't detected?

I think it detected it ok i just thought it was going to kill the app and then retry

No audio was detected:

How's your knowledge of Bash scripting? I think these function-based scripts are reasonably easy to follow -- if this is in your wheelhouse. If you look at the activeAudioCheck() function:

#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"
        case "$specialID" in
          "212")
            echo "Possible sports event blackout on NFL Network, so bumping channel up"
            $adbTarget shell input keyevent KEYCODE_DPAD_LEFT
            echo 0 > "$streamerNoPort/last_channel"
            exit 1
            ;; 
          "213")
            echo "Possible sports event blackout on MLB Network, so bumping channel down"
            $adbTarget shell input keyevent KEYCODE_DPAD_RIGHT
            echo 0 > "$streamerNoPort/last_channel"
            exit 1
            ;; 
          *)
            echo "Possible sports event blackout, so bumping channel down"
            $adbTarget shell input keyevent KEYCODE_DPAD_RIGHT
            echo 0 > "$streamerNoPort/last_channel"
            exit 1
            ;;
        esac
      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
}

You'll see it's currently setup to change channels up or down, based on certain channel numbers, to deal with sports blackouts -- not to kill the app and try again. That can be done of course. :slight_smile:

However, first it'd be good to know why tuning didn't complete properly in the first place. You'll probably need to watch what's happening in real time to get an idea of where/how it's failing.

@bnhf

There is a TBS2630 for sale on Marketplace for cheaper than a Link Pi ENC5-V2--any reason this thing wouldn't work for this application?

I don't see any reason why it wouldn't work. No 4K support, but there are few 4K broadcasts to capture anyway. Does it include "cards" to populate all 16 slots?

It does yes, it's fully populated.