AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Webcam issue with Motion and V4L2

Thu Oct 25, 2012 6:56 am

Quick question really. My Logitech C270 cam is stopping within motion on the RasPi even during periods of no detection.

I have run motion and copied the shell information here:
[email protected] ~ $ sudo motion
[0] Processing thread 0 - config file /home/pi/motion.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478784
[0] Thread 1 is from /home/pi/motion.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Thread 1 started
[1] cap.driver: "uvcvideo"
[1] cap.card: "UVC Camera (046d:0825)"
[1] cap.bus_info: "usb-bcm2708_usb-1.2.3"
[1] cap.capabilities=0x04000001
[1] - VIDEO_CAPTURE
[1] - STREAMING
[1] Test palette YUYV (352x288)
[1] Using palette YUYV (352x288) bytesperlines 704 sizeimage 202752 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255
[1] "Brightness", default -8193, current 128
[1] found control 0x00980901, "Contrast", range 0,255
[1] "Contrast", default 57343, current 32
[1] found control 0x00980902, "Saturation", range 0,255
[1] "Saturation", default 57343, current 32
[1] found control 0x00980913, "Gain", range 0,255
[1] "Gain", default 57343, current 32
[1] mmap information:
[1] frames=4
[1] 0 length=202752
[1] 1 length=202752
[1] 2 length=202752
[1] 3 length=202752
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081

Some time later

[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 1): Input/output error

Some time later

[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 2): Input/output error
[0] Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[0] Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] Calling vid_close() from motion_cleanup
[0] Closing video device /dev/video0

The only way I seem to be able to recover is a reboot after this.
Other information
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 005: ID 046d:0825 Logitech, Inc. Webcam C270

The Pi has its own RS power supply and the camera is off a 4 port powered USB hub to negate any PSU issues.

Can someone help by telling me if this looks like a V4L2 problem, or a motion problem, or how to get more information to determine?

Cheers

Adrian

User avatar
with ice cream
Posts: 175
Joined: Mon Jul 30, 2012 7:25 am

Re: Webcam issue with Motion and V4L2

Thu Oct 25, 2012 7:24 am

My initial problems with motion were related to old firmware, USB quirks and over-configuration. Once I got rid of all v4l packages/configurations and with a powered USB hub and a fresh start everything works great now. Just for the heck of it, have you tried hooking the camera up to one of the on-board USB ports?

AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Re: Webcam issue with Motion and V4L2

Thu Oct 25, 2012 4:10 pm

Yes I originally had the camera on one of the RasPi's USB ports.

I also got suggestions about it possibly being the power supply to the Pi dropping with the extra load so changing over to a powered hub was my most recent attempt to stop the issue.

Adrian :D

lingon
Posts: 128
Joined: Fri Aug 26, 2011 7:31 am

Re: Webcam issue with Motion and V4L2

Sat Oct 27, 2012 7:37 am

I have also tried running motion on my Raspberry Pi. I have overclocked with the turbo mode so it reaches 1 GHz. Using the MJPG is better than the other less compressed image formats.
To get slightly better results I have tried storing the output from motion on the RAM disk. I have configured motion to move the images from the RAM disk to the SD card after the motion event is over.

I have mostly tried running motion with 640*480 5 f/s. If I go to 960*720 2 f/s, then I get even more restarts and error messages and it is not really capable of keeping up.

Unfortunately I get exactly the same error messages:
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 2): Input/output error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 3): Input/output error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
as well as the error message
"Thread 1 - Watchdog timeout, trying to do a graceful restart"
In addition to that I have the problem of really weird colours on the images taken.

My guess is that at least part of the problem is due to lost USB-packets from the webcam because of the driver problem with the USB-system on the Raspberry Pi.

It seems that motion is using mmap. If mmap are unoptimized on the Raspberry Pi, then this might contribute also to the problems with motion that many users are seeing. But this is more of a speculation, that would need some mmap benchmarking.

AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Re: Webcam issue with Motion and V4L2

Sat Oct 27, 2012 9:42 pm

Sorry to have missed your post but thanks for the reply. It does show that it is not just my board or install.
I think I will search for another package, where does one find a list of packages for Raspbian on the Pi?

Adrian

lingon
Posts: 128
Joined: Fri Aug 26, 2011 7:31 am

Re: Webcam issue with Motion and V4L2

Sun Oct 28, 2012 5:36 pm

The USB-issues will remain with other packages unfortunately until they have been fixed.
To search for packages on Raspbian use
apt-cache search application_name

AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Re: Webcam issue with Motion and V4L2

Thu Nov 01, 2012 5:39 pm

Just an update. I purchased another lower spec camera the Logitech C200 which can only do a max of 640 x 480 pix. And up to now this has been running for 12 hours without failing. So possibly down to the camera hardware. Capture is slow at 640 x 480 but still no errors to the web page, will ut back on image capture to see how the Pi copes.

Adrian

Spoken to soon it did give the same error when doing jpeg writes to the SD card even with the size taken down to 320 x 240, I will try movie format.

AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Re: Webcam issue with Motion and V4L2

Thu Nov 01, 2012 11:07 pm

Nope still errors so not dependent on camera
[1] "Gain", default 57343, current 0
[1] mmap information:
[1] frames=4
[1] 0 length=153600
[1] 1 length=153600
[1] 2 length=153600
[1] 3 length=153600
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[1] Resizing pre_capture buffer to 2 items
[1] File of type 8 saved to: /home/pi/motion/01-20121101190743.flv
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 3): Input/output error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 2): Input/output error
[1] File of type 8 saved to: /home/pi/motion/02-20121101194835.flv
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 2): Input/output error
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
[1] File of type 8 saved to: /home/pi/motion/03-20121101200716.flv
[1] File of type 8 saved to: /home/pi/motion/04-20121101200900.flv
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
[0] Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[0] Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] Calling vid_close() from motion_cleanup
[0] Closing video device /dev/video0

Adrian

Bogdanz
Posts: 1
Joined: Tue Jan 22, 2013 5:54 pm

Re: Webcam issue with Motion and V4L2

Tue Jan 22, 2013 5:57 pm

Any success until now to fix this ?
I am getting the same problems so I am interested if you found a solution

AdrianH
Posts: 32
Joined: Wed Jun 27, 2012 7:43 pm

Re: Webcam issue with Motion and V4L2

Tue Jan 22, 2013 8:30 pm

No I gave up and went another way.

Adrian

sidboswell
Posts: 1
Joined: Mon Feb 11, 2013 4:39 pm

Re: Webcam issue with Motion and V4L2

Mon Feb 11, 2013 4:45 pm

I have had several issues of similar to those mentioned here. Namely:

v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 1): Input/output error

after several hours, then crash.

I've tried multiple webcams (all Logitech), different pallets (MJPEG and YUYV), different resolutions (320x240, 640x480), with and without a powered USB hub.

The web cams that I know had issues were a Quickcam for Notebooks and a c310.

However, I have an (Logitech) Orbit AF that I use for work and moved it from my work PC to my Pi over the weekend and it's been running ever since with no issues. It's a larger camera so I'm pushing it with a powered USB hub. I haven't tried the tracking features, but will when I have time.

I did also notice that MJPEG worked, but had an ugly color balance issue so I'm back with the YUYV at 640x480 @ 15 FPS.

PM me for my motion.conf if interested.

rpbrpb
Posts: 9
Joined: Wed Jun 12, 2013 8:41 pm

Re: Webcam issue with Motion and V4L2

Thu Jun 13, 2013 8:43 am

I've had the same problem for a few months now - Logitech C270 on powered hub, saving images to a USB memory stick also on powered hub (Pi USB ports to hub and mini WiFi dongle). I posted details two months ago here (user Rich):

http://astroland.funxiun.com/using-the- ... d-storage/

All my Pi manages is 320x240 images at 2fps and it fails every 10-20 minutes. I'm using the one stable combination I stumbled across: v4l2 palette 6, framerate 2, despeckle EedDl (whatever that means), gap 600, ffmpeg_cap_new on, ffmpeg_bps 500000, tracking off, rotate 180 (camera is mounted upside down!).

I wrote a script (motion-restarter.pl) that monitors /var/log/messages for the watchdog timer failing and restarts the motion service when it does. This gives me continuous coverage (I've had uptimes of a month) but with 30s gaps whenever the USB/service fails.

I tried apt-get upgrade a while ago but it bricked my pi each time (apparently a known issue at the time) so I wasn't able to see if recent USB fixes have helped the problem.

As I said in the above post, it's very disappointing that a camera that works flawlessly at 30fps in HD on Windows fails to work on Linux (I appreciate the lower power of the pi means 30fps and/or HD might not be possible, but craching every 10-20 minutes?)

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Webcam issue with Motion and V4L2

Thu Jun 13, 2013 9:37 am

Was reading through this, and I have not tried what you have, so consider this a guess :)

Is the camera device driver staying loaded or is it being dropped ?

The OS system is working on a demand basis, and it could be dumping a device driver and then it gives the I/O error.

rpbrpb
Posts: 9
Joined: Wed Jun 12, 2013 8:41 pm

Re: Webcam issue with Motion and V4L2

Thu Jun 13, 2013 12:46 pm

Ooh, I'm not sure. This is what I was getting in my /var/log/messages file - I'm not sure how to check if a driver has unloaded, sorry:

Code: Select all

[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
[0] Thread 1 is from /etc/motion/motion.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Thread 1 started
[1] cap.driver: "uvcvideo"
[1] cap.card: "UVC Camera (046d:0825)"
[1] cap.bus_info: "usb-bcm2708_usb-1.3.1"
[1] cap.capabilities=0x04000001
[1] - VIDEO_CAPTURE
[1] - STREAMING
[1] Test palette YUYV (320x240)
[1] Using palette YUYV (320x240) bytesperlines 640 sizeimage 153600 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255
[1]     "Brightness", default -8193, current 128
[1] found control 0x00980901, "Contrast", range 0,255
[1]     "Contrast", default 57343, current 32
[1] found control 0x00980902, "Saturation", range 0,255
[1]     "Saturation", default 57343, current 32
[1] found control 0x00980913, "Gain", range 0,255
[1]     "Gain", default 57343, current 0
[1] mmap information:
[1] frames=4
[1] 0 length=153600
[1] 1 length=153600
[1] 2 length=153600
[1] 3 length=153600
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[1] File of type 8 saved to: /tmp/motion/01-20130407085234.swf
[1] File of type 1 saved to: /tmp/motion/01-20130407085234-01.jpg
...
[1] File of type 1 saved to: /tmp/motion/01-20130407085330-00.jpg
[0] Thread 1 - Watchdog timeout, trying to do a graceful restart
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[0] Thread 1 - Watchdog timeout, did NOT restart graceful,killing it!
[0] Calling vid_close() from motion_cleanup
[0] Closing video device /dev/video0

Return to “Raspbian”