Motion - Support Question 2007x 10x 31x 183221

Motion doesn't work if first to access web-cam.

Question

I love this program but have one minor problem. After boot up, Motion never works if it is the first program to access the web-cam. This is on an 8 year old pc...this problem never happened when I was using my laptop.

I'll usually first access the web-cam with the program camstream. After that I can run motion and it works flawlessly. Sometimes I'll start motion first and then I'll have to quit motion (via the web interface using wget) and if I start it again it will work.

By motion "not working" I mean...motion is not detected (no motion pictures saved, however the interval snapshots return black pictures with the text on them) and when viewing through localhost:8081...it is just a black picture with the text.

(Same thing happens with my Nokia N810... except it's every other or so picture is black -- JonathanMiner - 21 Jan 2009)

I've ran it in debug mode but it doesn't tell me anything. It just seems to try to detect motion on a black picture...

Any ideas for a script to run on startup to overcome this? Or, any ideas on why this occurs?

Thanks

web-cam: Logitech QuickCam Messenger (046d:08da)
driver: gspca? 
from dmesg...
[   41.736000] usbcore: registered new interface driver gspca
[   41.736000] ubuntu/media/gspcav1/gspca_core.c: gspca driver 01.00.12 registered

Environment

Motion version: 3.2.8.ubuntu.fiesty_i386
ffmpeg version: svn
Libraries: ffmpeg
Server OS: xubuntu 7.04

-- JoeBeam - 31 Oct 2007

Follow Up

2008.06.30 update

Server is now running xubuntu 7.10 Gutsy (kernel 2.6.22-15-generic). I upgraded motion with motion_3.2.10.1-0.ubuntu.gutsy_i386.deb and upgraded gspca to 01.00.20. The problem still exists.

Just offhand, do other webcam viewers (like camstream) allow you to open the video device in one command? Otherwise, I think I'll try to duplicate whatever motion does when it opens and closes the video stream.

Thanks for your help.


Hi Joe,

I don't really know why motion is not able to "init" your webcam , i hear that with some bttv modules but never with a webcam module ...

you should try to load your module with some debug parameter and run motion in debug mode and no daemon : ./motion -n -d 10

-- AngelCarpintero - 03 Jul 2008

Answer

I've loaded gspca with debug parameters, but it really logs a lot of stuff and I couldn't find any errors. When I run motion in non daemon I get this...

[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.10.1 Started
[0] ffmpeg LIBAVCODEC_BUILD 3352064 LIBAVFORMAT_BUILD 3344896
[0] Thread 1 is from /etc/motion/motion.conf
[1] Thread 1 started
[0] motion-httpd/3.2.10.1 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Not a V4L2 device?
[1] Using VIDEO_PALETTE_YUV420P palette
[1] Using V4L1
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] Closing video device /dev/video0
[0] Motion terminating

Through this process I figured out I can recreate the init problem by removing and adding the gspca module via "sudo modprobe -r gspca" and "sudo modprobe gspca".

I ended up making this simple program to open and close the video stream...

#include <unistd.h>
#include <fcntl.h>

int main(){

int fd = -1;
fd = open("/dev/video0", O_RDWR);

if(fd >= 0){ close(fd); }

return(0);
}

if I run this program before running motion for the first time, everything works. So, I made an alias motion-start='oc-webcam && motion'

all is well now!

(Same solution works for me too! -- JonathanMiner - 21 Jan 2009)


really weird , because motion does exactly the same :
 fd = open(dev->video_device, O_RDWR);

So i think there's a bug on your driver or permission issues.

-- AngelCarpintero - 26 Sep 2008
Topic revision: r8 - 21 Jan 2009, JonathanMiner
Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.