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

Trouble with motion

Sat Oct 20, 2012 11:35 pm

I run Raspbian and continuously have problems running motion. So I thought I would remove with sudo apt-get remove motion
remove any config files left behind and any folders and start again.
But I get an errors when I install

sudo apt-get install motion
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
mysql-client postgresql-client
The following NEW packages will be installed:
motion
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 261 kB of archives.
After this operation, 756 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main motion armhf 3.2.12-3.2 [261 kB]
Fetched 261 kB in 1s (208 kB/s)
Preconfiguring packages ...
Selecting previously unselected package motion.
(Reading database ... 59223 files and directories currently installed.)
Unpacking motion (from .../motion_3.2.12-3.2_armhf.deb) ...
Processing triggers for man-db ...
Setting up motion (3.2.12-3.2) ...
chmod: cannot access `/etc/motion/motion.conf': No such file or directory
dpkg: error processing motion (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
motion
E: Sub-process /usr/bin/dpkg returned an error code (1)

Doing a quick ls there is a /etc/motion folder but no motion.conf

In the past I copied one from the web and pasted into this folder. Thinking this may be why I had issues.

But wonder if the chmod lines may be pointing to something else, I need to ask the groups support.

Is it a problem in the package with Raspbian.

I also could only run it previously using sudo motion?

Adrian

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Trouble with motion

Sun Oct 21, 2012 12:07 am

You might try purging the the package first - if the packaging system believes there should be a config file present from the previous install it might not create one, and then it'll fail because you manually removed it. "apt-get purge motion".

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

Re: Trouble with motion

Sun Oct 21, 2012 8:54 am

That certainly did have a different effect.

I ran sudo apt-get purge motion, then rebooted the Pi then reinstalled.
sudo apt-get install motion
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
mysql-client postgresql-client
The following NEW packages will be installed:
motion
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/261 kB of archives.
After this operation, 756 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package motion.
(Reading database ... 59215 files and directories currently installed.)
Unpacking motion (from .../motion_3.2.12-3.2_armhf.deb) ...
Processing triggers for man-db ...
Setting up motion (3.2.12-3.2) ...
Adding group `motion' (GID 110) ...
Done.
Adding system user `motion' (UID 107) ...
Adding new user `motion' (UID 107) with group `motion' ...
Not creating home directory `/home/motion'.
Adding user `motion' to group `video' ...
Adding user motion to group video
Done.
[warn] Not starting motion daemon, disabled via /etc/default/motion ... (warning).

I will try to run and configure the Package

Thanks

Adrian

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

Re: Trouble with motion

Sun Oct 21, 2012 1:08 pm

Getting further with the package.

If I am saving files and movies it will soon crash out with IO/errors but does last longer if all stopped and just using it to post frames to the web server every 2 seconds.

I have tried to run it in deamon mode but get the following error
Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid: No such file or directory
[0] Motion going to daemon mode


So it I think saying that I need a pid file?

what is this and why could the program not run/install one at install?

Cheers
Adrian

OK may have got this one myself having a dig around in the rasPi.

Noticed that all the other pid files were in fact in /var/run directory where as the config file had it as /var/run/motion so ther was not directory or folder. I was expecting motion to be able to write the folder but looks like it can not eve when run a Sudo

It must be good to be an expert at this, hope my ramblings help someone.

DavidMS
Posts: 144
Joined: Fri May 25, 2012 8:48 pm
Contact: Website

Re: Trouble with motion

Sun Oct 21, 2012 1:38 pm

I know it is the standard answer but have you checked you have a good power supply. I had problems initially with Motion doing some random stuff but since getting a better power supply and moving the camera to a 4 way powered USB. it seems to run fine.

Also - I got one of the new UK build Rpis yesterday and that has been running Motion for about 24 hours now, with a Camera and Wifi dongle in the two on-board USB ports
http://meanderingpi.wordpress.com/
11 Raspberry Pi's and counting....

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

Re: Trouble with motion

Sun Oct 21, 2012 2:17 pm

The power supply is good for 1.2 Amps and measuring the supply volts it is healthy on the Test point at 4.9 Volts.

I believe, although not having one of the new ones yet, that the two poly fuses F1 and F2 that supply the USB ports have been taken out on the new boards and shorts have been fitted instead. This should be solving the problem with powering some of the devices on the usb ports.

I have bypassed F2 which supplies the bottom USB port and I am running my Logitech camera on that port. Again I have measure 4.9 Volts on that device.

I would be interested to discover what camera you are using and even what powered hub, because if all else fails I will go down that route.

Lastly what size pictures you are able to view/take? I seem to only be able to view 320 x 240.

I appreciate your assistance.

Adrian

DavidMS
Posts: 144
Joined: Fri May 25, 2012 8:48 pm
Contact: Website

Re: Trouble with motion

Sun Oct 21, 2012 2:36 pm

AdrianH wrote:The power supply is good for 1.2 Amps and measuring the supply volts it is healthy on the Test point at 4.9 Volts.

I believe, although not having one of the new ones yet, that the two poly fuses F1 and F2 that supply the USB ports have been taken out on the new boards and shorts have been fitted instead. This should be solving the problem with powering some of the devices on the usb ports.

I have bypassed F2 which supplies the bottom USB port and I am running my Logitech camera on that port. Again I have measure 4.9 Volts on that device.

I would be interested to discover what camera you are using and even what powered hub, because if all else fails I will go down that route.

Lastly what size pictures you are able to view/take? I seem to only be able to view 320 x 240.

I appreciate your assistance.

Adrian

USB port is New Link from Farnell - http://uk.farnell.com/jsp/search/produc ... ku=8704341

Web Cam is - Logitech Webcam C200 from Amerzon

I also used a cheap HP one I got in surplus store before this, which gave me some problems, but I suspect that was more down to a poor a power supply I was using at the time
http://meanderingpi.wordpress.com/
11 Raspberry Pi's and counting....

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

Re: Trouble with motion

Sun Oct 21, 2012 2:45 pm

Just asking but the powered hub just looked at it in Farnel and do they also supply a separate PSU with it?

Also amend maximum size of picture to 352 x 288

Adrian

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

Re: Trouble with motion

Sun Oct 21, 2012 2:46 pm

AdrianH wrote:Getting further with the package.
If I am saving files and movies it will soon crash out with IO/errors but does last longer if all stopped and just using it to post frames to the web server every 2 seconds.
That may point to a hardware/power/setup problem. Run motion once (with sudo) in non-daemon setup mode (without conf file) and see what it finds.
AdrianH wrote:I have tried to run it in deamon mode but get the following error
Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid: No such file or directory
[0] Motion going to daemon mode


So it I think saying that I need a pid file?
In daemon mode it runs as its own user ('motion'). If you set it up to start with the system and the conf file is readable for motion and whatever directories files are saved to are writable it should work. It may mess up things when you start it manually (sudo). Try testing with "sudo su motion motion".

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Trouble with motion

Sun Oct 21, 2012 7:00 pm

AdrianH wrote: Noticed that all the other pid files were in fact in /var/run directory where as the config file had it as /var/run/motion so ther was not directory or folder. I was expecting motion to be able to write the folder but looks like it can not eve when run a Sudo

It must be good to be an expert at this, hope my ramblings help someone.
Probably the daemon expects the directory to exist - typically daemons create the pid file, but don't try to create the directory tree above where the pid file goes. I'd have expected the install to create that directory, but maybe it's just a bit buggy. If motion normally runs as user 'motion', then maybe you need to create a /var/run/motion directory and change its owner to be 'motion'.. So something like "sudo mkdir /var/run/motion" and "sudo chown motion.motion /var/run/motion" (motion.motion changes owner and group; if that errors try just "chown motion /var/run/motion"). I don't know what motion is, I've never run it, I'm just making suggestions based on how things typically work, so I may be wrong in this case :)

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

Re: Trouble with motion

Sun Oct 21, 2012 7:32 pm

When run as a daemon motion creates the directory when it doesn't exist:

Code: Select all

case "$1" in
  start)
    if check_daemon_enabled ; then
        if ! [ -d /var/run/motion ]; then
                mkdir /var/run/motion
        fi
        chown motion:motion /var/run/motion
(from /etc/init.d/motion)

As a daemon it runs fine but starting it from the command line mixes things up. I ran into similar problems and made it worse by playing with permissions and file paths.

DavidMS
Posts: 144
Joined: Fri May 25, 2012 8:48 pm
Contact: Website

Re: Trouble with motion

Sun Oct 21, 2012 7:41 pm

AdrianH wrote:Just asking but the powered hub just looked at it in Farnel and do they also supply a separate PSU with it?

Also amend maximum size of picture to 352 x 288

Adrian
Yes hub comes with PSU and seems to power the Rpi fine by looping back a line to the RPI power connector.

have not fiddled with the resolution as low res is fine for what I need

I always run is with Sudo motion -n
http://meanderingpi.wordpress.com/
11 Raspberry Pi's and counting....

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

Re: Trouble with motion

Mon Oct 22, 2012 10:16 pm

I have 'punched a hole' in my router to stick myRasPi running motion to the outside world. What a failure that was! I can browse from my local computer to the internal IP and see pictures no problem. I can browse from my PC to the external IP address as I am seen on the www and again for me no problem.

But when I went and did a test from a remove computer, I could see the control port but not the video.

Back home and everything looks OK again from my PC, so to a further test I went through a proxy server and looked back at my internet connection and the page would not show?

A look on the motion pages and found this snippet of information:

Motion has simple webcam server built in. The video stream is in mjpeg format.

Note: The webcam server feature requires that the option ppm is set to off.

Snip

The webserver generates a stream in "multipart jpeg" format (mjpeg). You cannot watch the stream with most browsers. Only certain versions of Netscape works. Mozilla and Firefox browsers can view the mjpeg stream but you often have to refresh the page once to get the streaming going. Internet Explorer cannot show the mjpeg stream. For public viewing this is not very useful. There exists a java applet called Cambozola which enabled any Java capable browser to show the stream. To enable the feature to a broad audience you should use this applet or similar.

To use the webcam feature with Cambozola is actually very simple.

1. Create a html page in which you will want the streamed picture.

2. In the html page include this code

<applet code=com.charliemouse.cambozola.Viewer
archive=cambozola.jar width="320" height="240" style="border-width:1; border-color:gray; border-style:solid;"> <param name=url value="http://www.myurl.com:8081"> </applet>

Where the width and height is the image size of the video stream.

Replace http://www.myurl.com:8081 by the real url and port number of your choice.

So now wondering how to add this web page to the RasPi so that standard browsers can view it, looks really like I would need a web server?

Adrian

Editing to say that I have downloaded lighttpd which installs and sets the Pi up as a web server and will play at putting the motion frame within that, may take a while!

chorlton2080
Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Re: Trouble with motion

Tue May 14, 2013 9:32 pm

If you are receiving the error connected with absence of "var/motion/motion.pid" when running in daemon mode, this is likely attributed to permissions.

I changed the entry in "etc/motion/motion.conf" from "var/motion/motion/pid" to "home/pi/motion.pid" and it now works fine. When running "motion" on a headless RPi, daemon mode is essential if you ever want to exit your SSH connection and keep streaming.

As way of performance, using a Logitech (unknown variety) HTOP is reporting around 7% CPU at 320x240 (max frames) and 17% CPU at 640x480: not too bad and hardly stressing the RPi.

Question now is: should I bother with the RPi Cam Board? Your thoughts please!

Return to “Raspberry Pi OS”