How to display RTSP streams from IP Cameras in Openhab and Habpanel (Linux only)

The IpCamera binding can now create mjpeg streams for cameras which do not have this ability normally. The below is not needed if you use the binding to do it for you.

Tonight whilst playing with ffmpeg and ffserver I found the following way to use them to get working RTSP streams in Openhab and Habpanel. This only works in Linux as ffserver is not available on the other platforms although ffmpeg itself is. This can be improved to have this auto start very easily, but this method is handy so you can see the output from the programs whilst you play with the settings. I would love to hear from people with what settings they find provides the blend they are after for CPU usage, video quality and network traffic.

The following will help you get this running if you are using Linux.

Install ffmpeg by doing this:

sudo apt update
sudo apt install ffmpeg

Setup the configuration file by running:

sudo nano /etc/ffserver.conf

Add this to the file and save:

<Feed camera1.ffm>
ACL allow localhost
#uncomment if you want an IP range to be able to access the stream
#ACL allow

<Stream camera1.mjpg>
Feed camera1.ffm
Format mpjpeg
VideoFrameRate 6
VideoSize 640x360
VideoBitRate 2048
Strict -1

Now you need to open two different SSH windows for testing, if it works and you are happy with the results you can get this to autostart…

Enter this command in one SSH session. Leave it running unless you want to change the settings in the file above, in which case use Ctrl+C to stop the process.


Enter this following command into the second SSH session replacing the rtsp url with what the ipCamera binding reports for any ONVIF capable cameras:

 ffmpeg -rtsp_transport tcp -i 'rtsp://'

The above will only work for Dahua and Amcrest cameras and only if you disable authentication for ONVIF in the cameras settings. Normally you can not disable authentication with these brands but you can turn it on/off for ONVIF which in this case is handy.

Now you can display this in habpanel with a frame widget by using this url when both the above two commands are working.


thanks for the info
work for ipcamera (sv3c svb06w720p-hx)

 ffmpeg -i 'rtsp://'
1 Like

I have it working with my Hikvision cameras, when they have basic authentication allowed in the cameras settings…

To use the main stream if you lower the framerate down to 12 or less and use 1080p the arm processor can handle it. Better method is to use the substream which is outlined below so the main stream can stay in high res.

ffmpeg -rtsp_transport tcp -i 'rtsp://admin:password@'

I did some CPU load tests to compare as the settings for the main video profile effect the CPU load of the Openhab server. These were running on an Odroid C2 ARM64 based setup, any modern x86 system would have far better performance.

Test results of using a camera via different methods.

No video streamed = 8% CPU load
30fps 640*480 MJPEG created by the camera and streamed via Habpanel no ffmpeg involved = 12% Cpu load (Asks for user/pass)
6FPS 640*480 MJPEG converted with ffmpeg to 6fps 640x360 MJPEG = 17% CPU load when open in Habpanel.
6fps 1080p H264 converted with ffmpeg to 6fps 640x360 MJPEG = 24% CPU load when open in Habpanel.
12fps 1080p H264 converted with ffmpeg to 6fps 640x360 MJPEG = 33% CPU load when open in Habpanel.

So it is possible to keep the main stream for high res and to configure the substream to MJPEG format by the camera. To then use this substream as the source which saves CPU power I used this line…

Hikvision substream rtsp feed.

ffmpeg -rtsp_transport tcp -i 'rtsp://admin:password@'

I could not work out a way that worked to place the stream direct from the camera to Habpanel, my conclusion is that basic auth does not work (or has a compat/bug) in the habpanel frame widget hence why using the above method works as it (ffmpeg) strips off the authentication. By processing an incoming MJPEG stream the CPU load was minimal compared to trying it on a high res high frame rate source.

EDIT: Simply entering this into the habpanel frame widget gives the picture without any user or password prompt. It fails to work if the same URL is used with admin:pass@ in the correct place. At first I thought this was a bug with the cameras firmware but then I found this. Since I was logged on via another chrome tab the credentials were passed across and this article explains it in more detail…

Hikvision direct camera semi working link (if you save user and password in the browsers cache when asked) then you need to hit refresh a few times on my tablet before the picture finally displays. Via ffmpeg it works every time and if using the cameras MJPEG stream to start from the CPU load is minimal.


Is it possible to run ffmpeg directly on Openhabian or is it necessary to have an additional machine?

Yes it will work if you follow the instructions in this thread and you do not need another server. This method only works on Linux and openhabian is Linux.

Perfect - thanks. I will give it a try!

Ok, I tried but I think that there is some bandwidth related issue. First 1000 looks to less. I increased to 10000 and was able to saw 1 picture. After this I got an error message and increased again to 100000, but the error message is still there:

Is there some configuration I can change to make it working?

Yeah the camera, to one that comes with support.

Hikvision direct camera semi working link (if you save user and password in the browsers cache when asked) then you need to hit refresh a few times on my tablet before the picture finally displays. Via ffmpeg it works every time and if using the cameras MJPEG stream to start from the CPU load is minimal.

Any idea how to make browser to remeber credentials for good? I wonder how to do in habpanelviewer.

The Ipcamera Binding can handle that for you and works on all of platforms not just Linux.

Hi, it works :slight_smile: thanks. Much better than refreshing images that was killing my openhab.
I don’t know exactly how you did it, but please tell me

  1. If I have 6 cameras with streams set up with your binding at openhabian running on RPI3, would it take a lot of CPU/ Memory resources?
  2. Is it allowed to put (192.168.1.*) to whitelist?

Thanks for your amazing work!

1: I think it would work but I have only tried 1 camera feeding 6 habpanels and my Odroid C2 handled it with ease, but it has a true 1gb network card and 2gb ram and more cpu grunt then a PI3. A single stream from 1 camera appears to only increase the CPU load by 1% on an ARM processor, however it is more than just cpu load as the more network traffic going in and out of the network card on a raspberry Pi is at some stage going to become saturated. I am interested in hearing what people find, but for cameras that can produce a MJPEG stream and have it accessable via HTTP the binding is working well.

  1. Not currently, but that is a good idea for a future feature. Each IP needs to be entered in its own set of brackets.
1 Like

Thanks for the info.
I have this working with the EZVIZ camera (Mini O).
Live video can be viewed with Basic UI on the PC but doesn’t work on the iOS app or Safari.
It DOES work with Chrome on iOS :slight_smile: but that only works when on the same network. We could do with a major iOS OpenHab app overhaul…please…

I haven’t setup Habpanel yet to test it.

The password for the EZVIZ camera is printed on the bottom of the camera and you have to disable encryption in the EZVIZ app.

commands for pi
Start the server with


Then start the video conversion
(replace password with the camera password and xxx with your camera ip)

ffmpeg -i ‘rtsp://’

text for sitemap

Image url=“http://openhabianpi:8090/camera1.mjpg

Keep an eye on the CPU temp as I don’t have a fan and it was up to 76C

1 Like

Hi All
Got this working but it craps out early. Tried using RTSP_transport tcp or udp but the CPU is too high for 1 camera, like 20%

Seems like lots of packets are dropping which kills the stream.

Any idea why? Blue Iris works with the cameras just fine, never have an issue

See this at the start of a stream:

[rtsp @ 0x562f06b758c0] max delay reached. need to consume packet
[rtsp @ 0x562f06b758c0] RTP: missed 41 packets

So you are asking why a $$$ dedicated x86 machine works and a $35 arm that is trying to do multiple roles is not as good?

You can enable hardware acceleration for FFMPEG but you need to google how and it most likely means you need to compile ffmpeg from source. Sorry I am not support, you will need to google how.
If you used a newer x86 based device for your openhab server one which uses Intel’s QuickSync you would have less issues and far better performance. Blue Iris also benefits from this and you probably have it on your server.

A low cost and power draw system that has this would be the H2 but it has supply issues at the moment.

Since you are using a camera that will work with the IpCamera binding, why dont you use MJPEG and stream using the binding? I am finding it only increases CPU load by 1% here and is easy to setup and use. I would only look at using this FFMPEG method if the camera only supports h264 or it does not provide a http method of providing a stream.

Well, using a digest python script also works but its heavy on CPU.

Does the binding allow for the removal of the authentication? to present only a http URL for HabPanel, i assume yes?

Heavy cpu will always be the case If you are converting h264 into mjpeg unless you use hardware acceleration. Video resolution will probably jump at the same speed that cpus get faster.

Yes the binding can work for you. See here

1 Like

Lovely, I got one camera working.

Ill do some more testing! Looks good matt!

1 Like

Hi @matt1 got it all working for video! nice work on the binding. Only issue is using 9 cameras on a Xeon Quad Core Cisco UCS blade, it hits 60-90% cpu when opening the camera page hah!

Might try and tune down the quality settings

Can u please help me with ffmpeg & ffsever installation instructions. I tried various options but no luck .
I have raspberry pi 3b + with us boot for this setup and pi 3b for openhab