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: .  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:

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

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:
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

No comments:

Post a Comment