OpenWrt Forum Archive

Topic: UVC webcam not working... (yuv video or ehci driver problem)

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Dear community,

I just bought a UVC-compatible webcam as I thought it will work without any problem on OpenWrt with uvc_streamer...
But... but... it doesn't work...

The problem is as follows:

root@OpenWrt:/tmp# uvc_streamer 
Using V4L2 device: /dev/video0
Resolution.......: 640 x 480
frames per second: 5
TCP port.........: 8080
Unable to set format: 22.
 Init v4L2 failed !! exit fatal 
init_VideoIn failed

Not really good...

I also tried to take a picture with spcacat, and it doesn't work neither:

root@OpenWrt:/tmp# spcacat 
 Spcaview version: 1.1.8 date: 25:12:2007 (C) mxhaard@magic.fr 
video /dev/video0 
Camera found: CMS-V28SET 
VIDIOCGPICT brightnes=32125 hue=32768 color=63897 contrast=13107 whiteness=43690depth=16 palette=8
Hmm did not support Video_channel
StreamId: 8  Camera
try palette 21 depth 8
Couldnt set palette first try 21 
Damned second try fail 
try palette 15 depth 12
Couldnt set palette first try 15 
Damned second try fail 
try palette 4 depth 24
Couldnt set palette first try 4 
Damned second try fail 
try palette 3 depth 16
Couldnt set palette first try 3 
Damned second try fail 
try palette 5 depth 32
Couldnt set palette first try 5 
Damned second try fail 
probe size in 
Available Resolutions width 640  heigth 480 
Available Resolutions width 384  heigth 288 
Available Resolutions width 352  heigth 288 
Available Resolutions width 320  heigth 240 
Available Resolutions width 192  heigth 144 
Available Resolutions width 176  heigth 144 
Available Resolutions width 160  heigth 120 
Invalid palette in check palette fatal !! 
 Format asked 15 check -1
Couldnt set videopict params with VIDIOCSPICT

I made some researches online, and found 2 hints:

1. a problem of YUV video
But cannot specify the YUV format in uvc_streamer...
I wish I could install uvccapture in OpenWrt (coz we can call 'uvccapture -f yuv'), but I didn't find this package for Kamikaze.
Any idea about YUV webcams?

2. a problem with the ehci driver (kmod-usb2)
Found in this OpenWrt ticket: https://lists.openwrt.org/pipermail/ope … 11051.html
It seems to be working if we comment the one and only line "ehci-usb" of the file "/etc/modules.d/50-usb2" provided by the package "kmod-usb2".
The problem is that, contrary to the example on this ticket, if I comment this line, nothing happen when I plug/unplug the webcam.
It doesn't mount it anymore on /dev/video0 so I cannot test it.

Any idea for my webcam problem?

(Last edited by $p00ky on 16 Jan 2010, 13:46)

ooooooook! I found a way to a solution! (even though I didn't find the solution yet...)

mjpeg_streamer seems to be working if I launch it in YUV mode.
I have to call mjpeg-streamer with the -i "input_uvc.so --yuv" parameter to open the device.

After some researches, I found that I can "stream" the webcam on http through a command like:
mjpg_streamer -i "input_uvc.so --yuv" -o "output_http.so -w /tmp/webcam"

It seems to work:

root@OpenWrt:/tmp/webcam# mjpg_streamer -i "input_uvc.so -y -d /dev/video0 -r VGA -l on" -o "output_http.so -p 1234 -w /tmp/webcam" 
MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: YUV
 i: JPEG Quality......: 80
 o: www-folder-path...: /tmp/webcam/
 o: HTTP TCP port.....: 1234
 o: username:password.: disabled
 o: commands..........: enabled

Except it doesn't do anything...
And if I connect to the server on port 1234 in my case, I do have a 404 error (from the mjpeg webserver):

404: Not Found!
Could not open file

If I stop the streamer with Ctrl-C, it stops:

^Csetting signal to stop
setting signal to stop
setting signal to stop
force cancelation of threads and cleanup ressources
 i: cleaning up ressources allocated by input thread
force cancelation of threads and cleanup ressources
 o: cleaning up ressources allocated by server thread #00
done

I tried the output_file.so plugin, but it doesn't output any file...
It's basically the same, it seems to be ok, but doesn't output anything.

root@OpenWrt:/tmp/webcam# mjpg_streamer -i "input_uvc.so --yuv" -o "output_file.so -f /tmp/webcam"
MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: YUV
 i: JPEG Quality......: 80
 o: output folder.................: /tmp/webcam
 o: delay after save..............: 0
 o: picture diff-bytes............: 0
 o: max number of pictures to hold: 0
 o: command.......................: disabled

No matter how long I wait, it does not print out anything else.
And when I press Ctrl-C, it stops the streamer on the same way as the previous copy/paste and I don't have any file in the folder.

A trigger problem?
How can I use this mjpeg_streamer?

Or how can I make uvc_streamer work as well?

Edit: Oh, thank you for your reply!
Actually, I found the files in the /webcam_www folder smile
It seems to be the default folder on OpenWrt (I found it by chance...)
There are many demos and scripts on this folder.

OK, so I made some improvements.
The output folder of the output_http.so should be the one provided by the package (in the case of OpenWrt, /webcam_www).
Now I got a better result, except it's LOADING but never printing any picture.

I think this is a RAM problem as the program is not "resource friendly" at all when it deals with YUV.
I don't know why but first, the mjpeg_streamer is launched 4 times when I launch the command:

  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
 1689  1050 root     S     2936  10%   0% mjpg_streamer -i input_uvc.so -y -r 1
 1692  1690 root     S     2936  10%   0% mjpg_streamer -i input_uvc.so -y -r 1
 1691  1690 root     S     2936  10%   0% mjpg_streamer -i input_uvc.so -y -r 1
 1690  1689 root     S     2936  10%   0% mjpg_streamer -i input_uvc.so -y -r 1

And each one of them shares 10% of the RAM for 0% of the CPU.
The problem is that the RAM is already used at almost 100% even before the mjpeg_streamer starts...

I tried running the same program with the same parameters on my notebook (ubuntu 9.10) and it's working as a charm.
The first difference is that I have only one instance of the mjpeg_streamer and the other one is that it's using 20% of the CPU for almost no RAM (o.2%):

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
12375 thomas    20   0 59072 4152 3212 S   23  0.2   0:32.50 mjpg_streamer

It's working well on my notebook (except that the video is totally BLURRED but I'll try to solve this problem when I'll be at this point on the router too).

Do you also think it's a RAM problem (limit)? And do you have any suggestions to solve the problem?
It seems to be the YUV format that is too much for a router CPU... but I have no choice, my webcam is like that...


Edit: Well, actually I might be wrong... It doesn't seem to consume that much memory (this is after starting the mjpeg_streamer):

root@OpenWrt:~# free
              total         used         free       shared      buffers
  Mem:        29916        16688        13228            0            0
 Swap:            0            0            0
Total:        29916        16688        13228

OK... something even weirder...

If I download the picture from "wget", it seems to work (except it's also totally blurred):

$ wget http://192.168.1.1:1234/?action=snapshot -O image.jpg 
--2010-01-16 22:39:54--  http://192.168.1.1:1234/?action=snapshot
Connecting to 192.168.1.1:1234... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [image/jpeg]
Saving to: `image.jpg'

    [ <=>                                                                                                               ] 2,443       --.-K/s   in 0.002s  

2010-01-16 22:39:55 (1.39 MB/s) - `image.jpg' saved [2443]

I got the picture!
But it's not working if I open the link in Firefox... :s
Any idea?

Update: OK it HAD worked... and it HAD worked in the browser too, twice and twice only...
With resolution 160x120 1 fps and 176x144 5 fps.
The stream was also working.
I don't know why but it's not working anymore...
wget neither. It blocks on "Connecting to 192.168.1.1:1234... connected.
HTTP request sent, awaiting response... "

(Last edited by $p00ky on 16 Jan 2010, 14:57)

Well, finally it seems to work with resolutions egal or less than 352x288.
I guess the cpu/memory of my router (LaFonera2.0g) does not allow me to manipulate bigger resolutions (I need a good ping and no video delay).
176x144 seems to be the best as it has no delay even through the internet (a good enough connection).

The magic command in my case is as follows (I put it in a startup script):

root@OpenWrt:/etc/init.d# cat webcam  
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org 

START=90
start() {
    mjpg_streamer -i "input_uvc.so -y -d /dev/video0 -r 352x288 --fps 5 -q 80" -o "output_http.so -p 1234 -w /webcam_www" &
}

stop() {
    killall mjpg_streamer
}

Hope it may help some other people.
If anybody has another solution, I'm listening! (especially to get higher resolutions)

The discussion might have continued from here.