User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Sun Jun 08, 2014 8:51 pm

sjmsoftware wrote:Thanks @dozencrows. Alas, I tried a number of different options setting the resolution in your motion.conf file but I can't get preview or video captures that resemble the partial field of view. If I run raspivid manually from the command line with -w and -h then the resolution is used..
MMAL motion only uses the "width" and "height" configuration options to set the resolution - passing "-w" and "-h" to the mmalcam_control_params won't have any effect as those are not recognised. So you need to change "width" and "height" to set the resolution (and possibly affect FOV).

The supported options for mmalcam_control_params are listed in this source file https://github.com/dozencrows/motion/bl ... mControl.c from line 137.

I notice that you have rotate set to 90 degrees - it's probably fine, given that the rotate happens in software after the camera capture.

jeby6372
Posts: 5
Joined: Tue Jun 10, 2014 10:30 pm

Motion - MMAL camera

Tue Jun 10, 2014 10:36 pm

How to install ? Do I have just to replace the standard /usr/bin/motion executable by the one you provide ?

Thanks in advance.

grats
Posts: 30
Joined: Fri Apr 25, 2014 6:51 am
Location: Colorado, USA

Re: Motion - MMAL camera

Tue Jun 10, 2014 11:36 pm

jeby6372 wrote:How to install ? Do I have just to replace the standard /usr/bin/motion executable by the one you provide ?

Thanks in advance.
yes

apt-get update
apt-get install motion
apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev

wget his version of it
tar zxvf it

mv motion /usr/bin/motion
mv the conf to /etc/motion.conf

should do it right there

intima
Posts: 2
Joined: Wed Jun 11, 2014 2:08 pm

Re: Motion - MMAL camera

Wed Jun 11, 2014 2:33 pm

I'm having trouble getting Motion - MMAL to record to .mov format.

When I set the following in /etc/motion.conf

Code: Select all

ffmpeg_video_codec mov
I get the following error:

Code: Select all

raspberrypi motion: [1] [ERR] [ENC] ffmpeg_open: avcodec_open - could not open codec mov
raspberrypi motion: [1] [ERR] [EVT] event_ffmpeg_newfile: ffopen_open error creating (new) file [/home/pi/MotionTempFiles/2014-06-11-12-17-40.mov]: 
Does anyone know why this is? Is it a simple case of installing a Quicktime library or something that I'm missing?

danger89
Posts: 6
Joined: Sat Jun 21, 2014 10:27 pm

Re: Motion - MMAL camera

Sat Jun 21, 2014 10:29 pm

Please check out this tutorial:
http://www.linux-projects.org/modules/s ... e&artid=16

It works great for me.. :)

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Sun Jun 22, 2014 10:44 am

Nice tutorial! Good to see lots of use cases for the Pi camera in one place.

This thread and its companion http://www.raspberrypi.org/forums/viewt ... 43&t=75240 are about a fork of motion with Pi-specific functionality that can give better framerates than USB or V4L. It takes a little more effort to set up, but does yield good results.

It would be great if your tutorial could be extended to cover that as well, but as it's about V4L use cases I suspect that's not a great fit ;)

sjmsoftware
Posts: 4
Joined: Wed Oct 02, 2013 6:21 pm

Re: Motion - MMAL camera

Sun Jun 22, 2014 11:25 am

dozencrows wrote:
sjmsoftware wrote:Thanks @dozencrows. Alas, I tried a number of different options setting the resolution in your motion.conf file but I can't get preview or video captures that resemble the partial field of view. If I run raspivid manually from the command line with -w and -h then the resolution is used..
MMAL motion only uses the "width" and "height" configuration options to set the resolution - passing "-w" and "-h" to the mmalcam_control_params won't have any effect as those are not recognised. So you need to change "width" and "height" to set the resolution (and possibly affect FOV).

The supported options for mmalcam_control_params are listed in this source file https://github.com/dozencrows/motion/bl ... mControl.c from line 137.

I notice that you have rotate set to 90 degrees - it's probably fine, given that the rotate happens in software after the camera capture.
Thank you @dozencrows. I experimented with a number of different width/height combinations in /etc/motion.conf - some 4:3 and some 16:9 (all of which were divisble by 16) but no matter what I tried I couldn't alter the FOV. The new FOV on the Pi, whilst covering a greater area, now means that areas that were previously in good focus and contained a lot of pixels are now very distant and it's hard to pick out the detail (if you'd like to see the specific images that show this, please PM me).

If anyone else has experienced this and/or knows of a solution I'd be really grateful if it could be shared.

tgwaste
Posts: 41
Joined: Thu Jan 31, 2013 7:15 pm

Re: Motion - MMAL camera

Fri Jul 11, 2014 6:22 am

I made this little app for viewing a video stream from the pi's camera using 'Motion':

https://itunes.apple.com/us/app/picam/id894461908?mt=8

eccentricdyslexic
Posts: 124
Joined: Thu Jul 18, 2013 6:13 am
Location: Uttoxeter, Staffordshire, UK

Re: Motion - MMAL camera

Fri Jul 11, 2014 6:26 am

Nice job!

Steve

biltong
Posts: 1
Joined: Sat Jul 12, 2014 9:26 pm

Re: Motion - MMAL camera

Sun Jul 13, 2014 8:13 am

hi @dozencrows, thanks for this release. I have tested it with the raspberry pi spy camera (https://www.adafruit.com/products/1937) but it hangs and fails. raspistill works okay, and the stable release of motion-mmal works okay too.

I have put up the logs and my config here: http://pastebin.com/tyA1eTHp

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Sun Jul 13, 2014 9:51 pm

Many thanks, @biltong. If you're using a version of Raspbian from April this year or later, there's an issue with the Pi firmware that causes motion to hang if you have the secondary buffer jpeg quality set to any other value than zero.

There should be a fix coming to the firmware in the very near future.

Jakein
Posts: 7
Joined: Thu Jul 24, 2014 9:36 am

Re: Motion - MMAL camera

Thu Aug 07, 2014 12:03 am

Hi folks!

I have a little question if anyone could help. I was looking for a way to output the Raspberry camera's video as a live preview to the display simultaneously while Motion is using it but couldn't find a way so far. Even the mmalcam_control_params is not working with "--preview" as it only supports some of the options it seems. Can anyone think of a way to do this with minimal CPU resources? Having OSD information from Motion would be a plus but I can also do without that. Any pointers would be appreciated. Thank you!

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Fri Aug 08, 2014 12:23 pm

I've had a look at the preview setup in raspivid, and it's done all via the MMAL API. There's a "preview" MMAL component that gets created and configured, then connected to the preview output on the camera component. This preview component looks to be responsible for getting the image on screen, without any further direct work by the application.

It doesn't look like a great deal of work to set up and test out - I'll add it to my TODO list for motion mmal, and post back when I've tried it - unless anyone beats me to it!

As preview is a MMAL/OpenMAX component, it is hard to know how good performance will be without trying it. If relies significantly on the CPU to process buffers and perform rendering (e.g. via OpenGL) then the frame rate will likely not be very good (due to motion's CPU hungry image processing) and will also probably slow down the whole app.

If preview is more of a GPU-side component (e.g. somehow outputting preview buffers more directly via the video hardware) then it may work pretty well! In that case, there's also the risk that motion's rate of grabbing image buffers might impact on preview frame rate.

In either case, I don't think there's a way of adding any custom OSD information to the preview (though there has been some posts about that possibility elsewhere in the camera forum) as it's behind the MMAL API.

It's going to be a case of suck-it-and-see, I think.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6895
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Motion - MMAL camera

Fri Aug 08, 2014 12:39 pm

If you use the video_render component and a mmal_connection with the MMAL_CONNECTION_FLAG_TUNNELLING flag from camera to video_render, then all the work is done on the GPU, and the rendering is done in hardware (not GL). It should have very little impact on motion and processing that is doing.

Basic overlays are now available (32 chars of text). I'm hoping to revisit the subject and tweak, but not guaranteed that I'll get to it.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Sat Aug 09, 2014 4:41 pm

That sounds great - certainly worth a try!

Jakein
Posts: 7
Joined: Thu Jul 24, 2014 9:36 am

Re: Motion - MMAL camera

Mon Aug 11, 2014 9:26 am

Most of what was just said flew right over my head haha! But sounds like it's doable from what I gather. I really hope someone could implement this soon as it would solve a big problem I'm facing right now and i'm sure many others would find it useful. Please keep us posted guys.

dkyancey
Posts: 2
Joined: Thu Aug 14, 2014 9:06 pm

Re: Motion - MMAL camera

Mon Aug 18, 2014 5:00 pm

I'm getting only timelapse and not motion-triggered video. I have not been able to find the correct setting to turn off timelapse video. I want to only capture motion-triggered video. What settings do I need to change?

Codex.
Posts: 3
Joined: Tue Aug 12, 2014 5:55 am

Re: Motion - MMAL camera

Fri Nov 21, 2014 2:47 am

Hey all

I haven't had much luck finding information on how to adjust the sensitivity of the motion captured

Can anyone please advise the setting to adjust this?

I keep getting 30 videos a day of a cloud going over the sun and dimming the room it's in enough to trigger it x____x

hydra3333
Posts: 107
Joined: Thu Jan 10, 2013 11:48 pm

stopping and starting

Fri Dec 12, 2014 8:04 am

Hello a few Queryies:
the daemon is "on" and it is started.
How to stop motion ? Like this ?

Code: Select all

#!/bin/sh
sudo ps -ef | grep motion | awk '{print $2}' | xargs kill
How to restart it (without rebooting) given that the daemon settings are active in the .conf ?

Also, it generates .avi files for setting msmpeg4; I was expecting h264 or mp4 files, am I doing something wrong ?

markmagness
Posts: 7
Joined: Tue Dec 23, 2014 2:44 pm

Re: Motion - MMAL camera

Tue Dec 23, 2014 2:50 pm

Hi,
I am running motion to stream video on my network. I have it set up so that when a motion is detected, it runs a perl script to send prowl notifications to my iPhone and records video. When the video finishes recording, a wput command is run which sends the video file to an FTP server. This all works fine as is.
Yesterday I attempted to switch to using the secondary buffer for streaming and video recording; it works fine for streaming, however when I set up to use it for video recording, my perl script and wput command dont seem to run. Can you help?

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: stopping and starting

Tue Dec 23, 2014 6:19 pm

hydra3333 wrote:How to stop motion ? Like this ?

Code: Select all

#!/bin/sh
sudo ps -ef | grep motion | awk '{print $2}' | xargs kill
Yes, that's generally how I would do it. I usually use the -quit option on kill.
hydra3333 wrote:How to restart it (without rebooting) given that the daemon settings are active in the .conf ?
As you have the daemon setting in the config file, you should just try running motion again - that should restart it as a daemon. If you don't want to run it as a daemon on restart, add -n.
hydra3333 wrote:Also, it generates .avi files for setting msmpeg4; I was expecting h264 or mp4 files, am I doing something wrong ?
.AVI is correct - that's the container format, not the type of codec used for compression. See http://en.wikipedia.org/wiki/Audio_Video_Interleave

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Tue Dec 23, 2014 6:28 pm

markmagness wrote:Hi,
...Yesterday I attempted to switch to using the secondary buffer for streaming and video recording; it works fine for streaming, however when I set up to use it for video recording, my perl script and wput command dont seem to run. Can you help?
I suspect that you're asking your Pi to do too much - it may well be spending all its CPU time encoding the movies from the secondary buffer. The video encoding pipeline isn't optimised for the Pi - it will do that in software, usually via ffmpeg. If you've set the secondary buffer to be higher resolution than the primary buffer (mmalcam_secondary_buffer_upscale set to greater than 1) then it will have to work even harder because of the greater number of pixels to be processed.

However, before following through on that conclusion, please try increasing the log level (log_level in the config file) to 7 and run motion again - and take a look in the log file (specified by logfile in the config file) and see if you can see it writing movie data and/or attempting to run your perl script.

andies
Posts: 140
Joined: Mon Nov 11, 2013 8:12 pm
Location: Berlin

Re: stopping and starting

Wed Dec 24, 2014 7:17 am

dozencrows wrote:
hydra3333 wrote:How to stop motion ? Like this ?

Code: Select all

#!/bin/sh
sudo ps -ef | grep motion | awk '{print $2}' | xargs kill
Yes, that's generally how I would do it. I usually use the -quit option on kill.
Is there any simpler procedure/button to stop (and not kill) motion? I am thinking of a home surveillance system that recognizes myself (for example, by looking at nmap and searching for my iPhone) that will stop motion if I am at home and restarts it when I am gone.

Or is killing and restarting the best option? (I am a former Windows user and hesitate to kill something, the wording already irritates me although I am not vegan :roll: )

Edit: I was not precise enough. I still want the streaming functionality intact but only the motion detection and recording feature stopped.
raspberry B, Noir camera, Mac Book Air, iPhone, Bezzera

User avatar
dozencrows
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion - MMAL camera

Wed Dec 24, 2014 10:39 am

There is a web interface to motion gives you that kind of control. If you set webcontrol_port in the config file (e.g. to 8080) you can then connect via web browser (or your own program) to that port and control motion's behaviour. You'll also need to set webcontrol_localhost to 'off' if you want to connect remotely to the Pi.

See http://www.lavrsen.dk/foswiki/bin/view/ ... _with_http for more info - but bear in mind that the MMAL motion config option names are a little different; use the comments in the supplied exampe conf file to guide you.

You can use also use apps like https://github.com/dozencrows/MotionWidget to manually disable and enable motion detection while keeping streaming going from a smartphone.

lastfreenick
Posts: 3
Joined: Tue Jan 13, 2015 1:09 pm

Re: Motion - MMAL camera

Tue Jan 13, 2015 1:26 pm

Hi dozencrows,

can you please have a look at ccrisan's project motionpi:
https://github.com/ccrisan/motionPie
It would be super awesome if you two could cooperate on getting motion mmal into Motionpi. Motionpi itself works very well except when used with the pi cam, I guess your work in motion mmal could iron out the poor performance of the pi cam in regular motion.

Return to “Camera board”