RTSP cam in octoprint workaround

Hi guys, I was struggling with rtsp cam in octoprint for some time and today I've found good solution. All is done one machine where octoprint is.

Build this https://github.com/horgh/videostreamer
Then run it

/path/to/Go/bin/videostreamer -input rtsp://camIP/stream_name -fcgi=false -format

in octoprint's settings set cam url to http://octopi_ip/stream

Last step is to modify template at /home/pi/OctoPrint/venv/lib/python2.7/site-packages/octoprint/templates/tabs/control.jijnja2
at line 17 change this

<img id="webcam_image" data-bind="css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }, event: { load: onWebcamLoaded, error: onWebcamErrored }, visible: !webcamError()">

to this

<video style="width: 100%" autoplay id="webcam_image" data-bind="css: { flipH: settings.webcam_flipH(), flipV: settings.webcam_flipV() }, event: { load: onWebcamLoaded, error: onWebcamErrored }, visible: !webcamError()"></video>

If you use dashboard plugin you need to modify its template too.

1 Like

Instead of modifying the code you could use this plugin I wrote that replaces the img tag with an iframe maybe.

1 Like

That is exactly what i was looking for.
Just got a cheap cam and found out it only supports rtsp and no http streams. Spend quite some time :smiley:
As soon as my print finishes i will try this out.
Really looking forward to this, thanks.

You may want to look over at this post. It is re-encoding rtsp stream into mjpg to work with OctoPrint by default.

1 Like

I'm really struggeling right now.
Installed everything and it should work.
Which ip should i use? I tried the loopback ip and the ip of my pi.
The rtsp link is correct, i tried it before several times.

I don't know where the problem ist.
The output is always the same:
"Waiting for clients..."
"Starting to serve requests on 0.0.0.0:8080 (Fast CGI)."

I hope you have some suggestions. Thanks!