werthdavid / homebridge-website-to-camera

Homebridge plugin that displays a Website as virtual camera (intended for Google Maps Traffic)
MIT License
54 stars 7 forks source link
camera homebridge homebridge-plugin maps phantom phantom-js traffic webcam

homebridge-website-to-camera

Homebridge plugin for displaying a Website (intended for Google Maps-->Traffic) as Camera

NPM version PRs Welcome Downloads

If you find my work useful you can buy me a coffee, I am very thankful for your support.

Buy Me A Coffee

Installation

Make sure you have Homebridge installed.

  1. Download the latest Chromium sudo apt-get install chromium-browser
  2. Verify the Chromium installation by running chromium-browser, output should be similar to (chromium-browser:30533): Gtk-WARNING **: cannot open display
  3. Install this plugin using: sudo npm install -g homebridge-website-to-camera
  4. Update your Homebridge config.json using the sample below (append in the block 'platforms' not 'accessories')

Configuration

Update your config similar to this:

 "platforms": [
      {
         "platform": "website-camera",
         "cameras": [
            {
               "name": "Website 1",
               "url": "https://github.com",
               "chromiumPath": "/usr/bin/chromium-browser"
            }
         ]
      }
   ]

You can add multiple cameras!

Config file

Take a look at the example config.json

Fields:

Usage

In some cases, the camera is not visible in Home-App:

AppleTV / Live-Stream :tada:

In Homebridge a Camera-Accessory provides two functionalities:

In previous versions of the plugin, only the still image was supported. This is a problem for AppleTV as this device does not show the still image, instead it directly shows the live-stream. Implementing the live-stream is not that easy with Node.js (Homekit needs the Camera to connect to the client via SRTP and send the video e.g. with x264). Instead of implementing this directly this plugin implements a helper, that lets you enable live-streaming via the homebridge-camera-ffmpeg plugin.

Enable Live-Stream

:exclamation: You need to install homebridge-camera-ffmpeg as well!

 "platforms": [
      {
         "platform": "website-camera",
         "cameras": [
            {
              "name": "Website 1",
              "url": "https://github.com",
              "live": "true",
              "liveSnapshotInterval": 1000,
              "liveRefreshInterval": 5000,
              "livePort": 8554
            }
         ]
      },
      {
        "platform": "Camera-ffmpeg",
        "cameras": [
            {
                "name": "Website Camera",
                "videoConfig": {
                "source": "-i http://localhost:8554",
                "stillImageSource": "-i http://localhost:8554/still"
                }
            }
        ]
      }
 ]

:grey_exclamation: if live is enabled, the website-to-camera plugin will not expose a camera on its own! There will only be a server listening on the given port that offers a MJPEG live-stream.

Live-mode FPS

If you set liveRefreshInterval to 33, the stream will be served with about 30fps. This will consume CPU accordingly. It does work but I recommend setting it to a value >= 1000 (so one picture per second) as this plugin is not optimized for fast live videos.

Background

The plugin uses Puppeteer/Chrome headless to capture the screenshots. The Browser instance stays open all the time for better performance and less CPU/Mem consumption.