Motion - Support Question 2012x 11x 18x 175503

on_motion_start, on_motion_end - only starting/ending at start/end of motion


Using a Microsoft Lifecam VX3000, plugged directly into a Raspberry Pi, no other peripherals.

This (I'm thinking, RTFM) involves setting up 'on_event_start' and 'on_event_end'.

I'm trying to get 'motion' to fire off a script when motion is detected, and when motion is not detected, with a gap of 2 seconds, the system seems to fire off the starting event when the system runs, and fires off the ending event when I hit 'control-C' to stop the process, but it isn't running as expected. I would think that once motion detection stops, the 'on_event_end' would fire.

Am I missing the obvious here?

I do get the occasional "Corrupt JPEG data" message, but I would think this isn't the critical point. When motion detection stops, after 2 seconds, the scripts should fire.

Output when running from command line:

pi@raspberrypi ~/.motion $ motion
[0] Processing thread 0 - config file /home/pi/.motion/motion.conf
[0] Motion 3.2.12 Started
[0] Thread 1 is from /home/pi/.motion/motion.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8081
[1] Thread 1 started
[1] cap.driver: "sonixj"
[1] cap.card: "USB camera"
[1] cap.bus_info: "usb-bcm2708_usb-1.3"
[1] cap.capabilities=0x05000001
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: JPEG (JPEG)
[1] Selected palette JPEG
[1] Test palette JPEG (320x240)
[1] Using palette JPEG (320x240) bytesperlines 320 sizeimage 29390 colorspace 00000007
[1] found control 0x00980900, "Brightness", range 0,255
[1]     "Brightness", default 128, current 1
[1] found control 0x00980901, "Contrast", range 0,127
[1]     "Contrast", default 20, current 20
[1] found control 0x00980902, "Saturation", range 0,40
[1]     "Saturation", default 25, current 25
[1] found control 0x0098090e, "Red Balance", range 24,40
[1]     "Red Balance", default 32, current 32
[1] found control 0x0098090f, "Blue Balance", range 24,40
[1]     "Blue Balance", default 32, current 32
[1] found control 0x00980910, "Gamma", range 0,40
[1]     "Gamma", default 20, current 20
[1] mmap information:
[1] frames=4
[1] 0 length=32768
[1] 1 length=32768
[1] 2 length=32768
[1] 3 length=32768
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8080
STARTING 1111111111
width= 176  height= 153  x= 175  y=  162
width= 199  height= 225  x= 222  y=  112
width= 160  height= 208  x= 243  y=  104
width= 94  height= 191  x= 275  y=  95
Corrupt JPEG data: 10257 extraneous bytes before marker 0xd9
^CENDING 0000000000
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] Closing video device /dev/video0
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[0] Motion terminating
pi@raspberrypi ~/.motion $

The scripts to run:

pi@raspberrypi ~/.motion $ more echostart
echo STARTING 1111111111
pi@raspberrypi ~/.motion $ more echoend
echo ENDING 0000000000
pi@raspberrypi ~/.motion $


# motion configuration file
# correct ratio (H=3:W=4) divisible by 16
on_motion_detected echo "width=" %i " height=" %J " x=" %K " y= " %L
on_event_start /home/pi/.motion/echostart gap 2
on_event_end /home/pi/.motion/echoend gap 2
# for outputting coordinates
# snapshot_interval=0 means snapshots are disabled


Motion version: 3.2.12
ffmpeg version: 0.8.4-6:0.8.4-1+rpi1
Libraries: ffmpeg
Server OS: Raspberry Pi (1.0) 3.2.27+
-- AndrewA - 18 Nov 2012


Continue to RTFM, I think (AndrewA):

In motion.conf, put the line in:

gap 2

For the on_event_start and on_event_end lines, just put in:

on_event_start /home/pi/.motion/echostart
on_event_end /home/pi/.motion/echoend

Works, with 2 second gap. Don't know if it is possible to set different gap lengths for start and end.

[Answering again...}

gap 2


gap 30


This allows on_event_start to fire after 2 seconds of motion, and on_event_end to fire 30 seconds after the end of motion.

Further testing, trying to do something like fire on_event_start to fire 30 seconds after continuous motion start, and on_event_end to fire 2 seconds after motion stoppage doesn't seem to work, however.

Also, no matter what gap is used, it seems 'on_event_start' always fires immediately after motion detection.

Rule of Posting Questions: After you have exhausted (what you thought) were all options/documentation, you will post a message to newsgroup/wiki. 30 seconds later, you will solve your own problem.

SupportForm edit

TopicTitle on_motion_start, on_motion_end - only starting/ending at start/end of motion
SupportStatus AskedQuestions
SubmittedBy AndrewA
Topic revision: r1 - 18 Nov 2012, AndrewA
Copyright © 1999-2024 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.