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.
See this link for the reasons for this approach in more detail:
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 192.168.0.0 192.168.255.255 </Feed> <Stream camera1.mjpg> Feed camera1.ffm Format mpjpeg VideoFrameRate 6 VideoSize 640x360 VideoBitRate 2048 VideoIntraOnly NoAudio Strict -1 </Stream>
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://192.168.1.2:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif' http://127.0.0.1:8090/camera1.ffm
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.