init_VideoIn failed and MJPG-streamer

I'm running version:
OpenWrt 22.03.2 r19803-9a599fee93 / LuCI openwrt-22.03 branch git-22.288.45147-96ec0cd

I'm trying to get a webcam working and I've installed all the necessary packages, including MJPG-streamer.

However, when I run:

mjpg_streamer -i "input_uvc.so -d /dev/video0 --fps 30 --led auto" -o "output_http.so -p 8080"

I get:

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: (null)
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 30
 i: Format............: JPEG
 i: TV-Norm...........: DEFAULT
 i: init_VideoIn failed

That last line:

 i: init_VideoIn failed

Seems to be the issue that I haven't been able to solve in 4 hours now.

Also, what does it mean below the image here, "Stream unavailable"

Relatedly, is it possible to 'see' the driver a camera is using or trying to use? If yes, can someone please tell me how?

If you run exactly this command

then it can't work: You opened a quote and never closed it.

2 Likes

@andyboeh thanks. i've made the correction to the command.

...and it's working now?

Does /dev/video0 exist? It should be created by the kernel camera driver when the camera is plugged in.

@andyboeh no. and thanks for asking.

@mk24 thanks. yes, it does exist, along with 1 and 2. tried one, but much the same.
i'm not giving up, working on it and will report on latest soon. it's a cool feature to have a webcam on a router, as both use so little energy. it's a fun holiday project! join me, let's have fun!

Some progress. With the corrected command, we now get:

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 30
 i: Format............: JPEG
 i: TV-Norm...........: DEFAULT
Unable to set format: 1196444237 res: 640x480
Init v4L2 failed !! exit fatal
 i: init_VideoIn failed

However, I can see a stream of video on the url/broswer. i installed a some gspca drivers ( kmod-video-gspca-core), and wonder whether those now conflict with v4L2, and thus the 'fatal' error. Any ideas?

I would interpret this as follows: mjpeg_streamer tried to capture with 640x480 resolution and your camera doesn't support this. Try to set a different resolution or play around with different video formats. You can get a list of supported formats by running either of:

v4l2-ctl --list-formats

or

v4l2-ctl --list-formats-ext

If you don't have this tool on OpenWrt, you can run it on your desktop.

The gspca-driver is also a v4l2 driver, for cameras not supported by the uvc driver (usually, older cameras).

thanks a lot. on both, I got:

-ash: v4l2-ctl: not found

in uvc input, i changed the resolution to 600x800, restarted and issued:

mjpg_streamer -i "input_uvc.so -d /dev/video0 --fps 30 --led auto" -o "output_http.so -p 8080"

but the result is the same, but interestingly, the resolution change does not seem to have been done:

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 30
 i: Format............: JPEG
 i: TV-Norm...........: DEFAULT
Unable to set format: 1196444237 res: 640x480
Init v4L2 failed !! exit fatal
 i: init_VideoIn failed

here we can see it was changed in the mjpg file:

config mjpg-streamer 'core'
        option enabled '1'
        option input 'uvc'
        option output 'http'
        option quality '80'
        option fps '5'
        option led 'auto'
        option www '/www/webcam'
        option port '8080'
        option enable_auth '0'
        option device '/dev/video0'
        option resolution '800x600'

The changes you make to uci config files are not taken into account if you run mjpg_streamer manually. The whole config is only used if you run it as a service. For testing purposes, you need to pass the required options to mjpg_streamer.

1 Like

Yes what @andyboeh said, for the UCI file to have any effect, you need to launch mjpgstreamer as a service using the init.d file.

v4l2-ctl is probably found in the optional package v4l2tools. (or maybe v4l-utils).

If you have a recent webcam supporting in-camera H26x compression, v4l2rtspserver may be of use. mjpg is an old format that is not bandwidth efficient.

@andyboeh can you please show/tell me how to do this? please!

@mk24 great idea! anyone here with make and model of such cameras? can you please say? thanks a lot. what a great idea!

Just add some parameters in your -i strings

mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 --fps 30 --led auto" -o "output_http.so -p 8080"

Perhaps you can get more available parameters in every -i or -o plugin by this command: (using inpt_uvc.so as example)

./mjpg_streamer -i "input_uvc.so --help"

Hope this reply useful