Mjpg-Streamer on Rpi0

  • DietPi version
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=25
    G_DIETPI_VERSION_RC=1
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’

  • Distro version = bookworm 1

  • Kernel version = Linux 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux

  • Architecture = armhf

  • SBC model = RPi Zero W (armv6l)

  • Power supply used = Raspberry Pi Brand Micro USB

  • SD card used = Panasonic 16GB

Hello all - I’m running Mjpg-Streamer successfully on an x86 device with Dietpi.
But on my RPi0 W, I seem to hit a issue. Any ideas? It looks like it might be a simple fix. Here’s the result of journalctl -u mjpg-streamer.service

Jan 04 16:24:02 ZEROCAM01 systemd[1]: Started mjpg-streamer.service - mjpg-streamer (DietPi).
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]: starting application
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG Streamer Version.: 2.0
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: ERROR: could not find input plugin
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]:        Perhaps you want to adjust the search path with:
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]: MJPG Streamer Version.: 2.0
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]: ERROR: could not find input plugin
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]:        Perhaps you want to adjust the search path with:
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 16:24:02 ZEROCAM01 mjpg_streamer[393]: MJPG-streamer [393]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 16:24:02 ZEROCAM01 systemd[1]: mjpg-streamer.service: Main process exited, code=exited, status=1/FAILURE
Jan 04 16:24:02 ZEROCAM01 systemd[1]: mjpg-streamer.service: Failed with result 'exit-code'.

I found this on mjpg-streamer github (same issue also with DietPi)
https://github.com/jacksonliam/mjpg-streamer/issues/203
Some solution was:

Apparently, all I needed to do was to install libraspberrypi-dev package. Although I had to google for it.

edit:

some more recent answers from 2022: https://community.octoprint.org/t/webcam-with-bullseye-on-raspberry-pi-4-anyone/41228/3
tldr; Since bullseye there is a new camera stack introduced and you would need to use the legacy stack, which can be enabled by setting camera_auto_detect=0 in config.txt

of course this is not a guaranteed solution to your problem.

1 Like

Hi Jappe
Thanks for the speedy reply.
Looks like libraspberrypi-dev is already installed to the latest version. I’ll take a look at your edit.

Edit:
No luck with the legacy stack. I am running bullseye dietpi on the x86 device, and that runs Mjpeg-Streamer with no issues at all.
Might it be worth running buster on the Rpi0? The only service I am running on it is Mjpeg-Streamer.

:thinking: I think running buster nowadays may be even more complicated then fixing this error.

On the github thread they also mentioned this

If you are running a cut down OS it’s possible it doesn’t have the required videocore headers and libraries included. Look for the directories
/opt/vc/lib and /opt/vc/include

You could also check for the plugin with find / -name input_raspicam.so and adjust LD_LIBRARY_PATH to this directory.

If you find nothing I would ask Micha, the current maintainer, how to fix this.

Don’t go back to Debian buster. It’s quite old Debian release and we will drop support in next release.

1 Like

Well now I’m really stumped. find / -name input_raspicam.so had no results.

Does this mean the installation script for Mjpg-Streamer on Rpi0 is broken possibly?

Edit:
Running vcgencmd get_camera shows that the Rpi0 does detect the camera:

supported=1 detected=1, libcamera interfaces=0

Additionally, running hdparm -i /dev/video0 results in:

/dev/video0:
 HDIO_GET_IDENTITY failed: Inappropriate ioctl for device

I don’t know if this helps with locating the issue.

@MichaIng any idea?

Probably the mjpg-streamer sources require an update.

We do install libraspberrypi-dev automatically on RPi when installing mjpg-streamer with dietpi-software, so it compiles with (legacy) RPi camera module support. But it might then try to use legacy libraries which do not exist anymore since Bullseye. Furthermore with the new Bookworm firmware packages, libraspberrypi-dev and all libraspberrypi libraries are generally deprecated.

We will remove legacy GPU/camera stack with next DietPi update anyway, and hence skip the libraspberrypi-dev installation. Does it compile and run well when you just remove those two lines from your /boot/dietpi/dietpi-software: DietPi/dietpi/dietpi-software at a6cddbeaa66e280b767ad82eeb0ad01d5bbaebc9 · MichaIng/DietPi · GitHub
Then G_AGP libraspberrypi-dev and dietpi-software reinstall 137?

But not sure whether RPi camera modules work then, when enabling them with modern camera stack by camera_auto_detect=1 to /boot/config.txt.

1 Like

Hi MichaIng, really appreciate your help.
I commented out the lines in the dietpi-software file, and purged + reinstalled.

After a reboot, I tried both camera_auto_detect=1 and (again rebooting) =0 in the config.txt.
Neither worked, but each output a slightly different result with journalctl -u mjpg-streamer.service:
camera_auto_detect=1

Jan 04 21:27:23 ZEROCAM01 systemd[1]: Started mjpg-streamer.service - mjpg-streamer (DietPi).
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]: starting application
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG Streamer Version.: 2.0
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: ERROR: could not find input plugin
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]:        Perhaps you want to adjust the search path with:
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]: MJPG Streamer Version.: 2.0
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]: ERROR: could not find input plugin
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]:        Perhaps you want to adjust the search path with:
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 21:27:24 ZEROCAM01 mjpg_streamer[399]: MJPG-streamer [399]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 21:27:24 ZEROCAM01 systemd[1]: mjpg-streamer.service: Main process exited, code=exited, status=1/FAILURE
Jan 04 21:27:24 ZEROCAM01 systemd[1]: mjpg-streamer.service: Failed with result 'exit-code'.

And now camera_auto_detect=0

Jan 04 21:29:34 ZEROCAM01 systemd[1]: Started mjpg-streamer.service - mjpg-streamer (DietPi).
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]: starting application
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG Streamer Version.: 2.0
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]: MJPG Streamer Version.: 2.0
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: ERROR: could not find input plugin
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]: ERROR: could not find input plugin
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]:        Perhaps you want to adjust the search path with:
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]:        Perhaps you want to adjust the search path with:
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 04 21:29:35 ZEROCAM01 mjpg_streamer[375]: MJPG-streamer [375]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Jan 04 21:29:35 ZEROCAM01 systemd[1]: mjpg-streamer.service: Main process exited, code=exited, status=1/FAILURE
Jan 04 21:29:35 ZEROCAM01 systemd[1]: mjpg-streamer.service: Failed with result 'exit-code'.

is input_raspicam.so something that should be provided by mjpeg streamer??

I believe so?

@MichaIng
Do you think this might be in any way relevant or useful?

just want to leave a note here in case anybody ends up here. Even for 32 bit it does not build input_raspicam.so because of the moving of the libraries.

The easiest way to solve this is by just modifying the CMakeLists.txt from mjpg-streamer/mjpg-streamer-experimental/plugins/input_raspicam and change all paths “opt/vc” for “usr”.

Having tried the above, I’m now stuck at this point:

pi@ZEROCAM01:~ $ ./mjpg-streamer-1.0.0/mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"
MJPG Streamer Version.: 2.0
 i: fps.............: 5
 i: resolution........: 640 x 480
 i: camera parameters..............:

Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
ERROR: could not find output plugin output_http.so
       Perhaps you want to adjust the search path with:
       # export LD_LIBRARY_PATH=/path/to/plugin/folder
       dlopen: output_http.so: cannot open shared object file: No such file or directory
pi@ZEROCAM01:~ $ export LD_LIBRARY_PATH=~/mjpg-streamer-1.0.0/plugins/input_raspicam; export LD_LIBRARY_PATH=~/mjpg-streamer-1.0.0/plugins/output_http
pi@ZEROCAM01:~ $ ./mjpg-streamer-1.0.0/mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"
MJPG Streamer Version.: 2.0
ERROR: could not find input plugin
       Perhaps you want to adjust the search path with:
       # export LD_LIBRARY_PATH=/path/to/plugin/folder
       dlopen: input_raspicam.so: cannot open shared object file: No such file or directory

Can I define the two folders? Both the input LD_LIBRARY_PATH=~/mjpg-streamer-1.0.0/plugins/input_raspicam and the output LD_LIBRARY_PATH=~/mjpg-streamer-1.0.0/plugins/output_http

I have just noticed that there isn’t an output_http.so in the respective folder.

I’m lost!

Oh! I should add - I swapped sdcards and am trying this in RaspiOS, not Dietpi.

means it is not related to DietPi or RPi OS. Probably something to report to mjpg_streamer guys

1 Like

thanks Joulinar. Maybe this can help in the future in case MichaIng decides to keep or remove mjpg-streamer from dietpi-software.

Edit:
In the end I used a uv4l_raspicam.service on RaspiOS Bullseye, and configured it to use mjpg. Success!
I don’t know if this might be an easier way to implement mjpg streams with the raspberry pi camera for future dietpi projects @MichaIng

Thanks for the help as always.

Ah sorry, I missed this line: DietPi/dietpi/dietpi-software at a6cddbeaa66e280b767ad82eeb0ad01d5bbaebc9 · MichaIng/DietPi · GitHub

Without libraspberrypi-dev, this RPi camera plugin is not compiled, hence the mjpg-streamer must of course not try to use it. In /etc/systemd/system/mjpg-streamer.service, the line should be hence changed to:

ExecStart=/opt/mjpg-streamer/mjpg_streamer -i 'input_uvc.so -d /dev/video0' -o 'output_http.so -p 8082 -n'

This is the correct module for generic cameras, like USB cams etc, but not sure whether it works with RPi camera modules when the modern camera stack is enabled. There is a large number of /dev/video* devices present in this case, and I never found the time to check what the purpose of all those is, i.e. which one to select as input, or it any of those works at all.

There is “libcamerafy” which somehow allows applications which to not know the modern RPi camera interface to use it with legacy API. This seems to work in case of motionEye, and hence might help here as well.

1 Like

Thanks MichaIng. But as I’ve already spent 4x the amount of time I wanted to on solving this - as per usual :sweat_smile: - and I have a working solution with uv4l_raspicam, I’m going to leave this until I feel like playing around again with the RPi0.

Another question, since the topic came up on GitHub as well: Where did you get uv4l_raspicam from and how did you configure it (which video device)? I guess its not this project which did not receive any commit since 9 years :smile:: GitHub - ShubhamCpp/RaspiCam-UV4L: Live Web Streaming on the Raspberry Pi using UV4L

Its name sounds like it would just access a /dev/video* device as normal UVC camera, but when the modern camera stack is enabled (default on RPi OS), then there are dozens of such devices, and I am not sure which one serves the correct camera stream.

Hi there. I followed this guide, making a few obvious changes as I went along. As I said in a previous post, I’m using a legacy 32 bit RpiOS image rather than Dietpi as the only service I need running is a webcam http server. edit: I skipped the RTSP section as I am quite happy with a basic mjpg stream, which is then accessed in HA.

1 Like

Hey MichaIng
I made the line change to the service file as you suggested, but I’m still getting errors:

journalctl -u mjpg-streamer
Mar 09 16:31:25 ZERO2CAM01 systemd[1]: Started mjpg-streamer.service - mjpg-streamer (DietPi).
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]: starting application
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]: MJPG Streamer Version.: 2.0
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG Streamer Version.: 2.0
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: ERROR: could not find input plugin
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]:        Perhaps you want to adjust the search path with:
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]: ERROR: could not find input plugin
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]:        Perhaps you want to adjust the search path with:
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Mar 09 16:31:25 ZERO2CAM01 mjpg_streamer[2544]: MJPG-streamer [2544]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Mar 09 16:31:25 ZERO2CAM01 systemd[1]: mjpg-streamer.service: Main process exited, code=exited, status=1/FAILURE
Mar 09 16:31:25 ZERO2CAM01 systemd[1]: mjpg-streamer.service: Failed with result 'exit-code'.
Mar 09 17:00:44 ZERO2CAM01 systemd[1]: Started mjpg-streamer.service - mjpg-streamer (DietPi).
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]: starting application
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG Streamer Version.: 2.0
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]: MJPG Streamer Version.: 2.0
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: ERROR: could not find input plugin
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]:        Perhaps you want to adjust the search path with:
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]: ERROR: could not find input plugin
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]:        Perhaps you want to adjust the search path with:
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder
Mar 09 17:00:44 ZERO2CAM01 mjpg_streamer[2970]: MJPG-streamer [2970]:        dlopen: input_raspicam.so: cannot open shared object file: No such file or directory
Mar 09 17:00:44 ZERO2CAM01 systemd[1]: mjpg-streamer.service: Main process exited, code=exited, status=1/FAILURE
Mar 09 17:00:44 ZERO2CAM01 systemd[1]: mjpg-streamer.service: Failed with result 'exit-code'.

Did you tell reload the service before restarting it?

systemctl daemon-reload
systemctl restart mjpg-streamer