- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Motion - MMAL camera
I've had some success writing a new module for Motion that reads frames directly from the Pi camera via the MMAL API. A test binary and config file is available here: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz
This binary is based on Motion SVN trunk at revision 557, and is compiled without MySQL, PostgreSQL or SDL support. Because it's based on trunk and not the 3.2 release branch, the syntax for the config file is different to the available documentation on the Motion wiki.
Next likely steps with this are:
* Tidy up, make command line build work and share the source publically.
* Add an option to support Pi camera settings available in raspivid/raspistill.
* Try optimising some obvious hotspots for the Pi (in reference frame tuning and frame difference code).
This binary is based on Motion SVN trunk at revision 557, and is compiled without MySQL, PostgreSQL or SDL support. Because it's based on trunk and not the 3.2 release branch, the syntax for the config file is different to the available documentation on the Motion wiki.
Next likely steps with this are:
* Tidy up, make command line build work and share the source publically.
* Add an option to support Pi camera settings available in raspivid/raspistill.
* Try optimising some obvious hotspots for the Pi (in reference frame tuning and frame difference code).
Last edited by dozencrows on Sun Jun 23, 2013 10:25 am, edited 1 time in total.
Re: Motion - MMAL camera
Hi !
Would it be to much to ask for a little step by step tutorial or if, by asking, I suggest I would not be able to make it work anyway ?
Even just global hints would do...
Thanks !
Would it be to much to ask for a little step by step tutorial or if, by asking, I suggest I would not be able to make it work anyway ?

Even just global hints would do...
Thanks !
Re: Motion - MMAL camera
thanks for your good job
can you send me your patch and option compilation
I would like compil and generate deb
thanks
can you send me your patch and option compilation
I would like compil and generate deb
thanks
Re: Motion - MMAL camera
How can I test this?
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
@bjornatic - you can find out lots of information about using Motion here: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome. Most of the information should apply to this version of motion, as the only part I have modified is the image capture side (and not compiled in the SQL database support).
Please also read through the example .conf file in the tarball to work out where the syntax differs from the documentation. Note that these differences are not down to me, they've been done by the actual motion developers (see http://www.lavrsen.dk/foswiki/bin/view/Motion/RoadMap). I've added one option "mmalcam_name" that is used to provide the camera's ID - this should be "vc.ril.camera" to work with the Pi camera.
If you're having a specific issue with Motion when using the MMAL camera module, please post details ideally attaching your .conf file and the command line arguments you're using.
@fturiot - the code's not quite ready to deliver as a deb, there's a few changes still to make and I need to test a bit more (e.g. with latest Raspian updates and firmware). I'm planning to put it all up on Github in the next few days so that should give you what you need.
Please also read through the example .conf file in the tarball to work out where the syntax differs from the documentation. Note that these differences are not down to me, they've been done by the actual motion developers (see http://www.lavrsen.dk/foswiki/bin/view/Motion/RoadMap). I've added one option "mmalcam_name" that is used to provide the camera's ID - this should be "vc.ril.camera" to work with the Pi camera.
If you're having a specific issue with Motion when using the MMAL camera module, please post details ideally attaching your .conf file and the command line arguments you're using.
@fturiot - the code's not quite ready to deliver as a deb, there's a few changes still to make and I need to test a bit more (e.g. with latest Raspian updates and firmware). I'm planning to put it all up on Github in the next few days so that should give you what you need.
Re: Motion - MMAL camera
ok thanks,
I have problem with libjbeg with Motion of you compil.
fred
I have problem with libjbeg with Motion of you compil.
fred
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Which version of libjpeg to you have installed?fturiot wrote:ok thanks,
I have problem with libjbeg with Motion of you compil.
fred
When I run this on my Pi:
Code: Select all
find /usr/lib -iname libjpeg*
Code: Select all
/usr/lib/arm-linux-gnueabihf/libjpeg.a
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8.4.0
/usr/lib/arm-linux-gnueabihf/libjpeg.la
/usr/lib/arm-linux-gnueabihf/libjpeg.so.62.0.0
/usr/lib/arm-linux-gnueabihf/libjpeg.so.62
/usr/lib/arm-linux-gnueabihf/libjpeg.so
Re: Motion - MMAL camera
i have this
Code: Select all
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8.4.0
/usr/lib/arm-linux-gnueabihf/libjpeg.so
/usr/lib/arm-linux-gnueabihf/libjpeg.a
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Try installing libjpeg62 via
That's what the test binary is linking against.
Code: Select all
sudo apt-get install libjpeg62
Re: Motion - MMAL camera
yes ok but why not work with lipjpeg8 ?
any raisons ?
thanks for all
fred
any raisons ?
thanks for all
fred
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
It may well work with libjpeg8 - I will have to try it.
libjpeg62 is listed as the dependent package for Debian in the Motion wiki, which is why I used it - see http://www.lavrsen.dk/foswiki/bin/view/ ... or_Install
libjpeg62 is listed as the dependent package for Debian in the Motion wiki, which is why I used it - see http://www.lavrsen.dk/foswiki/bin/view/ ... or_Install
Re: Motion - MMAL camera
ok thanks for all.
Re: Motion - MMAL camera
it's work but 3/4 min i have freezing of soc broadcom and i must reboot.
I test for reduce picture width.
fred
I test for reduce picture width.
fred
Re: Motion - MMAL camera
Hi, Thanks for the updated version, the rotation works well.
I'll leave it running and let you know if I spot any problems.
Craig.
I'll leave it running and let you know if I spot any problems.
Craig.
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
@bjornatic, @yusuk - my apologies - I suspect you're wanting information on how to install and run my test version, which I haven't made clear.
I would recommend trying the following:
1. Install the standard Raspbian motion package via apt-get. This should add all the dependencies.
2. Unzip the motion-mmal tarball into your home folder.
3. Try running motion from your home folder - If that works, you should get the help text for the tool.
4. Then try running it with the provided config file -. This should work - test it out by checking the webcam feed on your Pi on port 8081.
If you have a problem with libjpeg, see the post above about installing libjpeg62.
Let me know if you have any issues - please provide relevant details (e.g. command lines, changes to .conf files, error messages).
I would recommend trying the following:
1. Install the standard Raspbian motion package via apt-get. This should add all the dependencies.
2. Unzip the motion-mmal tarball into your home folder.
3. Try running motion from your home folder -
Code: Select all
./motion -h
4. Then try running it with the provided config file -
Code: Select all
./motion -n -c motion-mmalcam.conf
If you have a problem with libjpeg, see the post above about installing libjpeg62.
Let me know if you have any issues - please provide relevant details (e.g. command lines, changes to .conf files, error messages).
Re: Motion - MMAL camera
This is super nice from you ! Thanks.
I'll try it out asap and let you know.
I'll try it out asap and let you know.

Re: Motion - MMAL camera
great!! motion is working with csi camera module.
I'll feed back after testing more.
My Pi is rev.b and wifi connected.
The latency is less than using vlc. But the framerate is about 1frame per second.
I'll feed back after testing more.
My Pi is rev.b and wifi connected.
The latency is less than using vlc. But the framerate is about 1frame per second.
Re: Motion - MMAL camera
All working this is great !! Thanks again 

Re: Motion - MMAL camera
i have always freeze with motion with model b rev 2 on raspbian last.
I test with minimal raspbian img.
fred
I test with minimal raspbian img.
fred
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Hi fred - sorry to hear you're getting these problems. I personally haven't been experiencing freezes, and have had motion-mmal running for half an hour successfully (then stopped it myself).
Please supply a copy of your motion config file and command line if these are changed, so I can try them.
Are you using the latest Raspbian and firmware updates? What hardware do you have plugged in to your Pi's USB ports?
BTW I'm working on getting the source up to GitHub...
Please supply a copy of your motion config file and command line if these are changed, so I can try them.
Are you using the latest Raspbian and firmware updates? What hardware do you have plugged in to your Pi's USB ports?
BTW I'm working on getting the source up to GitHub...
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Ok, the source is now up on Github at this URL: https://github.com/dozencrows/motion
The master branch is an untouched fork of the original; all the MMAL changes are in the branch mmal-test. Note that this is currently just a drop of the configured source - there's no means provided yet for building the code.
The master branch is an untouched fork of the original; all the MMAL changes are in the branch mmal-test. Note that this is currently just a drop of the configured source - there's no means provided yet for building the code.
Re: Motion - MMAL camera
How do I install the test version on the pi? You indicate there is no ability to make that is build the software, but I assume the prebuilt components are there. What specific steps do I need to follow to install and then proceed to test ...
thanks from a neophyte...
thanks from a neophyte...
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Hi dpguest - please see my post above here for that info: http://www.raspberrypi.org/phpBB3/viewt ... 14#p356814
You can get the tarball containing the binary and config file from the first post in this thread.
I'm working on the command line build for the Github source at the moment - will post when that's available.
You can get the tarball containing the binary and config file from the first post in this thread.
I'm working on the command line build for the Github source at the moment - will post when that's available.
Re: Motion - MMAL camera
thanks much for your prompt reply ... I'll try to follow your instructions.
have a nice day...
have a nice day...
Re: Motion - MMAL camera
i could not find an option to mirror the picture vertically, did i miss it?
thought there was some discussion on the motion site and even a patch, it seems it's not in the actual motion version included...
http://www.lavrsen.dk/foswiki/bin/view/ ... irrorPatch
thought there was some discussion on the motion site and even a patch, it seems it's not in the actual motion version included...
http://www.lavrsen.dk/foswiki/bin/view/ ... irrorPatch