

Restart lighttpd to pick up the configuration change:Ĭreate the scripts that'll generate a single frame and stream, adjust the IP address and RTSP stream URL to suit your particular camera:įfmpeg -i "rtsp://192.168.60.13:554/user=admin&password=SECRET&channel=1&stream=0.sdp" -vframes 1 -f image2pipe -an -Įcho "Content-Type: multipart/x-mixed-replace boundary=ffmpeg"įfmpeg -i "rtsp://192.168.60.13:554/user=admin&password= SECRET&channel=1&stream=0.sdp" -c:v mjpeg -q:v 1 -f mpjpeg -an. This was done using:Ĭonfigure the cgi-bin folder, and set lighttpd to not buffer the entire file before starting to send:Īlter /etc/lighttpd/conf-available/nf:Īlias.url += ( "/cgi-bin/" => " /var/www/cgi-bin/" ) The web browser closes its connection, or the camera goes offline, theįfmpeg process does seem to reliably stop.Ī tool like ONVIF Device Manager may help figuring out the RTSP stream URL if you can't find it in the documentation for your camera (look at the bottom of the "live video" screen).Īpart from getting the paths right to suit your setup, nothing here should be too specific to Linux or a particular distribution. Have two devices viewing the stream then the CPU load is doubled.

This approach is not efficient, so if you You might be able to get systemd start ffmpeg directly, but I had trouble getting the output stream to be sent to the socket, and wasn't sure how to stop the process when the socket was closed.Īs it converts between video formats it requires a bit of CPU power on the host, though that can be tuned by configuring the resolution and framerate of the original RTSP stream, as well as resizing the output stream if required.Ī 1080p stream at 10FPS on an Intel Core i5-8259U uses about 5-10% CPUĪnd consumes 256MB of RAM.

Similar could be done using nginx + fastcgi, or in python - perhaps even an Octoprint plugin. This approach uses lighttpd and cgi-bin as the server. I'm using a cheap Chinese IP Camera that only has an RTSP stream to monitor my 3D printer via Octoprint/Octoapp, which requires a MJPEG stream over HTTP.
