Using VLC for cameras on OctoPrint with data overlays on video feeds

My work is still in progress, however I mashed up a first version of displaying the output of the octoprint-cli program on the video streams I have from two webcams on my AnyCubic Kobra printer. I struggled to get the webcam daemon that OctoPrint uses to display video to give consistent results. I'm far from an expert, however webcam daemon tool does not seem to be well designed to stream feeds out to the network. So I moved to VLC's command line tool cvlc and have been impressed by the results so far. VLC is a very powerful tool. I added the overlay of some of the data out of the octoprint-cli program to the two feeds. Two 640 by 480 video feeds at 15 fps keep a Raspberry Pi 3B 4 core at about 60% utilization while OctoPrint v1.8 is printing. I am using one IR cut Raspberry Pi native interface camera and one USB interfaced endoscope camera. I am running OctiPrint over a 2.4 GHz Wifi connection. I've had no printer issues so far with the video feeds running. I think some considerable utilization reduction might be accomplished by using some newer video compression methods available in VLC. I still have work to do. Below is two examples of cvlc streaming using displaying octoprint-cli data and the requisite bash scripts generating the data from the octoprint-cli print status command. I am currently running each of the four tasks in individual tmux sessions. Note, you need to install octoprint-cli, gawk, tmux and vlc on your OctoPrint machine. I posted this information at the GitHub features page of the octoprint-cli, the author of this tool had thought of doing something along this line, perhaps that will progress. The octoprint-cli is a useful tool. Getting higher resolution out of the cameras and sucking out snapshots on the host for timelapse may well require a Raspberry Pi 4 class machine and possibly a ethernet or 5.0 GHz network connection. Good hunting!

#put in tmux session
cvlc -v v4l2:///dev/video2:width=640:height=480:chroma=yuyv:fps=15 --sout '#transcode{vcodec=mp2v,acodec=none,fps=15,sfilter=marq{file=bed.txt,size=-2,color=16776960}}:rtp{mux=ts,sdp=rtsp://:8888/live.sdp}'

#put in tmux session
cvlc -v v4l2:///dev/video0:width=640:height=480:chroma=yuyv:fps=15 --sout '#transcode{vcodec=mp2v,acodec=none,fps=15,sfilter=marq{file=endo.txt,size=-2,color=16776960}}:rtp{mux=ts,sdp=rtsp://:8889/live.sdp}'

# put in tmux session
watch -n 5 "octoprint-cli print status | gawk -F':' '/Extruder Temp: /{print strftime(\"%H:%M:%S \"), \$0; exit}' > endo.txt"

# put in tmux session
watch -n 5 "octoprint-cli print status | gawk -F':' '/Progress: /{print strftime(\"%H:%M:%S \"), \$0; exit}' > bed.txt"

# on your target machine run VLC or other video program that can display rtsp: network video feeds
# in VLC the values for 'File, Open Network' are :
# rtsp:// (where z is 8 or 9 in my setup)


Love it, what endoscope are you using?