Showing posts with label Birdsy. Show all posts
Showing posts with label Birdsy. Show all posts

Wednesday, 1 January 2020

Restreamer: Live stream an IP camera the easy way

I recently added a wifi IP camera to add to my collection of home-brew wildlife monitoring kit, kindly supplied by Birdsy: https://www.birdsy.com/ .  The Birdsy camera livestreams to the 'cloud' where artificial intelligence (AI) software is used to classify the bird species.  Video clips are saved to your own secure section of the Birdsy website.

BUT I wanted to do more with the video without having to rely on an internet connection via the web site or smartphone app... so I needed access to the local video stream.  I came across a great application called 'Restreamer', which converts the rtsp stream that the camera produces into an internet browser-friendly video stream.    Restreamer is available in a simple to setup Docker image for the Raspberry Pi (or on Windows/Mac etc).  I recently wrote a how-to for Docker setup on the Raspberry Pi here.  In this case I would recommend using a version of the Pi with more oomph, eg the v3 or v4.

Restreamer user interface

Using Restreamer with the IP camera rtsp stream, I have been able to easily...

(1) Incorporate a website-friendly camera feed into my birdbox camera/weather 'dashboard' 
[  *Hint* - it's the top left camera feed  ]...


My 'Wildlife dashboard' incorporates Birdsy video stream via Restreamer, not the rtsp stream sent to the Birdsy servers and pulled back again via the Birdsy website (i'm not sure that's even possible) .

See this post that describes by Grafana wildlife dashboards in more detail.  By including the live, local camera video feed , I'm not reliant on pulling a live feed back off their website.  This does not interfere with normal operation of the Birdsy camera (or any other IP camera at that).  All the bird species AI goodness that Birdsy offers still requires the website login/app.    My dashboard is only available on my local network.

How does this work?... Restreamer converts the local rtsp video stream into a format that the Grafana dashboard can present in an html 'i-frame'. The output from Restreamer is for this Grafana panel is:

<iframe src="http://XXX.XXX.X.XX:9090/player.html" name="restreamer-player" width="704" height="500" scrolling="no" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen="true"></iframe>

'http://XXX.XXX.X.XX' represents the IP address of the Raspberry pi running Restreamer.  Port 9090 is configured in the docker Restreamer container used to make the birdsy IP camera feed available.  You can spin up as many Restreamer Docker containers as you want, just assign a different port for each camera - instructions on the Restreamer website.

(2) Push the livestream elsewhere... e.g. Stream live to YouTube
A few years ago I live streamed a Robin nest to YouTube using using a program called ffmpeg.  It was a fiddle to setup and involved a long and convoluted command line to run it. If you want to watch four  hours of robin chicks check out this archived link: https://youtu.be/lMOGX1dMaO8


Anyway Restreamer makes to really simple to push the local rtsp stream direct to YouTube, Twitch, Facebook, Vimeo etc (I know what at least two of these are....).  The screenshot below is my Birdsy Camera feed pushed direct to YouTube, however any rtsp camera where you can access the local feed should work equally well.


(3) Push the camera feed into alternative, locally run motion capture software
[ Video clip motion-captured locally using free CCTV  application 'Zoneminder' .  Technically this used the rtsp feed direct from  the camera, and not via Restreamer]

This gif was generated from a Zoneminder-motion captured clip.  I don't recommend Zoneminder as it's user interface is clunky and I found retrieving captured video to be non-intuitive and fiddly. I only used it as there is a Docker container available for the raspberry pi.  Other motion capture software is available, i will do a future post on economical local motion capture options (i.e. not reliant on the cloud and an 'always on' internet connection).

Look a chap in the eye...

Restreamer brief overview
See https://datarhei.github.io/restreamer/

Restreamer takes a variety of video stream sources and converts it into a web browser-friendly format.  For my IP camera it was as simple as entering the IP camera's rtsp stream and pressing Start.

Stream locally and also to external services (Youtube etc) 
It can also take video from IP cameras, USB cameras, Raspbery PI cameras

For an IP camera, the format is:  rtsp://username:password@Camera'sIPaddress:port/streamLocation
The username and password can be found in your camera's literature (be sure to change it...)
I located the IP address and rtsp stream location of my Networked IP camera using a windows program called IPCManager, this gives access to loads of behind the scenes camera configuration options.

The instructions for adding a Restreamer container to Docker can be found here:
https://datarhei.github.io/restreamer/docs/installation-linux-arm.html
I'm running it on the fastest Raspberry Pi currently available (Pi 4) with 4Gb ram - as I dont want this to be a bottleneck.  There are Docker images available to run in Windows or Linux Docker installations too.

Next job is to look at options for local motion capture, probably starting with Docker applications on my trusty Raspberry Pi

Saturday, 21 December 2019

Birdsy - Monitor wildlife and auto classify bird species

I recently added a wifi IP camera to add to my collection of home-brew wildlife monitoring kit, kindly supplied by Birdsy: https://www.birdsy.com/ .  This IP camera livestreams to the 'cloud' where artificial intelligence (AI) software is used to classify the bird species.  Video clips are saved to your own secure section of the Birdsy website...

Here is a screenshot of some recent captures off my Birdsy webpage:
A selection of captured, species classified clips as presented on the Birdsy webpage
You can that the bird AI is fairly good, it struggles with non-avian species, but given the company is called 'Birdsy' we can let that go...

As with many internet CCTV streaming applications you can review your live camera from anywhere with internet access and a web browser or via a dedicated phone app.  I can now watch my camera live at work too now...

My Birdsy camera setup
The 'value add' is its auto species classification, which is prett neat.  This is the first Goldfinch it classified, I downloaded it direct from the Birdsy website and uploaded to YouTube:


A mouse or two regularly compete with a Robin, the most frequently classified visitor.


As most people will set this up outdoors, you'll need a decent outdoors wifi connection, and access to a power socket.  I've run a 10m DC extension cable to reach the nearest plug socket (amazon link here).  I already have good wifi coverage outside for half a dozen or so other home-brew cameras.

10m 12v extension cable

The Birdsy camera is configured fairly easily via a smartphone/tablet app. You can dial up or down the resolution of the videa stream, presumably to adjust for better/poorer  wifi signals.

It *is* possible to run this with a dedicated wired ethernet connection, this would require either an additional network cable to be run, or once PoE (power over ethernet) setup with the network and power split out (power dropped to 12v) at the camera end.

Here is a screenshot of the configuration app:


IP camera vs home brew
Until recently, all my nature-watching has been with home-made setups using a Raspberry Pi as a processing unit, with either an attached webcam or raspberry pi camera module (or both).  A cursory glance around the web will find many people using IP cameras like this one from Birdsy instead... so what's the difference?

An IP camera, or 'Internet Protocol' camera is an all-in-one device that connects to a wired or wireless network and generates a video stream.  Camera configuration is usually achieved via a smartphone/tablet app or web browser interface.  The camera itself usually does not deal with video storage or motion capture (I'm oversimplifying, as some do bits of both).  They exist to provide a video 'stream' to some other application, e.g. CCTV motion capture software, and/or dedicated storage device, eg a digital video recorder/DVR.  IP cameras often have built in day/night modes, infra-red cut switching (IR cut) and often an integrated microphone.  They also tend to be expensive.

Most of my home made kit is Raspberry pi minicomputer with attached camera module (like the camera bit from your mobile phone).  All of the functionality mentioned above is possible but require fiddly configuration, the addition of extra components, e.g.illumination, IR cut, microphone and some programming (depending on your aims this may be minimal).  While more fiddly and requiring more technical insight, this approach costs a lot less to setup.

The cool thing about the Birdsy camera, isn't the camera, its the cloud-based image recognition system that categorises the bird video clips based on bird species being filmed.  Given that I get a lot of non-avian species I'm hoping that the AI algorithm will be extended to include non-avian species.  I'm sure there are research applications to auto identification of bird species.

As this is the first dedicated IP camera I've had to play with I plan on investigating other creative things than can be done with the video stream, so more at a later date..