Cats are very helpful for programming. But when we are not at home, how can we remotely watch the cat and let our friends watch it together? With Azure, this problem will be solved!

Live broadcast equipment and software


USB Camera

In terms of hardware, we only need an ordinary USB camera. It is recommended to use a camera with auto focus and resolution above 1080p. The image sensor of the camera can be IMX317 or 415. I bought a 4K camera with 415 sensor. This is generally used for monitoring.

Connect the camera to your computer and aim at the cat, but be careful not to let the cat touch the camera.

OBS Studio

I recommend using OBS Studio. This is a free, but very professional video broadcast software. Basically, you can set it up with just a few clicks of the mouse. ffmpeg can also be used as a live broadcast software.

After starting OBS, add a camera in Sources. Some cameras support manual adjustment of focus and other parameters. You can double-click the added device name to set it.

OBS does not have a live streaming address now, we will use Azure to create a live broadcast server for OBS.

Azure Global


There are professional PaaS services on Azure that can do live streaming. We'll use Azure Media Service to broadcast live events on Azure global cloud.

Go to Azure Portal, click + Create a resource, search for Media Services, and click Create.

Select your subscription and resource group, specify a Media Services account name, select or create a storage account, and then click Review + Create to complete the creation.

When the deployment is completed, click Go to resource

Enter the Live streaming menu, click + Add live event (new)

Enter the Live event name, in my case catlive. I recommended to choose a fixed URL for Static hostname prefix, such as Use live event name or custom name, so that the live broadcast address will not change. Select Yes for Start live event. Finally, click Create to complete the live channel creation.

Enter catlive

Copy Input URL

Back to OBS, paste the URL you just copied into the Server address in Settings-Stream. You need to specify a Stream Key, for example, 996.

After the configuration is complete, click Start Streaming. At this time, OBS will send the real-time frame of the camera to Azure Media Service.

At this point, you should be able to see the live broadcast preview in Azure. Then click + Create an output.

Set the output parameters according to your needs, here I leave it as default. Then start output.

Choose the default Streaming endpoint

Click Start streaming endpoint

Now, you should be able to see the live broadcast screen.

Finally, copy the Streaming URL below. This is the live link to be sent to the audience. At this point, Azure is fully configured.

The audience only needs a player that supports the RTMP protocol, such as VLC, to watch the live broadcast.

Open VLC and click Media – Open Network Stream. Paste the previously copied Streaming URL in Network to watch the live broadcast.

Azure China


Although the global version of Azure is very nice, China's network speed is a problem, especially for China Telecom's network. Due to the QoS bandwidth limit, it is almost impossible to watch live broadcasts every night, so we need a China only solution. However, although Azure China also has Media Service, individual accounts are not allowed to create Media Service. Therefore, we can only use VM to set up a live broadcast server, that's why Chinese programmers work 996, everything is so complicated when come to China. I chose Ubuntu 20.14 LTS for my VM.

Please follow Azure document to create a Linux VM.

Open TCP ports 1935 and 8080 in the firewall.

We'll use Docker to run the RTMP server. 

SSH into the VM and install Docker.

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
sudo apt install docker-ce

If you don't want to type sudo to run docker command every time, you can

sudo usermod -aG docker ${USER}
su - ${USER}
id -nG

Start the RTMP server

docker run -d -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls

The streaming URL format is:

rtmp://<Your VM domain name or IP>:1935/live/<Custom Key>

Similarly, use OBS to send the camera video to this address to start live streaming. Viewers can watch the live broadcast in players such as VLC using the same address.

Conclusion


By using Azure global cloud, we can setup a live streaming server in 10 minutes with a few mouse click on Azure Media Services. For China, we can also use Docker on Azure VM to setup RTMP server.