lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Thu May 19, 2016 7:23 am

@pi-anazazi
I always use motion in daemon mode, is that a problem?
I have never used daemon mode. Launching it using start-stop-daemon works well for me. I have seen some posts from people about who do use it. I think it should be OK as long as the user is allowed to write the pid file - which you already changed! So long as you can see the log output somewhere it is fine!

By the way, just to check, when you said a few posts ago that you have been using an older version of motion with the same config file, did you mean motion, or mmal-motion? You know that mmal-motion is intended only for use with the raspberry pi camera using the direct MMAL API - not /dev/video0 drivers.

User avatar
pi-anazazi
Posts: 515
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Motion - MMAL camera

Thu May 19, 2016 11:33 am

Yep, I only use the raspi cam with both raspis... Will try that soon, busy these days...
Kind regards

anazazi

User avatar
pi-anazazi
Posts: 515
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Motion - MMAL camera

Sat May 21, 2016 2:50 pm

Hy again!

Problem solved... kind of... ;-)

Could not find anything in the logs, motion doing fine... at a resolution of 1920x1024 video streaming... :-D

So switched to a raspi 2 for this one, motion fully occupying one core, but still three left for the rest of the show.

So it does what it's supposed to do now, don't see anything to debug, or?

kind regards

anazazi
Kind regards

anazazi

mmocco
Posts: 1
Joined: Mon Jun 13, 2016 7:26 pm

Re: Motion - MMAL camera

Mon Jun 13, 2016 7:36 pm

I'm using motion mmal on my pi and it was working fine for awhile. I set it up to stream to my 8081 port and soon discovered that the steam would end on its own after a few hours. While trying to debug this I came upon a new problem and am at a loss.

Whenever my camera detects motion, it immediately stops streaming and soon after terminates the process.

My logfile is below:

Code: Select all

[0] [NTC] [ALL] [Jun 13 19:29:00] motion_startup: Using log type (ALL) log level (INF)
[0] [NTC] [ENC] [Jun 13 19:29:00] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3670272 LIBAVFORMAT_BUILD 3670272
[0] [NTC] [ALL] [Jun 13 19:29:00] main: Thread 1 is from /home/pi/mmal/motion-mmalcam-both.conf
[0] [NTC] [ALL] [Jun 13 19:29:00] main: Thread 1 is device: /dev/video0 input -1
[0] [NTC] [ALL] [Jun 13 19:29:00] main: Stream port 8081
[0] [NTC] [ALL] [Jun 13 19:29:00] main: Waiting for threads to finish, pid: 4373
[1] [NTC] [ALL] [Jun 13 19:29:00] motion_init: Thread 1 started , motion detection Enabled
[1] [ALR] [VID] [Jun 13 19:29:00] mmalcam_start: MMAL Camera thread starting... for camera (vc.ril.camera) of 640 x 480 at 8 fps
[0] [NTC] [STR] [Jun 13 19:29:00] httpd_run: motion-httpd testing : IPV4 addr: 0.0.0.0 port: 8080
[1] [ALR] [VID] [Jun 13 19:29:00] mmalcam_start: MMAL Camera using video capture
[0] [NTC] [STR] [Jun 13 19:29:00] httpd_run: motion-httpd Bound : IPV4 addr: 0.0.0.0 port: 8080
[0] [NTC] [STR] [Jun 13 19:29:00] httpd_run: motion-httpd/mmaltest running, accepting connections
[0] [NTC] [STR] [Jun 13 19:29:00] httpd_run: motion-httpd: waiting for data on 0.0.0.0 port TCP 8080
[1] [NTC] [VID] [Jun 13 19:29:00] MMAL camera component created
[1] [NTC] [ALL] [Jun 13 19:29:00] image_ring_resize: Resizing pre_capture buffer to 1 items
[1] [NTC] [STR] [Jun 13 19:29:00] http_bindsock: motion-stream testing : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [STR] [Jun 13 19:29:00] http_bindsock: motion-stream Bound : IPV4 addr: 0.0.0.0 port: 8081
[1] [NTC] [ALL] [Jun 13 19:29:00] motion_init: Started motion-stream server in port 8081 auth Disabled
[1] [NTC] [ALL] [Jun 13 19:29:00] image_ring_resize: Resizing pre_capture buffer to 9 items
[1] [INF] [ALL] [Jun 13 19:29:01] motion_loop: Lightswitch detected
[1] [NTC] [EVT] [Jun 13 19:29:01] event_newfile: File of type 2 saved to: /run/shm/lastsnap.jpg
[1] [NTC] [EVT] [Jun 13 19:29:01] event_newfile: File of type 2 saved to: /run/shm/lastsnap.JPG
[1] [NTC] [ALL] [Jun 13 19:29:06] motion_loop: fps: 7.572258 idle 2.78% over 0.94%
[1] [NTC] [EVT] [Jun 13 19:29:07] event_new_video FPS 8
[1] [NTC] [ENC] [Jun 13 19:29:07] ffmpeg_open Selected Output FPS 8
[1] [INF] [ENC] [Jun 13 19:29:07] ffmpeg_avcodec_log: Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.tim$
 - flag 24
[1] [NTC] [EVT] [Jun 13 19:29:07] event_newfile: File of type 8 saved to: /run/shm/20160613192907.avi
[1] [NTC] [ALL] [Jun 13 19:29:07] motion_detected: Motion detected - starting event 1
[1] [ERR] [ENC] [Jun 13 19:29:07] ffmpeg_put_frame: Error while writing video frame:
[1] [NTC] [ALL] [Jun 13 19:29:07] motion_loop: Thread exiting
[1] [NTC] [STR] [Jun 13 19:29:07] stream_stop: Closing motion-stream listen socket & active motion-stream sockets
[1] [NTC] [STR] [Jun 13 19:29:07] stream_stop: Closed motion-stream listen socket & active motion-stream sockets
[1] [INF] [ALL] [Jun 13 19:29:07] motion_cleanup: Calling vid_close() from motion_cleanup
[1] [INF] [VID] [Jun 13 19:29:07] vid_close: calling video source cleanup
[1] [ALR] [VID] [Jun 13 19:29:07] MMAL Camera cleanup
[0] [NTC] [ALL] [Jun 13 19:29:08] main: Threads finished
[0] [NTC] [STR] [Jun 13 19:29:08] httpd_run: motion-httpd - Finishing
[0] [NTC] [STR] [Jun 13 19:29:08] httpd_run: motion-httpd Closing
[0] [NTC] [STR] [Jun 13 19:29:08] motion_web_control: motion-httpd thread exit
[0] [NTC] [ALL] [Jun 13 19:29:09] main: Motion terminating
[0] [NTC] [ALL] [Jun 13 19:29:09] motion_remove_pid: Closing logfile (/tmp/motion.log).

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Tue Jun 14, 2016 6:31 am

Hi @mmocco.

I have never seen that error before. Could it be that /run/shm is full? I run a script that moves anything I want to keep out of there onto the sdcard. Or you can change your config to save directly to sdcard. See the item

Code: Select all

target_dir /run/shm

philpugh
Posts: 3
Joined: Tue Sep 04, 2012 12:31 pm

Re: Motion - MMAL camera

Tue Jun 28, 2016 11:56 am

If you can you should learn about how to download and compile code from github. This works for me:
CODE: SELECT ALL
sudo apt-get install -y libjpeg-dev libavformat56 libavformat-dev libavcodec56 libavcodec-dev libavutil54 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev

sudo apt-get install git
sudo apt-get install cmake
git clone https://github.com/raspberrypi/userland
git clone https://github.com/lowflyerUK/motion.git
cd motion/
git checkout mmal-test
USERLANDPATH=/home/pi/userland cmake .
make
After a while you should have a newly created binary "motion" in the directory also called "motion". You can run it with:
CODE: SELECT ALL
/home/pi/motion/motion -c /home/pi/motion/configs/motion-mmalcam-both.conf
This doesn't appear to work.
the make - on last line- says no target
I believe the make should be make motion - which throws an error saying it can't find mysql.h

Anyone got this to work pls?

Phil

philpugh
Posts: 3
Joined: Tue Sep 04, 2012 12:31 pm

Re: Motion - MMAL camera

Tue Jun 28, 2016 3:50 pm

I got the version motion-mmal-lowflyerUK-20151114.tar.gz working on Jessie with RPi2 without much problem.

Like the up-scaled images - but they don't get rotated like the video when rotate set to 180 - haven't tried other settings. The way I have to mount the camera/RPi needs the rotation :)

Any suggestions?

Phil

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Thu Jun 30, 2016 8:16 am

@philpugh Sorry you are having problems compiling. Yes, it works fine for me. Is it possible that the

Code: Select all

USERLANDPATH=/home/pi/userland cmake .
didn't work for some reason? Is the path correct? did you check that the "." is at the end?

To get mmal to rotate everything (big & small stills and as well as movies) you could try changing this line in your config file

Code: Select all

mmalcam_control_params --exposure night -ISO 1600 -rot 90
The -rot parameter should work with 90, 180 or 270 degrees.

Good luck! Please let us know how you get on.

philpugh
Posts: 3
Joined: Tue Sep 04, 2012 12:31 pm

Re: Motion - MMAL camera

Fri Jul 01, 2016 4:27 pm

Thanks lowflyer - the -rot 180 did the trick (once I remembered to comment out the rotate 180 I had in for the 'normal' motion setting!)

As for the compile I will try again on another system - I did cut-and-paste line by line so I think I had it all .

Phil

User avatar
underwhelmd
Posts: 93
Joined: Fri Jul 08, 2016 10:05 pm
Location: East Coast, Canada

Re: Motion - MMAL camera

Fri Jul 08, 2016 10:18 pm

Just signed up to say THANK YOU developers of motion-mmal and contributors to this thread.

I had been running a regular old usb webcam on my Pi 3 with regular motion and that was ok (security cam, pointed outside the house). Today, a v2 Pi Noir cam arrived in the mail and I was anxious to try it out. It was a bit of a struggle, trial and error until I found your build and this thread. It's working now.... a couple tweaks to the config and it'll be perfect.

cheers.

capgun_bandit
Posts: 1
Joined: Thu Aug 04, 2016 1:26 am

Re: Motion - MMAL camera

Thu Aug 04, 2016 1:44 am

First time poster here. I'm a bit of a newbie to Linux/Pi, but I'm looking forward to digging around the board. First of all though, THANK YOU lowflyer! I had been having a helluva time getting motion to work on pi3 with Jessie until I found this thread and your motion build. Thanks for making it so simple!
lowflyer wrote:I have never used daemon mode. Launching it using start-stop-daemon works well for me. I have seen some posts from people about who do use it. I think it should be OK as long as the user is allowed to write the pid file - which you already changed! So long as you can see the log output somewhere it is fine!
I have a hopefully easy question. Everything seems to be working perfectly, but I want to start motion automatically when my pi boots up. I'm not sure how to do the start-stop-daemon, but when I turn on Daemon mode in the config file, I get this:

Code: Select all

[email protected]:~ $ ./motion -c motion-mmalcam-both.conf
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file motion-mmalcam-both.conf
[0] [NTC] [ALL] motion_startup: Motion mmaltest Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (INF)
[0] [NTC] [ALL] become_daemon: Motion going to daemon mode
[0] [ERR] [ALL] create_path: Problem creating directory /var/run/motion: 
[0] [EMG] [ALL] become_daemon: Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid: 
[email protected]:~ $ 
Message from [email protected] at Aug  3 18:27:18 ...
 motion: [0] [EMG] [ALL] become_daemon: Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid:

Broadcast message from [email protected] (Wed 2016-08-03 18:27:18 PDT):

motion[2740]: [0] [EMG] [ALL] become_daemon: Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid:
You mention being allowed to write the PID file, which based on my output, seems like it's probably my issue. Can someone point me in the right direction with that? Thanks!

OGC421
Posts: 2
Joined: Mon Aug 08, 2016 4:56 pm

Re: Motion - MMAL camera

Mon Aug 08, 2016 5:03 pm

Hello,

I have tried to use motion-mmal with my Raspberry pi 2 model B but when I want to execute motion, it says :error while loading shared librairies: libavformat.so.53: cannot open shared object files No such file or directory.
My problem is that I have installed libavformat56 a more recent version of this lib but it doesn't work ...

If someone have any idea

Thanks for all

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Sun Aug 14, 2016 8:28 pm

@capgun_bandit, I put this in my /etc/rc.local file:

Code: Select all

## startup motion
DAEMON='/home/pi/motion/motion'
DAEMONARGS=" -c /home/pi/motion-mmal.conf" # Important : leave space before first argument
start-stop-daemon --start -b --exec $DAEMON --chuid pi --$DAEMONARGS
exit 0
You may need something slightly different if your files are different. Or if you already have something in that file.

Good luck! Let us know how you get on.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Sun Aug 14, 2016 8:37 pm

@OGC421, which version of motion are you running? And which version of rasbian?

My version of motion - which you can get as explained here viewtopic.php?p=864996#p864996 should work with jessie (using libavformat56). Other versions of motion are probably compiled to work only with wheezy (using libavformat53).

Hope this helps.

Rholk
Posts: 5
Joined: Tue Aug 23, 2016 2:07 pm

Re: Motion - MMAL camera

Tue Aug 23, 2016 2:14 pm

Hello,

I am using motion mmal version.
(Don't remember from where i got it, but hash is: c1864ef40617682df60e31cb2d5b8d89)

CPU usage is ~15%, i can give config files, but it is a 820x616 video mode + stills at 4 time res.
I prefer to use such ratio to avoid the ugly crop of the camera.


My problem is that the pi heats much. 50° at idle, (room at 25), but 68° when motion is working.
This makes the pi crash quite oftenly (i have hardware watchdog which reboot it.) ~ once every 2 days. sometime twice a day.

What are your temps?

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Tue Aug 23, 2016 4:10 pm

@Rholk Hi!

That seems quite hot. I run mmal-motion on 3 Raspberry Pis for months between upgrades with never any unintended reboots. One - a very old model B - runs at about 15% cpu at just under 50 degrees CPU, with room temperature about 24 degrees.

Is your Pi in an enclosed box? Can you make some more veltillation?

Are you sure that your power supply is OK? Lots of people have rebooting problems with under powered 5V supplies.

Have you set watchdog to reboot automatically if the Pi gets too hot? If so what threashold did you use and how did you get the sensor data into the watchdog daemon?

Hope this helps.

pmtate
Posts: 5
Joined: Mon Jan 18, 2016 10:00 am

Re: Motion - MMAL camera

Mon Aug 29, 2016 9:29 am

@lowflyer

I successfully compiled https://github.com/lowflyerUK/motion/tree/merge-mmal-2 (thinking it was the latest) for use on a Zero 1.3 Noir v1, but wondered which was the latest branch or what are the differences between the branches:

https://github.com/lowflyerUK/motion/tree/master - presume copy of original dozencrows
https://github.com/lowflyerUK/motion/tree/merge-mmal-1
https://github.com/lowflyerUK/motion/tree/merge-mmal-2
https://github.com/lowflyerUK/motion/tree/mmal-test

thank you and @dozencrows for all your efforts

Paul

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Mon Aug 29, 2016 9:42 am

@pmtate Hi! You are very observant! My merge-mmal branches are some experiments in merging mmal back into the latest motion code. You can follow a discussion about it here https://github.com/dozencrows/motion/pu ... -769752424

I am glad it works for you. Please give any feedback. Thanks.

GekkePrutser
Posts: 36
Joined: Sat Mar 23, 2013 5:09 pm

Re: Motion - MMAL camera

Mon Aug 29, 2016 9:07 pm

Thanks Lowflyer!

I just installed your branch on jessie, it works great!

I just can't use resolutions higher than 640x480 (using the width/height params). I tried using 1296x972 which is a nice full-FOV camera mode, but I get:

Code: Select all

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
Segmentation fault
Is that normal? The quality is acceptable in 640x480 anyway. But the custom housing I printed is aimed a bit too high so I'd like to see the full FOV if possible :) At least until I redesign it.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Mon Aug 29, 2016 9:30 pm

@GekkePrutser Hi! If you go much above 640x480 with an upscale factor of 3 or more, the secondary pictures will be at too high resolution. Or your GPU allocated memory in /boot/config.txt is too low.

If you don't want the secondary pictures, you should adjust your config file to only use the primary (lower resolution) ones. If you increase the log_level parameter to 7 or 8, you might get some useful diagnostic information.

You might want to post the relevant bits of your config file and the gpu_mem parameter in /boot/config.txt.

Hope this helps.

kernel_panik
Posts: 3
Joined: Sun Jun 05, 2016 7:48 am

Re: Motion - MMAL camera

Fri Sep 02, 2016 7:50 am

lowflyer wrote:@pi-anazazi
By the way, just to check, when you said a few posts ago that you have been using an older version of motion with the same config file, did you mean motion, or mmal-motion? You know that mmal-motion is intended only for use with the raspberry pi camera using the direct MMAL API - not /dev/video0 drivers.
Thats interesting.

I'm currently using mmal-motion with the camera module and 2 other USB cameras - and its working fine!
I'm simply using a thread for each device as described in motion.conf.

lowflyer
Posts: 78
Joined: Sat Jun 01, 2013 2:27 pm

Re: Motion - MMAL camera

Fri Sep 02, 2016 5:49 pm

@kernel_panik That sounds super! It would be interesting if you could post the key bits of your config files and tell us which Raspberry Pi it is and the CPU load. Thanks.

OGC421
Posts: 2
Joined: Mon Aug 08, 2016 4:56 pm

Re: Motion - MMAL camera

Sun Sep 04, 2016 2:23 pm

Hi everybody,

I was in hollidays, that's why I didn't answer you.
I will try with your different answers to my question this week, and I will tell you if it works.

Thanks for aller.

GraspAberry
Posts: 2
Joined: Mon Sep 26, 2016 5:00 pm

Re: Motion - MMAL camera

Mon Sep 26, 2016 5:19 pm

Got it to work using @lowflyer 's mod on a Pi Zero with the v2 NoIR camera and Jessie Lite. Had to fiddle with some dependencies, but at the end it worked. Thanks!

Some questions:
  1. I'm only using it as a streaming server to allow me to take a peek at any time without being there. I don't really care about motion detection. I noticed there is a simple control interface at http://[IP]:8080 that allows to pause detection. Is there any config option that, as strange as it sounds, allows to run motion without motion?
  2. How are the mjpeg stream and that control interface served? I didn't see Apache installed. Does the Pi have another internal web server?
  3. Does the streaming server create access logs? Can I check who watched the stream and when?

barry914
Posts: 48
Joined: Sat Aug 20, 2016 7:40 pm

Re: Motion - MMAL camera

Mon Sep 26, 2016 8:07 pm

You can use motion without motion. You set a couple of switches in /etc/motion/motion.conf:

Code: Select all

output_pictures off
and

Code: Select all

ffmpeg_output_movies off

Return to “Camera board”