User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

webcam very low fps

Wed Aug 22, 2012 9:35 pm

Hi

I'm trying to run a cheap crappy web camera on RPi. The problem is that I'm getting very very low fps *only* at the lowest resolution available in Cheese. CPU is at 100%.

I'm using "wheezy" images from 15.07.2012 but I updated (apt-get update).
When the camera is plugged the uvcvideo driver is auto loaded and everything looks fine.
But then Cheese shows something only at 160x120... 640x480, 352x288 are just showing black screen and CPU is at 0% load.
And on 160x120 I have 1 frame at ~10s which is insane :)

On the other hand the same camera work very good @ 640x480 on my Ubuntu 10.04 desktop PC (again tested with Cheese).

I see people running cameras with (almost) decent fps so... what I'm missing? :evil:
thunderingnerd.blogspot.com

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: webcam very low fps

Thu Aug 23, 2012 6:55 am

Well what are you trying to do with the webcam ?
The problem is either that the webcam is total crap like one of mine, or cheese with X is chewing up too much CPU.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Thu Aug 23, 2012 7:19 am

SirLagz wrote:Well what are you trying to do with the webcam?
Run Cheese with >10fps for starters :) And then stream on the internet?
Yes, the camera is cheap but it works just fine on Ubuntu 10.

Ubuntu 10.04 - 2.6.38 kernel
RPi - 3.2 kernel
And of course RPi's uvcvideo version is greater than the one on Ubuntu.

Which leaves:
SirLagz wrote:cheese with X is chewing up too much CPU.
I guess streaming with ffmpeg will need less CPU (no X)... Should try it.
Also maybe rebuilding the kernel (tons of patches pushed to git lately...).
...and try with another camera
What else?
thunderingnerd.blogspot.com

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: webcam very low fps

Thu Aug 23, 2012 7:39 am

10 FPS with high resolution is going to be hard.
I can get 320x240 @ 10fps nicely with my crapcams.
[email protected] can work, but I think the Cams I have can't handle it very well.

Did those with ffmpeg, so i say ffmpeg is the way to go :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Thu Aug 23, 2012 8:03 am

320x240 @ 10fps is just fine for my needs :)
I guess this tutorial is OK?
thunderingnerd.blogspot.com

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: webcam very low fps

Thu Aug 23, 2012 8:19 am

My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Sat Aug 25, 2012 10:36 pm

oookay I got it working following your guide :) Thanks a lot!
Just some questions:

#1
When I try accessing the stream using Chrome: http://localhost/webcam.ffm
it's just trying to download the file. Any ideas why? I'll try another browser tomorrow...
For now I'm stuck using VLC.

#2
The "-r 5" option seems ignored:

*** 10 dup! fps= 26 q=24.8 size= 27772kB time=00:01:28.60 bitrate=2567.8kbits/s dup=2472 drop=0

Also the bitrate is >2000.
Am I missing something?
thunderingnerd.blogspot.com

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: webcam very low fps

Sun Aug 26, 2012 11:29 am

the bitrate and fps settings are target settings, and get ignored sometimes. You may have to use v4l2-ctl I think it was to set those parameters manually.

also it seems some browsers aren't setup to handle mjpegs. That's also something I'm looking into at the moment.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Mon Aug 27, 2012 10:19 am

Chrome ended support for MJPEG video steams after Chrome 19.0.1084.52
:x

Maybe this is worth trying:
http://www.raspberrypi.org/phpBB3/viewt ... =26&t=7557
The RPi just sends the raw data. I'll try it tomorrow.
thunderingnerd.blogspot.com

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Mon Aug 27, 2012 8:05 pm

SirLagz wrote:the bitrate and fps settings are target settings, and get ignored sometimes
it gets ignored because 30fps is the *only* supported framerate of my crap cam (v4l2-ctl --list-formats-ext) :shock:
Now that was unexpected.

Setting to lower fps returns bad arg.
Oh well I should try better cam (at least with a vendor name on it :D )
thunderingnerd.blogspot.com

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: webcam very low fps

Tue Aug 28, 2012 1:17 am

Stomp wrote:Chrome ended support for MJPEG video steams after Chrome 19.0.1084.52
:x

Maybe this is worth trying:
http://www.raspberrypi.org/phpBB3/viewt ... =26&t=7557
The RPi just sends the raw data. I'll try it tomorrow.
Looks like it was a bug, not support ending
http://code.google.com/p/chromium/issue ... ?id=135337
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Tue Aug 28, 2012 4:31 pm

So I got another camera and I can confirm that Logitech C310 is working fine @15fps.
Damn Chinese crap cams! :)
SirLagz wrote:Looks like it was a bug, not support ending
http://code.google.com/p/chromium/issue ... ?id=135337
So we're now waiting for ver.22 of Chrome... :?
thunderingnerd.blogspot.com

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 6:34 pm

Stomp wrote:So I got another camera and I can confirm that Logitech C310 is working fine @15fps.
Based on this post I just went out and bought a Logitech C310. However, using mplayer I just get a timeout like with my other two cheaper webcams. Can you specify exactly what software and what command you use to have it working? -also, what version of kernel, etc.? Thanks! My specific error is:
v4l2: select timeout

(and as with my other webcams, the C310 does work fine with mplayer on a x86 Debian system.)

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 8:49 pm

Sorry if I mislead you :(
I'll try to avoid such "I confirm" statements in the future.
Please note that this cam is also stated as "working" here: RPi_VerifiedPeripherals

As I said in the first post I'm using "wheezy" images from 15.07.2012 but I made an update (apt-get). I won't be at home for the weekend so I'll be able to send you the exact kernel version later on PM.
Mem config: I don't use X so I'm using 224MB RAM and 32MB VRAM for a Linux.

I'm using this guide from SirLagz with some small modifications - cam resolution/fps, port.
ffserver, ffmpeg commands are basically the same as in the guide.

For receiving the stream I'm using VLC (on Ubuntu 10.04 PC) and the only problem I have is that the VLC often timeouts before starting to stream and I have to push "Play" a couple of times to make it work (quite annoying sometimes). I believe this is a network problem and it has nothing to do with the camera.

Did you compiled ffmpeg as described in the guide?
Did you tried Cheese?
When exactly are you getting timeout in mplayer? Is this on your target PC when receiving the stream or on RPi?
thunderingnerd.blogspot.com

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 9:45 pm

Thank you very much for your reply! Don't worry too much about the purchase, it was my employer's money anyway :-). My raspbian system is up to date as of today, with rpi-update. My RAM split is 128/128 right now although I also tried giving the GPU the minimum.

Code: Select all

Linux raspberrypi 3.2.27+ #96 PREEMPT Fri Aug 31 13:34:04 BST 2012 armv6l GNU/Linux
When connecting the Logitech webcam, dmesg says this:

Code: Select all

[11240.772231] usb 1-1.3: new high-speed USB device number 111 using dwc_otg
[11241.104464] usb 1-1.3: New USB device found, idVendor=046d, idProduct=081b
[11241.104495] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[11241.104525] usb 1-1.3: SerialNumber: 30E6A2F0
[11241.110569] uvcvideo: Found UVC 1.00 device <unnamed> (046d:081b)
[11241.208224] input: UVC Camera (046d:081b) as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.0/input/input43
[11242.202052] 111:3:1: cannot set freq 16000 to ep 0x86
[11243.202086] 111:3:2: cannot set freq 24000 to ep 0x86
[11244.202140] 111:3:3: cannot set freq 32000 to ep 0x86
[11245.202182] 111:3:4: cannot set freq 48000 to ep 0x86
I haven't tried streaming. "cheese" runs the CPU to 100% and seems to hang without opening a window, at least for several minutes, I haven't tried waiting longer yet. I have tried to capture a single frame to a PNG image file with

Code: Select all

mplayer -vo png -frames 1 tv://
which gives me this:

Code: Select all

MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <[email protected]>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: UVC Camera (046d:081b)
 Capabilities:  video capture  streaming
 supported norms:
 inputs: 0 = Camera 1;
 Current input: 0
 Current format: YUYV
v4l2: ioctl set format failed: Input/output error
v4l2: ioctl set mute failed: Invalid argument
v4l2: 0 frames successfully processed, 0 frames dropped.
Exiting... (End of file)
I don't know what it means, but if instead I plug the webcam into the upper of the 2 USB ports, I get dmesg saying something slightly different with the last two complaints about "cannot set freq" missing,

Code: Select all

[11419.998937] usb 1-1.2: new high-speed USB device number 116 using dwc_otg
[11420.331233] usb 1-1.2: New USB device found, idVendor=046d, idProduct=081b
[11420.331294] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[11420.331313] usb 1-1.2: SerialNumber: 30E6A2F0
[11420.336955] uvcvideo: Found UVC 1.00 device <unnamed> (046d:081b)
[11420.434552] input: UVC Camera (046d:081b) as /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/input/input47
[11421.428896] 116:3:1: cannot set freq 16000 to ep 0x86
[11422.428902] 116:3:2: cannot set freq 24000 to ep 0x86
but mplayer result is the same. The very first time I tried mplayer I got a v4l2 timeout but I cannot reproduce that now, and I'm not sure why.

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 10:34 pm

Looks like there are some webcam tips at the post below, which I am trying now.
http://www.raspberrypi.org/phpBB3/viewt ... 45#p135060

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 11:20 pm

Ok, I got something to work, at least a little bit, with Logitech C310 and also two different $10 webcams ("Gear Head" and "HYPE", shown below).

1) I'm not using the webcam audio, and it seems to cause errors, so I edit /etc/modprobe.d/raspi-blacklist.conf to include

Code: Select all

blacklist snd_usb_audio

2) Force low resolution and low framerate with:

Code: Select all

mplayer -fps 1 -tv width=160:height=120 tv://
This does give me a tiny, 1-FPS window with what appears to be 2-bit color, but it is at least some sort of an image. The lag time from the live scene to the capture window display is about 6 seconds (!). I'm hoping there is some way to do better than this (both lag time, and image resolution).
3Webcams.jpg
3Webcams.jpg (39.25 KiB) Viewed 26590 times
Last edited by jbeale on Fri Aug 31, 2012 11:41 pm, edited 1 time in total.

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Fri Aug 31, 2012 11:39 pm

...and about that video quality, um... I look more than a little bit undead :?
00000009.jpg
00000009.jpg (9.74 KiB) Viewed 26587 times
00000010.jpg
00000010.jpg (9.91 KiB) Viewed 26587 times

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Sat Sep 01, 2012 6:06 am

Whoa :) pretty scary images!

This looks like a problem:
[11245.202182] 111:3:4: cannot set freq 48000 to ep 0x86

I haven't seen it with my cams. Maybe something USB related (ep = end pooint)? I'm not sure.
Have you replaced F2 and F3 with 0Ohm resistors on your board? Or tried self powered hub? (probably not your problem but just in case; you can check max current the camera is draining with "lsusb -v")

With both cams I tried - Crapcam and c310 I was getting almost identical behavior. The problem was that with the cramcap I couldn't change the fps (was only 30) and RPi seems to get bloated streaming @30fps over network. Result was huuuge delay between captured and received stream on the VLC on my PC (the picture was good) and frame rate at around 0.005fps :) When I reduced the fps (c310) the delay was ~2s and fps was acceptable (set to 15 but haven't measured it exactly). Which is fine for me. Also res=320x240.

Don't know what else to tell you :| Hope there are more experienced ppl reading this thread...
(Maybe it's worth trying SirLagz's tutorial from above?)
thunderingnerd.blogspot.com

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Sat Sep 01, 2012 10:24 pm

for what it's worth, the "cannot set freq 48000" is apparently related to an audio driver (setting the audio sampling rate to 48000 samples per second). It went away when I disabled the audio, but the video still has trouble as you can see.

User avatar
jbeale
Posts: 3469
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: webcam very low fps

Sun Sep 02, 2012 7:17 pm

By the way, it looks like one difference between the Logitech webcam, and the $10 type is that the Logitech supports MJPEG (the cheap cam lists only the first option, YUYV).

[email protected]:~$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)

Index : 1
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : MJPEG

CrystalCowboy
Posts: 9
Joined: Mon Aug 27, 2012 8:44 pm

Re: webcam very low fps

Sun Sep 02, 2012 8:32 pm

Some webcams I have tried on Raspbian(wheezy) and Arch with fswebcam:

Hercules Deluxe Optical Glass:
YUYV format only. I like this because it is cheap, and has an adjustable focus lens.
Wheezy:
160x120
176x144
352x288 (the default resolution).
Arch: works only at default resolution (352x288). Any attempt to reset the resolution results in garbled images.
Fedora 16(x86_64) (for reference):
160x120
176x144
320x240
352x288
640x480
It appears that the webcam drivers for ARM have some room for improvement.

Microsoft LifeCam VX-800:
YUYV format only.
Wheezy or Arch:
160x120
176x144
320x240
352x288.
Anything higher reso times out.
F16: 160x120, 176x144, 320x240, 352x288, 640x480

HP Webcam HD-2200:
YUYV and MJPEG formats:
160x120
176x144
320x240
352x288 = default
640x480
800x600
MJPEG format only: 1280x720

Logitech C310
YUYV and MJPEG formats:
160x120
176x144
320x176
320x240
352x288 = default
432x240
544x288
640x360
960x544
960x720
1024x576
1184x656
1280x960
MJPEG only: 640x480, 752x416, 800x448, 800x600, 864x480, 1280x720

mjpg-streamer does a great job streaming the MJPEG formats from the camera to the web, with minimal overhead.
motion on wheezy seems to have some problems with MJPEG.

CrystalCowboy
Posts: 9
Joined: Mon Aug 27, 2012 8:44 pm

Re: webcam very low fps

Sun Sep 02, 2012 8:40 pm

jbeale wrote:By the way, it looks like one difference between the Logitech webcam, and the $10 type is that the Logitech supports MJPEG (the cheap cam lists only the first option, YUYV).
Yes, this is to be expected, since the MJPEG format images take up ~ 20X less space than YUYV.

fswebcam is a useful utility for sorting camera capabilities.

User avatar
Stomp
Posts: 37
Joined: Mon Aug 06, 2012 4:34 pm
Contact: Website

Re: webcam very low fps

Mon Sep 03, 2012 12:51 pm

@CrystalCowboy: You said here that you're able to stream 640x360 with CPU @1% :shock:
FPS?
What is the delay in the received stream?
Lol this is hard to believe... Am I missing something here?
thunderingnerd.blogspot.com

tekmanro
Posts: 14
Joined: Tue Jul 17, 2012 9:57 pm

Re: webcam very low fps

Mon Sep 03, 2012 5:14 pm

I'm curious how you got mjpg-streamer to compile on the Raspberry. It looks like it's a very outdated project that relies on v4l1, and wouldn't compile for me with v4l2 (even if I manually rename videodev2.h to videodev.h). Any help there would be appreciated.

Return to “Graphics, sound and multimedia”