Skip to content

Instantly share code, notes, and snippets.

@bakman2
Last active December 29, 2023 19:31
  • Star 30 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bakman2/521fd7333b4fad6602b9f9955c4fbc2c to your computer and use it in GitHub Desktop.
Octoprint IP Camera

How to use Octoprint with an IP camera that has an RTSP stream available

Optional: For Wyze cam only

Install Dafang Hacks on the Wyze Cam.

Once running and all is functional, continue. Set video bitrate to 1500, VBR, 30fps.

Installation

If OctoPrint is running on a Raspberry Pi (3B minimum):

ssh pi@<raspberry_ip>
sudo apt update
sudo apt install vlc

VLC will be used to transcode the rtsp stream to a http stream which OctoPrint can use as streaming URL

nano http_stream.sh

paste the following line:

cvlc -I dummy rtsp://ip_of_yourcam --sout "#transcode{vcodec=mjpg,quality=3,fps=5,acodec=none,width=1280,height=720}:standard{access=http{mime=multipart/x-mixed-replace; boundary=7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8888/videostream.cgi}" 2>/dev/null

Change the ip_of_yourcam to match the full rtsp url from your camera

CTRL+x to save

chmod +x http_stream.sh
./http_stream.sh

Now you should be able to open your browser:

http://<raspberryip>:8888/videostream.cgi

If it works, you can use this url in OctoPrint for the Stream URL

For the snapshot URL use the stills url from your camera

Change your user/pass and ip to match your setup Click advanced options and uncheck Validate SSL on snapshot URL (if applicable)

As this process is cpu intensive you will need to play around with the quality=x,fps=x (fps = frames per second) options in the cvlc command. These settings work for me, but as I wanted better quality I have this process running on a more powerful device.

@RonaldCoutinho
Copy link

RonaldCoutinho commented Feb 25, 2022

Hi, guys!

I solved my problem in a simple way, after a lot of research, I entered this post with this smart solution and very easy to execute! Before running the .BAT it is necessary to have VLC installed on your computer, then just replace your rtsp:// link inside the BAT and that's it!

:: The following line is neccessary if you need an ability to restart the streams with this batch file
:: Kill all existing streams (the command actually suspends ALL the vlc processes):
taskkill /f /im "vlc.exe"

:: Run two instances of VLC. These would transcode MP4 rtsp-stream to Motion JPEG http-stream:
start vlc -vvv -Idummy rtsp://login:password@192.168.0.2/streaming/channels/2/preview --sout #transcode{vcodec=MJPG,venc=ffmpeg{strict=1},fps=10,width=640,height=360}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:9911/}
start vlc -vvv -Idummy rtsp://login:password@192.168.0.3/streaming/channels/2/preview --sout #transcode{vcodec=MJPG,venc=ffmpeg{strict=1},fps=10,width=640,height=360}:standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:9912/}

:: In order to execute VLC with `vlc` as in exapmle above, you have to add corresponding value to the PATH variable.
:: Otherwise you have to use full path e.g `"C:\Program Files\VLC\vlc.exe"`.

:: Such rtsp-stream uri as rtsp://login:password@127.0.0.1/streaming/channels/2/preview is specific for Hikvision cameras.

:: Access the http-streams like that:
:: For the first camera: http://127.0.0.1:9911 
:: For the the second camera: http://127.0.0.1:9912 
:: For external access change `127.0.0.1` to the address of the server (or PC) you are running VLC on.
:: Your server's Ports you are using for streaming (9911 and 9912 from current example) must be open for external access.

by @JonesTwink/cctv-startup.bat

@bastel-123
Copy link

UPDATE: Half a year later, a solution was made. https://github.com/aler9/rtsp-simple-server is what I'm currently using, and it works great, no problems yet.

Hi,

can you please give us some hints how you integrated this with octorprint.

That you be very fine
Frank

@JDIacobbo
Copy link

UPDATE: Half a year later, a solution was made. https://github.com/aler9/rtsp-simple-server is what I'm currently using, and it works great, no problems yet.

Hi,

can you please give us some hints how you integrated this with octorprint.

That you be very fine Frank

I am also interested in how @bastel-123 was able to get this working with Octoprint.

@emaklav
Copy link

emaklav commented Oct 6, 2023

Hi! I'm start rtsp-simple-server localy on ubuntu server that connected to printer, so I have access to HTPP stream from rtsp-simple-server in my browser, but Octo didnt saw this stream ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment