:::: MENU ::::

Introducing Llama Cam Powered by Ubiquiti and Azure

TL;DR; I used a couple of Unifi cameras, farm WiFi and the Azure cloud to share the joy of llamas with the world.

An Idea is Forming

“Hmmm, how can I share the fruits of my networking escapades with the world? Or, if not the world, at least a couple of people.”

That was the thought I had one evening while probably building a Lego model 🤷‍♂️. In the past 4-5 months I have upgraded my farm WiFi to the best I can make it. Why? Read about that here. In any case, I wanted to find a way to share some of the fun and excitement I get from all this equipment and figuring out how it works. Considering at the time of writing that the world is being turned upside down with the COVID-19 pandemic, I wanted to make something that could bring a smile, a bit of warmth, a bit of happiness.

The idea of Llama Cam was born. I have about 25 llamas on my farm (I say “about” as they keep spawning), and I often share them on video calls, web shows, social media and many other ways. People always like llamas, and why wouldn’t you! What if I could use my new Unifi cameras to stream live footage of llamas?

In fact, a single tweet confirmed my brilliant idea.

Here was my plan, as I saw it in broad strokes.

It wasn’t that straight forward though. Let me go through each of the parts, one at the time.

Capturing Llamas in HD

If step one is getting a camera pointed at some llamas, then step zero is getting the infrastructure set up to support that camera. First of all, here is the geography of the challenge.

As you might infer from the map, the location for the cameras is not next to any other current network infrastructure, so I needed to somehow get an Internet connection there. Again, Ubiquiti to the rescue. When I set up the gate camera with solar power, I used the NanoStation AC to get a “wireless LAN” connection there. Long range WiFi that gives about 400 Mbit in speed and is super stable. I went for the same setup again. I daisy chained an existing Mesh Access Point to a NanoStation AC, which then fired all the bits up the hill to the pump shed.

Luckily this time I did have power in the location (pump shed), so I didn’t have to go all green with solar. However, I needed to get the signal from the NanoStation to the cameras and I also needed to power the cameras. The solution was a Flex Switch, which is an outdoor rated 5 Gigabit Power-over-Ethernet (PoE) port switch. What did catch me out was the lack of a power source in the box. The Flex Switch is powered over PoE, which means you are expected to connect it as an extension of a powered switch. I don’t have that in my pump shed. I did manage to get the right PoE adapter (and I also learnt that there are many different types of PoE adapters) from Perth, so crisis averted.

I then assigned the 5 ports as follows

  1. PoE adapter
  2. Network connection from NanoStation AC
  3. G3 Flex camera (Llama Cam 1)
  4. G3 Flex camera (Llama Cam 2)
  5. Flex HD access point

And that makes the Flex Switch look like a cheap Christmas tree. Woot!

Flex Switch

You might have noticed that I casually added a Flex HD access point. While it doesn’t have an effect on the Llama Cams, I wanted it for a future automation project of my bore pump and tank setup. More on that another time.

Producing Llama Cam

With the two cameras pointed in the general direction of some llamas and the footage being streamed on my local network and stored on the NVR which is part of the UDM-PRO, I had footage but only on the farm. The footage is exposed through the Unifi Protect interface on the UDM-PRO, as a local network RTSP feed.

Llamacam RTSP

Now I had the feed available for each of the two cameras, I had to do something with them.  I decided to use OBS (short for Open Broadcaster Software) Studio, a free streaming production software package. It is used by tons of people streaming and organising live feeds. I added both camera feeds with a VLC video source in OBS, as well as a couple of logos for the companies that made all this happen.

OBS

Oh, what does it all run on, you ask? My trusty old Lenovo Yoga 900 of course. I used it to run Plex recently, but since I upgraded to a Synology NAS, it has been available for a new project.

Streaming Through Bandwidth Hell

Up until now, it has been pretty smooth sailing… or setup at least. I have got a stable network signal to the paddock where the llamas are, I can get the camera feed exposed on the network and I can produce it all nicely in OBS. However, where do I send it? Let me lay out the constraints I have.

  1. I have 100 GB of Internet data per month. Total.
  2. I can’t/don’t want to host the stream myself. When there are 1000s of people watching llamas it would grind to a halt.
  3. I have pretty much no cash to spend on a humanitarian project like this.
  4. I don’t want to spend time managing the feed, once it is going.

I briefly considered streaming via YouTube, as I do that with OBS for Azure community Live. However, YouTube only officially support 12 hours for a live stream.  (EDIT: YT support infinite streaming, but only stores the last 12 hours). And as per point 4, I don’t want to keep setting up a new feed. I also looked at commercial streaming services, but the cost quickly became prohibitive. And then I realised that Microsoft Azure has Media Services, a collection of cloud services that index, package, protect and stream video at scale. Stream.

One of the perks of the MVP Award is the free credits that you get, and it was enough to set up a streaming service for the llamas. Yay, win! That solves points 2 and 3 from my list.

I work from home (like most people do at the moment) and the Internet connection is a life line in more than one way. I live on a farm in rural Australia, and I don’t have access to regular broadband. For more about my setup, check out the original Farm Wifi post. If I run out of data, it is a bit of a problem. I did a lot of maths around how much data I can use, how much streaming consumes, what is acceptable for a first version and much more. I ended up with some compromises, but here are the details

  • Stream for 6 hours a day, 9am – 3pm. That is when the llamas are most active as well.
  • Stream at the lowest bit rate possible. Around 200 kbit/s. I am sure everyone will be okay with non-HD llamas.
  • Let Azure do all the heavy lifting and distribution.

OBS can be configured to stream at a (nearly) constant bit rate. During testing of my setup I wasn’t aware of this, and streamed at 2500 kbit/s for nearly a day. I used up the rest of my data for the month. Crap! So, launch setup is 100 kbit/s for video and 64 kbit/s for audio (yeah, hear those llamas too!). I might increase that at a later stage. There are still a lot of settings in OBS I don’t quite understand, but here is what is running currently.

OBS Settings

That takes care of point 1 (or so I really really hope), and that only leaves the last point. I want to send the stream to the internet and then (almost) forget about it. And that is of course what I use Azure Media Services for. In particular the streaming part.

Creating a Media Service is straight forward. There are pretty much no settings to choose, apart from subscription, resource group, location and storage account. The storage account is used to store the live feed for a set period of time for the streaming service, among other things.

Azure Media Services

I only really need a single media service, as that can host multiple live streams. Once I had a media service, I’d create a live event.

New Live Stream

Choose the settings that works for you. I left them as default.

Media Service Settings

Alright, so far, so good. Azure is ready to receive the stream. When you create a live stream and start it, you will get an input URL, which is what OBS sends the stream to.

Azure Llamacam Stream

Similarly you get a streaming URL, which I can then consume on the website. That solves point 4 of my constraints. Azure is now taking care of my live feed and can stream it to the world. In terms of costs, the Azure Media Service is about USD65 per month. As I mentioned, luckily this is within the Azure credits I get as part of the Microsoft MVP program.

llamacam.com.au

Almost there! We’ve got some llamas going into some cameras, which streams to an NVR and exposes and RTSP feed, which can be consumed in OBS and produced into a single feed with sponsor logos, which is then streamed to an Azure Media Service Live Stream endpoint for the world to enjoy. Phew!

Last step is of course to make it all visible and available to you fellow llama voyeur, and that is through a good old website. I chose to create a simple WordPress website. You can judge me. A professional web developer that has mulitple MVP Awards for both development and Azure knowledge. But WordPress is super simple, can be done with a few clicks in Azure, and I just wanted to have a simple site to share the llama feed.

Not much more really to say here, other than I bought the llamacam.com.au domain, used the Azure Media Service player and came up with a countdown timer that can show when the llamas are next live, if not currently.

llamacam.com.au

 

Llamacam is born.

Future improvements

As with any project that comes from a desire to try out new tech and spread some llama goodness to the world there are a lot more ideas for the project than what version 1.0 has. In no particular order, these are some of the plans I have. Still not sure if they are possible/feasible or not.

  • And Azure AI integration to recognize when a llama is in the feed. Maybe even do a llama counter or something 🤔
  • Create an ASP.NET Core site to host llamacam.com.au that I have a lot more control over.
  • A notification service to notify you when llamas are in view. Believe it or not, llamas move around and sometimes Llamacam is llama-less.
  • Twitter account with automated llama snippets.
  • Llama request service. Deliver a llama video or something.

This project is fun, techinical, nerdy, ruralry challenged and full of llamas. What more can you want in a side project?

Watch. Share. Enjoy.