HDMI for Channels

Since this project does possibly require some equipment purchases, I just wanted to point out that it looks like Amazon has finally announced their Prime Days 2013 for July 11-12. So those of you on the cusp of trying out this project may want to keep that in mind. I know I always get some awesome deals.

Hopefully we will see a FireTV cube deal. This device is excellent.

I'd suggest we use environment variables, which would work both for people who want to deploy using the container and for those that don't. For example:

  			url:   os.Getenv("TUNER1_URL"),
			pre:   os.Getenv("STREAMER_APP") + "/prebmitune1.sh",
			start: os.Getenv("STREAMER_APP") + "/bmitune1.sh",
			stop:  os.Getenv("STREAMER_APP") + "/stopbmitune1.sh",

Where $STREAMER_APP would be the device/app part of the directory path. For example, firetv/yttv -- how does that strike you?

1 Like

I like it! Maybe create a .env file that is sourced when launching main?

This would also provide a path to cleanup my keep_alive.sh script as well.

EDIT: this looks good GitHub - joho/godotenv: A Go port of Ruby's dotenv library (Loads environment variables from .env files)

That library looks fine, but would create a potential conflict between container users and non-container users as there would be two different methods of setting env vars. In Portainer in particular, it's more convenient to have the environment variables in with the stack rather than in a separate .env file.

Since androidhdmi-for-channels has to be launched somehow by the non-container users, I'd propose the setting of env vars as part of launching the executable (in a script for example).

Maybe we should move this discussion to discord. I see Channels has a discord server with a dev-playground? Official Discord Soft Launch

@bnhf Take a look at the repo now - its using env variables and the new structure. GitHub - sullrich/androidhdmi-for-channels: androidhdmi-for-channels

Regardless of where you collaborate, I'll be eagerly following and learning quickly, happy to test anything you develop and to share notes!

I find all of this inspiring, fascinating and fun.

One extra bit that would be cool to include, if possible, is this code for YTTV subscribers, as apparently it's more reliable than potentially-dynamic URLs for each target channel.

Mine still haven't changed but as I channel surf I wonder, how long will this last? lol

1 Like

I meant to move the developer related discussion to Discord but a lot of the things we are discussing via this thread could also be talked about over there as well. Wondering if we could get a Discord channel named hdmi-channels @tmm1 ?

Nice work -- that looks great, and should lend itself well to either host-based or docker-based installations -- especially at this stage.

@tmm1 has created the channel in discord dev-hdmi-channels - hope to see some of you over there!

I posted some info about that Home Assistant script when it was originally posted. It's out of date and won't be very helpful here.

@tmm1 Can you clarify which license your code is under for hdmi-channels go and shell scripts?

EDIT: the license is MIT in case anyone is wondering.

EDIT: lots of features landed in my repo today including:
Improve script durability / reliability
Allow multiple tuners from one set of scripts
Allowing the tuner and encoder information to be dynamically set. Useful for docker containers, etc
Support for FireTV and Hulu

Please let me know if you use it or have questions!

I'd love to jump in here but the thread is a little too long for newbies. If I were to buy an HDMI IP encoder, and use it connected to an extra FireStick I have laying around, how hard is it to simply record the stream into a Channels?

I'm assuming to manually tune and play a show on the FireStick, I'd need an HDMI splitter (so I can see what I'm doing, and which I also have laying around somewhere).

I'm not sure if I'm ready to dive into all this coding, unless there was one of you interested in summarizing what you have worked out for specific types of sources (such as the FireStick) in a Wiki format or something? I'm ready to spend $$ but it's the time to futz around that I'm lacking.

Some encoders have HDMI out built in so you can do exactly that.

I use VLC on a laptop to see what is going on a bit laggy but works. I can look at all my 4 capture inputs this way.

Maybe it depends on which encoder you purchase, but with the URayCoder H.265 I bought, I can monitor what's coming into to the encoder right from the same built-in webserver that's used for configuration.

Given the experimental nature of this Channels extension and active development going on, futzing around at this stage is unavoidable. There are really two aspects of a stream capture to consider, which are what streaming device do you want to use and what app do you want to run.

Capturing the output from a streaming device like the FireTV is the easy part, controlling a particular app for live tv with reliable channel changes is where the challenge lies. What app are you hoping to use?

Alrighty then, here's the latest update to the Docker container for this project!

Support has been added to pass the streaming device's adb hostname:port or ip:port to the scripts, so you'll no longer need individual scripts for each tuner.

Also, the scripts are being organized under /opt/scripts/streamer/app, where streamer/app is the type of streaming device followed by the streaming app name. For example onn/yttv, chromecast/hulu or firetv/directv. The current sample scripts will be under sample/yttv.

There are some new and changed environment variables, so make sure you update your compose in Portainer - Stacks accordingly when you pull the new image:

version: '3.9'
services:
  androidhdmi-for-channels:
    image: bnhf/androidhdmi-for-channels:latest
    container_name: androidhdmi-for-channels
    dns_search: localdomain # Specify the name of your LAN's domain, usually local or localdomain
    ports:
      - 5037:5037 # Port used by adb-server
      - 7654:7654 # Port used by Channels androidhdmi-for-channels proxy
    environment:
#      - ADB_DEVICES=${ADB_DEVICES} # Space separated list of adb devices to control in the form hostname:port or ip:port
      - TUNERS=${TUNERS} # Number of tuners you'd like defined 1, 2, 3 or 4 supported
      - STREAMER1_HOST=${STREAMER1_HOST} # Streaming device #1 with adb port in the form hostname:port or ip:port
      - STREAMER2_HOST=${STREAMER2_HOST} # Streaming device #2 with adb port in the form hostname:port or ip:port
      - STREAMER3_HOST=${STREAMER3_HOST} # Streaming device #3 with adb port in the form hostname:port or ip:port
      - STREAMER4_HOST=${STREAMER4_HOST} # Streaming device #4 with adb port in the form hostname:port or ip:port
      - TUNER1_URL=${TUNER1_URL} # Full URL for tuner #1 in the form http://hostname/stream or http://ip/stream
      - TUNER2_URL=${TUNER2_URL} # Full URL for tuner #2 in the form http://hostname/stream or http://ip/stream
      - TUNER3_URL=${TUNER3_URL} # Full URL for tuner #3 in the form http://hostname/stream or http://ip/stream
      - TUNER4_URL=${TUNER4_URL} # Full URL for tuner #4 in the form http://hostname/stream or http://ip/stream
      - STREAMER_APP=${STREAMER_APP} # Streaming device name and streaming app you're using in the form streamer/app (use lowercase with slash between as shown)
    volumes:
      - /data/androidhdmi-for-channels:/opt/scripts # pre/stop/bmitune.sh scripts will be stored in this bound host directory under streamer/app
      - /data/adb:/root/.android # Persistent data directory for adb keys
    restart: unless-stopped

Your Portainer - Stacks should look similar to this:

You'll want to update your scripts to take advantage of "$1" in the pre/stop scripts, and "$2" in the start script. These are the STREAMERx_HOST values for each virtual tuner.

It'd be nice for those that are trying to get going with this extension to be able to start with script samples for whatever combination of streamer/app that you're using. So even if your script isn't perfect yet, by getting it bundled with the container it'll be a better starting point than the current samples.

EDIT: Added a bound directory for the adb data to make adb connections persistent across container deployments.

Can this be some how implimented using MY HDMI Encoder. My computer has a 2nd HDMI and would like to stream that output from the computer but impliment the URL's to the Browser. I I see is for androd but not by way of Windows Computer and Web Browser. I don't how to impliment the URL's to start the streams.

1 Like

Oh wow, this is very exciting. Thanks for this! I’m headed out for another trip but when I am back I will convert my setup (Chromecast+Onn, both using YTTV) to the docker. On my Mac mini that is running CDVR server I am using Docker Desktop. And on a Raspberry Pi 4+ I have Portainer, with Home Assistant and Scrypted. Would either one be better than the other for this? I’m leaning towards the Mac, but would appreciate your feedback. And thanks again for putting this together.

Good question. I guess the beauty of Docker is that it's super easy to spin-up a container on both, and see which you like better. Not sure how much horsepower is required for the ah4channels proxy, so that could factor in.