dieteltow
Posts: 1
Joined: Fri Jan 04, 2013 9:17 pm

2 Webcams with motion

Fri Jan 04, 2013 9:37 pm

Hi all,

I'm running successfully a Creative Live! Cam Sync on my Pi (debian-wheezy). I have a webstream and motion takes pictures when it detects motion. It works when connected to a powered usb hub and directly connected to the on board usb port. So far so good.

Now I connected a second camera of the same type. I configured Thread1.conf for dev/video0 and Thread2.conf for /dev/video1. Both cameras are connected to the onboard usb ports (I connect to the pi using ssh, so don't need mouse and keyboard connected to the pi).

$ lsusb
Bus 001 Device 004: ID 041e:406c Creative Technology, Ltd Live! Cam Sync [VF0520]
Bus 001 Device 005: ID 041e:406c Creative Technology, Ltd Live! Cam Sync [VF0520]

First camera works, I have a webstream on 8081

Second camera does not work:

[2] Retrying until successful connection with camera
[2] cap.driver: "uvcvideo"
[2] cap.card: "VF0520 Live! Cam Sync"
[2] cap.bus_info: "usb-bcm2708_usb-1.3"
[2] cap.capabilities=0x04000001
[2] - VIDEO_CAPTURE
[2] - STREAMING
[2] Unable to query input 1 VIDIOC_ENUMINPUT: Invalid argument
[2] ioctl (VIDIOCGCAP): Invalid argument
[2] Video signal lost - Adding grey image

So I switched the cameras to check if it is a problem with the second cameras itself: Same problem
Next try: Connect both cameras to a powered usb hub: Same problem.
Next try: One camera connected to board, other camera to usb hub: Same probem

Any ideas?

Brgds,

Dietmar

User avatar
jors
Posts: 32
Joined: Sun Sep 23, 2012 9:05 am
Location: Barcelona
Contact: Website

Re: 2 Webcams with motion

Sat Feb 02, 2013 8:47 pm

I have bought the same webcam (Creative Live! Cam Sync) and I haven't managed to get it working propperly with motion :cry:

Other image capture apps (fswebcam, uvccapture) work correctly, but even if I tried several & different configuration options with motion, most of captured images are corrupt. Could you please provide your motion configuration/usage?

Cheers.
Blog @ http://enchufado.com/

User avatar
jors
Posts: 32
Joined: Sun Sep 23, 2012 9:05 am
Location: Barcelona
Contact: Website

Re: 2 Webcams with motion

Sun Feb 03, 2013 9:13 am

Oh, and just for the record the webcam works perfectly with motion + same configuration on any other non-Raspberry Pi hardware. It is a little bit dissapointing since I cannot do anything to solve it because it is a hardware issue.

Cheers.
Blog @ http://enchufado.com/

User avatar
jors
Posts: 32
Joined: Sun Sep 23, 2012 9:05 am
Location: Barcelona
Contact: Website

Re: 2 Webcams with motion

Sun Feb 03, 2013 10:57 am

Ok, found a workaround on the forums (http://www.raspberrypi.org/phpBB3/viewt ... 6&p=276985 and http://www.raspberrypi.org/phpBB3/viewt ... er#p164539) that worked. In summary, you have to use motion taking the input from mjpg_streamer. Here are (more or less) the steps:

Step 1: mjpg_streamer

Code: Select all

apt-get install subversion libv4l-dev libjpeg8-dev imagemagick checkinstall
cd /usr/src/
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
cd mjpg-streamer/mjpg-streamer
make USE_LIBV4L2=true clean all
checkinstall # Basically this creates a Debian/Raspbian package for better handling
dpkg -l | grep mjpg # Verify it has been installed
mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -r 352x288 -f 5" -o "/usr/local/lib/output_http.so -p 8090 -w /var/www/mjpg_streamer" # You can avoid putting absolute paths to plugins by setting LD_LIBRARY_PATH as follows...
export LD_LIBRARY_PATH=/usr/local/lib; mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 352x288 -f 5" -o "output_http.so -p 8090 -w /var/www/mjpg_streamer"
Step 2: motion

Code: Select all

apt-get install motion
vi /etc/motion/motion.cnf
netcam_url "http://localhost:8090/?action=snapshot"
motion -n
And that's it. Hope it will be usefull to others!

Cheers.
Blog @ http://enchufado.com/

gerorge
Posts: 1
Joined: Wed Apr 17, 2013 6:41 pm

Re: 2 Webcams with motion

Wed Apr 17, 2013 6:48 pm

Hi,

I had the same problem, but after launch it manually i saw that motion.conf didn't find thread files:

motion looks for :
/usr/local/etc/thread*.conf

bu my files are in:
/etc/motion/thread*.conf

after that you have to change ports, so that you'll have a different port for a different camera

regards

droidus
Posts: 251
Joined: Sat Feb 02, 2013 4:09 am

Re: 2 Webcams with motion

Wed Apr 17, 2013 9:55 pm

I have been having issues with motion as well. I am using an hp webcam, and can't get it to stream to the address defined by the netcam_url.

chriglu
Posts: 27
Joined: Thu Mar 28, 2013 10:17 pm

Re: 2 Webcams with motion

Thu Apr 18, 2013 4:44 am

droidus wrote:I have been having issues with motion as well. I am using an hp webcam, and can't get it to stream to the address defined by the netcam_url.
Can you check if motion is listening on the defined ports with "netstat -tulpn" ?

Code: Select all

tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8082            0.0.0.0:*               LISTEN

droidus
Posts: 251
Joined: Sat Feb 02, 2013 4:09 am

Re: 2 Webcams with motion

Sat Apr 20, 2013 12:22 am

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2154/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2692/sshd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2781/mysqld
udp 0 0 0.0.0.0:68 0.0.0.0:* 1984/dhclient
udp 0 0 10.30.211.164:123 0.0.0.0:* 2329/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2329/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2329/ntpd
udp 0 0 0.0.0.0:60804 0.0.0.0:* 1984/dhclient

this is all that is running when I run motion.

chriglu
Posts: 27
Joined: Thu Mar 28, 2013 10:17 pm

Re: 2 Webcams with motion

Sat Apr 20, 2013 6:23 am

It seems that your motion isn't running on any ports. if you started motion, you should see a log entry /var/log/syslog when it starts listening on the ports:

Code: Select all

[email protected] ~ $ grep stream /var/log/syslog
Apr 20 08:06:14 earlybirdpi motion: [1] Started stream webcam server in port 8081
Apr 20 08:06:15 earlybirdpi motion: [2] Started stream webcam server in port 8082
can you check, if motion is running? maybe the startup already fails..

Code: Select all

[email protected] ~ $ pstree |grep motion
     |-motion---3*[{motion}]
Otherwise you need to have a look in /var/log/syslog what's happening/failing when you start it.

droidus
Posts: 251
Joined: Sat Feb 02, 2013 4:09 am

Re: 2 Webcams with motion

Sat Apr 20, 2013 12:26 pm

when I run that first command, this is what I get:

Apr 6 18:11:18 raspberrypi motion: [1] Started stream webcam server
in port 8081
Apr 6 18:43:59 raspberrypi motion: [1] Started stream webcam server
in port 8081
Apr 6 23:03:42 raspberrypi motion: [1] Started stream webcam server
in port 8081
Apr 6 23:06:27 raspberrypi motion: [1] Started stream webcam server
in port 8081
Apr 16 17:18:13 raspberrypi mysqld: Open streams: 0
Apr 19 22:50:10 raspberrypi mysqld: Open streams: 0

as for the grep motion:

| -bash---motion---{motion}

piscesmini
Posts: 1
Joined: Tue Oct 14, 2014 2:11 pm

Re: 2 Webcams with motion

Tue Oct 14, 2014 2:15 pm

Hi I am new to Rasberry Pi
I was able to connect 2 USB cameras and both are working fine. I just cannot get both cameras to work because I dont know how to make new thread.conf files for both cameras.

Can you please help

Sailinghome
Posts: 1
Joined: Fri Oct 24, 2014 3:20 am

Re: 2 Webcams with motion

Fri Oct 24, 2014 3:21 am

This site is a bit old, but seems to explain how to separate the two webcams in the RPi.

http://astrobeano.blogspot.hk/2012/08/r ... bcams.html

I hope it helps.

User avatar
sudo
Posts: 5
Joined: Mon Jul 21, 2014 4:37 am
Location: Calgary, Alberta, Canada
Contact: Website

Re: 2 Webcams with motion

Thu Oct 30, 2014 1:41 am

My particular error message read:
Unable to query input 5 VIDIOC_ENUMINPUT: Invalid argument

Well, turns out, my /etc/motion/motion.conf had a section that appeared as:

Code: Select all

# The video input to be used (default: 8)
# Should normally be set to 0 or 1 for video/TV cards, and 8 for USB cameras
input 5
I changed it to input 8 and now my camera works.

In my case, I was probably the culprit. Long ago, I'd been going crazy trying insane things to make some uncooperative, ancient web cam function. Then I got some new cheap ones from ebay and tried them, running aground with this. I didn't notice this rather glaring error.

Others may stumble here as I did, hence my posting of this here.

alfox
Posts: 127
Joined: Sun Mar 22, 2015 11:06 am

Re: 2 Webcams with motion

Fri May 22, 2015 2:47 pm

Can you help me? My two webcams don't work: only one.



On this guide http://astrobeano.blogspot.hk/2012/08/r ... bcams.html

Code: Select all

..... I went with two camera configuration files as ~/webcam/cam1.conf which is just:

videodevice /dev/video0
webcam_port 8081
What is the "cam1.conf "'s path?

How do I put my configuration files? txt e docx are't allowed

barsznica
Posts: 18
Joined: Thu Apr 14, 2016 12:38 pm

Re: 2 Webcams with motion

Tue Mar 07, 2017 5:51 am

Hurrah, it works!
Uncomment the "threads" used in motion.conf and comment out any lines that will be in the "thread*.conf" files. The thread*.conf files live where motion.conf does; /etc/motion/
The tread.conf files only need to describe things that are DIFFERENT between the cameras. Therefore, videodevice and stream_port will have to be commented out in motion.conf (at the very least).

In thread2.conf I have:
videodevice /dev/video1
stream_port 8081
In thread1.conf I have:
videodevice /dev/video0
stream_port 8082

Running apache2, in /var/www/html/index.html only contains:
<img src="http://192.168.1.5:8081"/>
<img src="http://192.168.1.5:8082"/>

pvklink
Posts: 13
Joined: Wed Mar 08, 2017 3:03 pm

Re: 2 Webcams with motion

Wed Mar 08, 2017 7:43 pm

Hi can somebody help me witj my motion.conf?
I can't get motion control working in my RPI

i installed debian jessie
RPI 3 b
IP camera DAHUA IPC A35P

I just installed a DAHUA IPC A35P. and the web and app are working great! I have the app working over internet,
streams are stored on my nas and the last thing to do is domoticz integration.

I installed motion on the rpi:
sudo apt-get install motion
sudo nano /etc/default/motion
start_motion_daemon=yes and saved the file
sudo /etc/init.d/motion start

and finaly edit motion.conf with
netcam_url rtsp:// :@/cam/realmonitor?channel=1&subtype=0.
rtsp_uses_tcp off

and get errors like this: (strange because i do get a live stream in VLC with the same URL !!!! is this a Bug?

[1] [CRT] [NET] [Mar 08 19:48:27] netcam_start: Invalid netcam_url ( rtsp:// :@/cam/realmonitor?channel=1&subtype=0.)
[1] [WRN] [ALL] [Mar 08 19:48:27] motion_init: Could not fetch initial image from camera Motion continues using width and height from config file(s)

What else parameters do i have to set to get my motion control to work
Or is it that the url could be correct but other parameters are wrong?
Who can help me?, i think i am almost there....

Annihilation989
Posts: 3
Joined: Wed Feb 14, 2018 3:37 pm

Re: 2 Webcams with motion

Wed Feb 14, 2018 3:44 pm

will the camera work if it already has built in software

Annihilation989
Posts: 3
Joined: Wed Feb 14, 2018 3:37 pm

Re: 2 Webcams with motion

Fri Feb 16, 2018 10:29 am

will the camera work if it already has built in software


Return to “Troubleshooting”