Restreamer with Raspberry PI: Self-Hosted Re-Streaming Server

5
(1)

Last Updated on 5th January 2024 by peppe8o

In this tutorial, I will show you how to use Restreamer with Raspberry PI, to be able to stream your IP cameras to web pages or external services.

What is Restreamer

Restreamer (from datarhei) makes a few things but in an excellent way. It simply gets one (or more) streaming inputs and facilitates you to publish it into a web page, social network, or open-source platforms like Icecast.

It is a self-hosted, open-source video server, free both for private and commercial use.

It can get input from quite all the IP cameras from the market, as it allows you to use the RTSP, a common protocol supported by a wide range of producers in the market. Moreover, it can take input videos also from USB cameras and Raspberry PI cameras.

On the output side, Restreamer can route your video stream to many providers by allowing the user to integrate their videos with easy-to-use widgets and a really few settings.

For this reason,

What We Need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:

Raspberry PI 4 model B image

Step-by-step Procedure

Prepare the Operating System

The first step is installing the Raspberry PI OS. Please note that for my test I’m using the 64-bit version. You have 2 options:

  1. Raspberry PI OS Lite: This is a lightweight OS for Raspberry PI computer boards, without a Desktop environment (headless). Suggested for low-power Raspberry PI computers (like the RPI Zero 2 W), but also for newer computer models to get the full computing power working for your service.
  2. Raspberry PI OS Desktop: This is a less-performing OS (compared to the lite version), but it runs well on many Raspberry PI computer boards. I suggest this only if you need a desktop environment. In this case, you will work from its internal terminal.

You can check the difference between the 2 operating systems with my Raspberry PI OS Lite vs Desktop: comparison between the 2 distributions article.

After installing the OS, please make it up-to-date. From the Raspberry PI SSH session (or terminal):

sudo apt update -y && sudo apt upgrade -y

For this guide, I’ve used the Raspberry PI OS Lite (64-bit) as Operating System.

Finally, we need to install Docker. For this task, you can refer to my Setup a Docker environment with Raspberry PI OS Lite. Please note that in that tutorial the docker-compose and Portainer installation is optional and it’s not required for Restreamer.

With Docker, you can install Restreamer on Raspberry PI with the following command (please copy the whole command lines and paste it into your terminal:

docker run -d --restart=always --name restreamer \
   -v /opt/restreamer/config:/core/config -v /opt/restreamer/data:/core/data \
   --privileged \
   -p 8080:8080 -p 8181:8181 \
   -p 1935:1935 -p 1936:1936 \
   -p 6000:6000/udp \
   datarhei/restreamer:rpi-latest

That’s all on the Raspberry PI side. The remaining steps will be performed from a remote PC (or from your Raspberry PI browser if you use the desktop release).

Access the User Interface for Restreamer with Raspberry PI

At this point, Restreamer will publish its User Interface (UI) at the URL “http://raspberry_ip_address:8080/ui” where, of course, you have to change the “raspberry_ip_address” with your Raspberry PI’s IP address. In my case, my PI has IP 192.168.1.85 and my URL will be “http://192.168.1.85:8080/ui”.

From your favourite browser in your remote PC, please connect to the web UI to reach the user registration page:

restreamer-raspberry-pi-set-admin

This will appear only the very first time you start your Restreamer container.

Please set your favourite credentials and press “REGISTER USER”. It will address you to the welcome page, where you can find the button to start Video Setup (please click it):

restreamer-raspberry-pi-start

The following page allows you to set different network sources. Many IP cameras offer access via the RSTP protocol. I will use it with my ieGeek IG62 camera as it makes it really simple to get the video stream. In this case, I will use the Network Source link highlighted in the following picture:

restreamer-raspberry-pi-video-setup-network-source

The following page will ask you to configure the network stream of your IP camera. Here can be the hardest part: you must check your camera manual for its RTSP address format and, if required, the related credentials. In many cases, you can also ask Google for it: many websites are collecting the RTPS URL format for quite all the IP cameras available in the market.

For example, in my case (ieGeek IG62), it doesn’t require credentials and the URL will be like the following: rtsp://ip_address_of_camera:554/11:

restreamer-raspberry-pi-video-rtsp-set-address

After filling in the stream address, please press “NEXT”.

Restreamer will check if the connection starts correctly and may ask you to choose the video profile from those supported by your IP camera:

restreamer-raspberry-pi-video-rtsp-set-codec

Select your favourite and press “NEXT”.

The same option for the audio input:

restreamer-raspberry-pi-video-rtsp-set-audio

Again, set your favourite and press NEXT.

On the following page, you can set additional metadata to your video stream as a description or info about the author:

restreamer-raspberry-pi-video-rtsp-set-metadata

Set it according to your preferences (you can also leave them as default) and scroll down to press NEXT again. The final page will ask you to associate a License to your video. You can choose between several Creative Commons licenses:

restreamer-raspberry-pi-video-rtsp-set-license

Finally, press SAVE. The stream will start to arrive on your page:

restreamer-raspberry-pi-streaming

In the LIVESTREAM widget, you can use the pencil icon to access and tune again the stream configuration:

restreamer-raspberry-pi-streaming-edit-button

From this menu, you can change the settings previously configured or you can even delete the stream:

restreamer-raspberry-pi-stream-delete

Set the Host Address

It is important to note that Restreamer can only get the IP address of its Docker container (an internal IP that you can’t reach from a remote PC by default). We need to change it before going to the live stream, in order to get Restreamer generating the correct URLs for our video.

Please identify and use the System settings from the menu:

restreamer-raspberry-pi-system-settings-link

Here you can adjust your external IP address by using your Raspberry PI address from the Network tab:

restreamer-raspberry-pi-system-network-address

Save it. Restreamer will restart automatically. Then you can go back to the Restreamer home.

The Restreamer Integrated Player

Restreamer comes with an integrated player to show your camera video on a web page. The player settings can be adjusted with the pencil icon in the player widget:

restreamer-player-edit-button

With this button, you can change the setting for the stream, but you can also get the URL to reach your video from a browser or even the iframe code to integrate your video into a web page:

restreamer-player-edit

For example, if you copy the player URL you can use it in your browser to reach the picture without the need to enter the Restreamer admin interface:

restreamer-player-view

Of course, without having a public static IP and without configuring your router you will not be able to reach your streaming from outside your home. And I would suggest NOT to do it directly as you can see that there isn’t any password protection to your video unless it is intended as a public broadcast.

If you want to access it from the internet, you must configure your router as a VPN server and access it via your private VPN, or you can go to the following chapter.

Streaming to External Applications

To publish your video stream with external services, you can use the “+” button in the player widget:

restreamer-player-publications

It enables you to use several service providers or software or protocols that you can use with easy for external streaming:

restreamer-player-publications-supported-methods

Adding More Cameras

At this point, we have seen all the options and features that Restreamer offers for our IP camera.

We may need to manage multiple cameras. In Restreamer for Raspberry PI we will manage the additional cameras as new channels. You can configure a new channel with the channel selector:

restreamer-channels-button

This opens the Channels area in the bottom part of the window, where you can select the camera stream to manage or you can add a new channel with the “+” button highlighted in the following picture:

restreamer-add-channel

After clicking this button, you will be asked to give a name to the new channel:

restreamer-add-channel-name

After giving a name and pressing the “ADD” button, the procedure will be the same as shown for the first camera.

On the other side, if you want to delete a Restreamer channel, you can do it by entering again to the LIVESTREAM settings (pencil icon) and using the DELETE button there.

Please note that Restreamer doesn’t offer a way to directly show multiple cameras on a single web page. For this task, you need to install a LAMP server in your Raspberry PI and use the iframe codes to build your HTML page with multiple camera streams.

Final Thoughts

Restreamer makes a huge usage of disk space, with continuous write and deletion of the stream’s temporary parts.

If you use a MicroSD, my suggestion is to mount a USB storage (you can do it with my Automount USB storage with Raspberry PI OS Lite tutorial), so that you can use the USB storage in your docker command (“-v” options) to change the folder for data and config, instead of using the “/opt/restreamer/” folder.

Finally, please note that Restreamer IS NOT a DVR and doesn’t have any motion detection or alarm system. For this job, you will have to use external services or different monitoring software like iSpy/AgentDVR or Zoneminder.

Restreamer Docs

Please find the official Restreamer Docs at https://docs.datarhei.com/restreamer/knowledge-base/manual.

What’s Next

Interested in more cool ways to use your Raspberry PI computer board? Take a look at peppe8o Raspberry PI computer tutorials!

Enjoy!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?