Hello again! Things got busy so I was not able to continue my journey until last night. I made a lot of progress and I can definitively say that the webcam is working.
I need to document my steps thoroughly and eventually re-run the process to verify that I'm not forgetting anything, but here's what I did from memory (if you're here to help me troubleshoot webcamd
feel free to skip the bulleted list):
- Install a fresh copy of the latest nightly
- Initial wave of customization
- Change password (
passwd
)
- Add WiFi password (
sudo nano /boot/octopi-wpa-supplicant.txt
)
- Change
/boot/config.txt
according to the quick start guide that came with the camera (same content as in my original post, but here for clarity and edited to reflect my situation:)
- Instructions said to change
camera_auto_detect=1
to camera_auto_detect=0
but it was already set to 0 (I suspect this was an OctoPi change).
- Underneath that, added
dtoverlay=imx219
- Reboot
- Install vim and
sudo apt update && sudo apt upgrade -y
(yeah I'm using vim for these commands but stating nano
for simplicity / newcomers who might copy-paste)
- Install
mjpeg-streamer
experimental fork from Arducam
- From
~
, mv mjpg-streamer mjpg-streamer-old
to back up the old alias
git clone https://github.com/ArduCAM/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
- Edit
input_libcamera
plugin so it always builds:
-
nano plugins/input_libcamera/CMakeLists.txt
- Delete the line that starts with
if (
- Delete the
endif()
line
- Remove leading spaces / tabs from lines in-between
- Make sure dependencies are installed:
sudo apt install cmake libjpeg9-dev gcc g++ libcamera-dev
- Install new mjpeg-streamer:
From there, I am able to run the following command and view snapshots / stream from another computer:
LD_LIBRARY_PATH=/usr/local/lib/mjpg-streamer /usr/local/bin/mjpg_streamer -i "input_libcamera.so" -o "output_http.so -l 0.0.0.0 -p 8081"
The problem is, this doesn't work with webcamd
so I'm still not able to use it for printing. webcamd
is just bash so I should maybe eventually be able to figure things out but I haven't been able to thus far. I've hacked a bit on /root/bin/webcamd
, even restoring it from the Octopi GitHub repo a couple times (so that makes my instructions less reproducible).
diff --git a/webcamd.original b/webcamd
old mode 100644
new mode 100755
index f2c6dfb..98666f8
--- a/webcamd.original
+++ b/webcamd
@@ -11,8 +11,8 @@
### computer. ###
########################################################################
-MJPGSTREAMER_HOME=/opt/mjpg-streamer
-MJPGSTREAMER_INPUT_USB="input_uvc.so"
+MJPGSTREAMER_HOME=/usr/local/bin/mjpg-streamer
+MJPGSTREAMER_INPUT_USB="input_libcamera.so"
MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"
brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "0458:6006" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0825" "046d:0994" "0ac8:3450")
@@ -155,8 +155,9 @@ function runMjpgStreamer {
fi
pushd $MJPGSTREAMER_HOME > /dev/null 2>&1
- echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input"
- LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &
+ logger -s "pushd to $MJPGSTREAMER_HOME"
+ logger -s "Running ./mjpg_streamer -o \"output_http.so -w $camera_http_webroot $camera_http_options\" -i \"$input\""
+ LD_LIBRARY_PATH=/usr/local/lib/mjpg_streamer ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &
sleep 1 &
sleep_pid=$!
wait ${sleep_pid}
I changed the lines to include logger -s
because that's how I could get things to show up in journalctl
.
This then required a change from /boot/octopi.txt
to get it to output something like what I was testing with, changing the line like camera_http_options
to:
camera_http_options="-n -l 0.0.0.0 -p 8081"
With this configuration, I get the following lines of output from journalctl -fu webcamd.service
every 2 minutes:
Aug 03 15:33:01 octopi root[15137]: pushd to /usr/local/bin/mjpg-streamer
Aug 03 15:33:01 octopi root[15138]: Running ./mjpg_streamer -o "output_http.so -w ./www-octopi -n -l 0.0.0.0 -p 8081" -i "input_libcamera.so -r 640x480 -f 10 -d /dev/video0"
With both 127.0.0.1
and 0.0.0.0
, I can't view the webcam from another computer. URLs I've tried:
<ip>:8081
-
<ip>/webcam/
(shows "The webcam server is not currently running" page)
- Tunneling with ssh like
ssh pi@<ip> -L 8080:<ip>:8081
and looking at 127.0.0.1:8080
(which definitely worked when I was running mjpg_streamer
myself from the command line)
So that's where I'm stuck at. I'm hoping there's better instructions somewhere for getting webcamd
working with mjpg_streamer
with input_libcamera
because I seem to be treading into unknown territory here.