How to install the webcam software?

I have an SD card with Octoprint, which is working, but has an older OS on it seems like it.
So I Created a new SD card with the latest PI version, and installed Octoprint on it.
Now I want to add my webcam to it, but cannot get that to work, while it works on the old card.

I tried installing the software,but keeps failing for download.

Anyone knows how to install the stream jpg software correctly ?

Thank you

Please be specific with what you have installed, what hardware you have used. 'Latest Pi version' doesn't tell me anything about what OS you have installed where.

And also 'the software' says nothing, state it's name.

There is a guide,

But I don't know if maybe you want to install OctoPi which has this setup out-of-the box:

Please give more details, we can't help you otherwise.

I'm sorry.
I am new to everything.

  1. Downloaded the latest version here: https://www.raspberrypi.org/software/
  2. installed octoprint and compiled it
  3. installed python 3.8
  4. installing MJPG-Streamer but then i got stuck on some kind of script that i needed to put in a file, and then unable to compile. (lost the webpage for it)

May I ask why you don't use the ready to use octopi image where everything is installed and working?

i was having the impression when i went in there with VNC, that a lot of items were missing from the OS
in case i want to use it for other things.
and now I have the latest OS installed, with a nice GUI

I see.
Well @Charlie_Powell already posted the link to the guide on how to install it on raspbian.
I suggest you start the with the webcam part again and tell us when you get stuck.

We don't know which script you used before so we can't really help you with that.

ok, I followed this part

and stuck on the Optional: Webcam section

i keep getting this error

pi@raspberrypi:~ cd ~ pi@raspberrypi:~ sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake
sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting

and also this error

**pi@raspberrypi:~ $ sudo service haproxy start
sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

**

ok, changed the permission with 055 and was able to install that part

then i installed the mpeg part
and ran this after that

For Jessie use:

sudo apt install subversion libjpeg62-turbo-dev imagemagick libav-tools libv4l-dev cmake

which failed so i changed it to

sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake

that installed, and started the server.
but still, the webcam is not working.

If you downloaded the latest Raspberry Pi OS, why are you using the command that it says for Jessie? That is based on buster, so you should use the command that says it is for buster :wink:

Could you paste the output of when you ran the mjpg streamer command, the one that is like this?:

./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"

pi@raspberrypi:~ ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so" bash: ./mjpg_streamer: No such file or directory pi@raspberrypi:~ dir
Bookshelf Downloads OctoPrint RaspberryPi-Factory-Reset
Desktop mjpg-streamer Pictures Templates
Documents Music Public Videos
pi@raspberrypi:~ cd mjp-streamer bash: cd: mjp-streamer: No such file or directory pi@raspberrypi:~ cd mjpg-streamer
pi@raspberrypi:~/mjpg-streamer ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so" bash: ./mjpg_streamer: No such file or directory pi@raspberrypi:~/mjpg-streamer ./mjpg-streamer -i "./input_uvc.so" -o "./output_http.so"
bash: ./mjpg-streamer: No such file or directory
pi@raspberrypi:~/mjpg-streamer cd pi@raspberrypi:~ ./mjpg-streamer -i "./input_uvc.so" -o "./output_http.so"
bash: ./mjpg-streamer: Is a directory
pi@raspberrypi:~ $ ./mjpg-streamer -i "./input_uvc.so" -o "./output_http.so"

went deeper into the folder, seems like it's called differently

pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental $ dir
_build input_uvc.so output_file.so start.sh
cmake LICENSE output_http.so TODO
CMakeLists.txt makedeb.sh output_rtsp.so utils.c
Dockerfile Makefile output_udp.so utils.h
docker-start.sh mjpg_streamer plugins www
input_file.so mjpg_streamer.c postinstall.sh
input_http.so mjpg_streamer.h README.md

input_raspicam.so mjpg_streamer@.service scripts
pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental mjpg_streamer -i "input_uvc.so" -o "output_http.so" bash: mjpg_streamer: command not found pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental

I started with a new image and did the following

python3 --version

sudo apt update
sudo apt install python3-pip python3-dev python3-setuptools python3-venv git libyaml-dev build-essential
mkdir OctoPrint && cd OctoPrint
python3 -m venv venv
source venv/bin/activate

pip install pip --upgrade
pip install octoprint

sudo usermod -a -G tty pi
sudo usermod -a -G dialout pi

wget https://github.com/OctoPrint/OctoPrint/raw/master/scripts/octoprint.service && sudo mv octoprint.service /etc/systemd/system/octoprint.service

sudo systemctl enable octoprint.service

cd
sudo apt install haproxy

sudo -i
geany /etc/haproxy/haproxy.cfg

changed to

global
maxconn 4096
user haproxy
group haproxy
daemon
log 127.0.0.1 local0 debug

defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
option http-server-close
option forwardfor
maxconn 2000
timeout connect 5s
timeout client 15min
timeout server 15min

frontend public
bind :::80 v4v6
use_backend webcam if { path_beg /webcam/ }
default_backend octoprint

backend octoprint
reqrep ^([^\ :])\ /(.) \1\ /\2
option forwardfor
server octoprint1 127.0.0.1:5000

backend webcam
reqrep ^([^\ :])\ /webcam/(.) \1\ /\2
server webcam1 127.0.0.1:8080

sudo service haproxy start

cd ~
sudo apt install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
make

Everything went fine, except for the line below.
I cannot get this one to start.
also after reboot it does not start..

start webcam server
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so"

it gives me

bash: ./mjpg_streamer: No such file or directory

error

What am I suppose to change?

changed it to this

/home/pi/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "/home/pi/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so" -o "/home/pi/mjpg-streamer/mjpg-streamer-experimental/output_http.so"

and that seems to work..

now how can i autostart this?
since after a reboot, the streaming server is off again

thanks

found this

Start it automatically
Create the systemd service by sudo nano /etc/systemd/system/mjpg-streamer.service and add this inside the file

[Unit]
Description=mjpg streamer for octoprint webcam
After=network.target

[Service]
Restart=always

Adjust the CLI params (see Available mjpg-streamer configuration options)

Replace pi with your raspberry pi username if different

For camera plugged via USB cable (i.e. webcam)

ExecStart=/home/pi/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -o "/home/pi/mjpg-streamer/mjpg-streamer-experimental/output_http.so -p 8080 -w /home/pi/mjpg-streamer/mjpg-streamer-experimental/www" -i "/home/pi/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so -f 15"

For camera connected via the dedicated camera port using the ribbon cable

ExecStart=/home/pi/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -o "/home/pi/mjpg-streamer/mjpg-streamer-experimental/output_http.so -p 8080 -w /home/pi/mjpg-streamer/mjpg-streamer-experimental/www" -i "/home/pi/mjpg-streamer/mjpg-streamer-experimental/input_raspicam.so -fps 15"

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable mjpg-streamer
sudo systemctl start mjpg-streamer
sudo systemctl status mjpg-streamer

and it worked. except after rebooting, the stream doesn't come up, but no errors..

ok, rebooting works fine now.
Seems like the Guide needs to be updated, the version and command line is different then from what is in the guide, if you do it manually.

Need to figure out now, how to make it widescreen instead of 4:3 format.
other than that, it's working good