Installing Motion on Raspberry Pi 2 Jessie


Installing Motion on the Jessie dist is not completely straight forward. When installing it through apt-get like normally, you will see something like the following in the logs:

Note, selecting ‘libjpeg62-turbo’ instead of ‘libjpeg62’

It turns out that the Jessie dist is using a different libjpeg library than the Wheezy dist, which causes some issues when trying to run Motion. The error log will contain the following:

./motion: error while loading shared libraries: cannot open shared object file: No such file or directory

So what you need to do is the following; first install all dependencies manually:

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

Then download and untar this modified Motion release:

tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz

(The source for this package can be found at

And then to start the program, run:

sudo ./motion -c motion-mmalcam-both.conf


33 thoughts on “Installing Motion on Raspberry Pi 2 Jessie”

  1. Cannot get more than 5M out of new 8Meg camera with Motion. will go the 3280 x 2464. Have others got it working? Thanks for the Jessie version.

  2. Thank you so much. After two days of struggle with Jessie and motion, I got to through your tutorial and it resolved my issue in 5 mins. Thank you so much.

  3. Hi Joakim, Firstly i am so happy i found this thread, YOU SAVED ME! secondly i have an application that must be able to start and stop the stream using a php script. (an android phone activates the thread). Can you maybe give me the script command line command to stop it as well ?
    Thanks in regard

    • Hi Neil,
      I guess it depends on how you started it. I don’t have much experience with PHP, but if you have the handle to the process it shouldn’t be too difficult? Otherwise I guess you could look into the php “posix_kill” function?

      • I tried ” sudo service motion stop” which does not work so i am out of ideas to how to stop/kill the process without restarting the pi

  4. Hi again,

    Easiest way for me is to basically start it like you did “sudo ./motion -c motion-mmalcam-both.conf” by invoking the system interface so i can run commands like that.

    If that is how you start it in cmd, how would you stop it from that same cmd ?

    If that makes sense


    • There should be a way to kill the process by grepping the pid from the output of ps (for “motion” in this case), and killing it. Don’t know it by heart though, sorry.

      • Hi thanks, sorry for late reply, but yeah you can search for the process and kill it using pkill and its pid or you can kill a process by name if you want to automate it, that what i did, just killed the process by name. Thanks for the help ! have a great day

  5. Came across this after hours of banging my head against the wall.. only to understand that this is for the Pi camera.. not a ip based camera..

    Has anyone installed motion onto jessie to use just netcams.. I have 2x foscam fi9900’s which work fine with motion on wheezy (my old setup).. upgraded to a rapberry pi 3 and installed a nice clean version of jessie. and now all i can get is jpg’s.. no avi created..

    Any pointers friends ??

  6. Hi being a new pi user I thought a CCTV project may be useful. I successfully installed Motion and was able to view a live stream of our front gate. However when I came to look again I received an error relating to ENOSPC telling me that camera component cannot be enabled. Looking up ENOSPC it indicates that the hard drive is full. I am using a 32GB sd card, Pi3 and Jessie. When viewing the stream it looked like the camera was taking numerous pictures which I wonder is filling up memory.
    Any clues as to what I should do?

    • I’m not sure motion has any built in way to clean out old pictures, but you could create a separate cron job for that. If you just want the live stream you could disable storing pictures in the .conf file, simply set “output_pictures” to “off”.

  7. I get an error
    [1] [ALR] [VID] [Nov 04 18:42:16] mmalcam_start: MMAL Camera using still capture
    [0] [ERR] [ALL] [Nov 04 18:42:51] main: Thread 1 – Watchdog timeout, trying to do a graceful restart

    Any idea on this?

  8. my CamUp -script has:
    ps -C motion -o pid= > $HOME/logs/ # saves proc. id in file

    and CamDown -script has:
    pkill -F $PID
    rm $PID

    among others

  9. hi , i’ve tried your tutorial but i have this error:

    mmal: mmal_vc_component_create: failed to create component ‘’ (1:ENOMEM)
    mmal: mmal_component_create_core: could not create component ‘’ (1)
    mmal: Failed to create camera component
    mmal: main: Failed to create camera component

    • From a quick look online the most common cause seems to be the power adapter not powerful enough to run the camera, or the camera not being properly connected. This is not an issue I’ve had any personal experience with, so I can’t really help.

  10. i configure the “motion-mmalcam-both.conf” and now i don’t have the error again now i have this :

    [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

    but when i do i could not acces to the flux in my navigator..
    please help me i don’t no what to do

  11. phew – worked for me. I already had this working on pi A but after numerous blog posts couldn’t get it working on my Jessie B. This cracked it though. Fantastic. I would love to know what was different about this version of motion and how you changed it!

  12. This procedure still works on my current pi2’s – but does anyone know if there’s a working installation of motion-mmal for the pi3?


  13. 2017-08-16-raspbian-stretch – Has removed more libraries.
    * E: Package ‘libavformat56’ has no installation candidate
    * E: Package ‘libavcodec56’ has no installation candidate
    * E: Package ‘libavutil54’ has no installation candidate
    * E: Package ‘libmysqlclient18’ has no installation candidate
    * E: Package ‘libmysqlclient-dev’ has no installation candi

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.