Raspberry ft and CCTV with Motion !

Want to keep an eye on your pasta cooking ? Monitor your cat where even your girlfriend ? Then I have the solution for you : Motion !

At the outset, after plugging in your webcam usb to your Zhao, Please check if it is well recognized, with the command “lsusb”, must get one of these lines :

Bus 001 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270

It then installs motion :

sudo apt-get install motion

It goes straight in the motion configuration file, where everything goes :

sudo nano /etc/motion/motion.conf

Here are the most important configuration lines :

ATTENTION : In this tuto, I took the liberty to distinguish the side recording (index [SAVE]) images on the pi raspberry and the side STREAMING (index [STREAM]) images on the mini web server provides with motion. So be attentive when the details of a configuration related images is indicated.

  • off daemon

We pass this line to “on” If you want to be able to initiate motion as a daemon, and thus be able to release a terminal. In my case I passed to “off” because like that I can see what is happening live in my terminal.

  • v4l2_palette 6

Is used to configure the type of range you want to use. Each webcam uses a specific palette, Therefore, choosing the right palette in the configuration file. The palette used by default will be the 8 (YU12).

  • width 640height 480

Indicates the height and width of the images recorded and streamed.

  • framerate 50 [SAVE]

This figure shows the number of frames recorded per second. High figure = consumed RAM.

  • threshold 1500 [SAVE]

Number that indicates the number of detected pixels which change to start recording images and/or video.

  • off output_normal

Default line “on”. Just pass it to “off” If we do not wish to use the recording but only the web streaming.

  • quality 75 [SAVE]

Percentage of quality of recorded images.

  • ffmpeg_cap_new off [SAVE]

Default line “on”. Just pass it off if it does not want motion create a video file with all recorded images.

  • ffmpeg_video_codec mpeg4 [SAVE]

Default on line “SWF”. Is used to specify the output video codec for the video file creation. I personally put on mpeg4 in order to obtain a .avi when I activate the registration.

  • target_dir /media/SAVE/Autre/CAM [SAVE]

Specifies the path for recording images and videos. In my case for example, the files are sent on my external hard drive, which allows to record lots of data.

  • webcam_port 8081

The default port for the web server mini.

  • webcam_quality 50 [STREAM]

Percentage of quality streamed images.

  • webcam_maxrate 5 [STREAM]

This figure shows the number of images streamed per second. High figure = consumed RAM.

  • off webcam_localhost

If the parameter is passed to “on”, It allows only local access to the server's stream.

Voilà, Once done, There is more to launch motion :

sudo motion

Don't forget the “sudo”, otherwise motion will launch the default changes to the motion.conf, and so all of your changes will not be taken into account !

Where the palette 8 is not compatible, It shows you a list of compatible palette, you just go change the configuration of the palette in your motion.conf.

If everything is ok, you get something similar to this :

We will therefore on our browser, from an another computer (to take advantage of the off-raspberry fluidity), tape on 192.168.X.X:8081 (the local address of your rasperry) and we are witnessing the magic :

In my case, I have disabled the capture and recording of image files and videos on my hard drive. But if you have enabled, There is more to pass in front of your webcam to see the display of many lines of recordings of images and videos !

Voilà, While motion turns, you find that the resources used by your Raspberry are up, It is for this reason, I advise you to focus on total usage of a raspberry for motion, If like me you are using you to many other services !

You may also like...

  • Emeric

    I put it last week for my part.

    It works well, but it is necessary that I put a little script to enable disable Motion at the beginning of the page.

    Then motion detection … Finally one day …

  • eyd3n

    :]

    The only flaw of motion lies in the fact that the old webcam fail to follow the proposed default palettes. It requires patching and recompiling, things I never managed to do so without errors.

    • Good evening,

      I guess that's damn for my Apple then … 🙁

      Here is what I get by launching motion :

      [0] Processing thread 0 – config file /etc/motion/motion.conf

      [0] Motion 3.2.12 Started

      [0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785

      [0] Thread 1 is from /etc/motion/motion.conf

      [0] motion-httpd/3.2.12 running, accepting connections

      [0] motion-httpd: waiting for data on TCP port 8080

      [1] Thread 1 started

      [1] Cap.driver: “spca561”

      [1] Cap.card: “Camera”

      [1] Cap.bus_info: “USB-bcm2708_usb - 1.2”

      [1] Cap.capabilities = 0 x 85000001

      [1] – VIDEO_CAPTURE

      [1] – READWRITE

      [1] – STREAMING

      [1] Config pallet index 0 (S910) doesn't work.

      [1] Supported pallets:

      [1] 0: S561 (S561)

      [1] 1: GBRG (GBRG)

      [1] Unable to find a compatible palette format.

      [1] IOCTL (VIDIOCGCAP): Inappropriate ioctl for device

      [1] Could not fetch initial image from camera

      [1] Motion continuous using width and height from config file(s)

      I imagine that my webcam doesn't support any palette..

      • eyd3n

        AHA, I had this problem before my C270, that's why this tutorial took two weeks late.

        A google search with “Linux motion S561/GBRG” will lead you to patches from the official website. For my part, I have never managed to patcher/compile properly amended motion installation. After if you are (very) comfortable with linux, I hope that you will find will be able to help you !

  • Good, I saw patches to be applied on the .c but I too want to break my head :p

    Suddenly I found another small software, fswebcam, that works it perfectly with my old logitech !

    I use it as well :

    fswebcam r 800×600 -d/dev/video0 /var/www/webcam/images/webcam.jpg-l 5

    And in/var/www/webcam, I have an index.html file that contains this :

    And this is ! 🙂 Ma webcam prend une photo toutes les 5 seconds and my web page is updated all the 5 also seconds.

    I'm trying to save my order as a service ( to be able to do such a “Service webcamstream start”, who will run the command fswebcam above). Mais je galère un peu 🙂

    Or use cron, but the idea is to be able to disable/enable the command on the fly. If there is another way to make, je suis toute ouïe 🙂

    • Je vends ma came 😀

      http://wp.me/p2W3Jj-iS

      It may help you to do a service

    • eyd3n

      Excellent ! Played well for the service and the web page that is updated all the 5 seconds ! In the end you have recreated the web part of motion with fswebcam and apache :]

  • Jean

    I did the same configuration with the same camera but I have the following result:
    [0] Processing thread 0 – config file /etc/motion/motion.conf
    [0] Motion 3.2.12 Started
    [0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478785
    [0] Thread 1 is from /etc/motion/motion.conf
    [0] Webcam port number 8080 for thread 1 conflicts with the control port
    [0] Webcam feature for thread 1 is disabled.
    [0] httpd bind(): Address already in use
    [1] Thread 1 started
    [0] httpd thread exit
    [1] Cap.driver: “uvcvideo”
    [1] Cap.card: “UVC Camera (046d:0825)”
    [1] Cap.bus_info: “USB-bcm2708_usb - 1.2”
    [1] Cap.capabilities = 0 x 84000001
    [1] – VIDEO_CAPTURE
    [1] – STREAMING
    [1] Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy
    [1] IOCTL (VIDIOCGCAP): Inappropriate ioctl for device
    [1] Could not fetch initial image from camera
    [1] Motion continuous using width and height from config file(s)
    [1] Resizing pre_capture buffer to 1 items
    [1] Retrying until successful connection with camera
    [1] Cap.driver: “uvcvideo”
    [1] Cap.card: “UVC Camera (046d:0825)”
    [1] Cap.bus_info: “USB-bcm2708_usb - 1.2”
    [1] Cap.capabilities = 0 x 84000001
    [1] – VIDEO_CAPTURE
    [1] – STREAMING
    [1] Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy
    [1] IOCTL (VIDIOCGCAP): Inappropriate ioctl for device

    And I did not video on the ip address of the port followed by raspberry…. 🙁
    Can you help me ?

    • The port 8080 is already used by another service or web server :
      [0] Webcam port number 8080 for thread 1 conflicts with the control port
      [0] Webcam feature for thread 1 is disabled.
      [0] httpd bind(): Address already in use

      There must be an error in the config

  • BaloumbA

    Hello,
    being very interested in Mount ca home , I would like to know if the video (images)on the browser can be bet online (use the internet ip address rather than the local)
    Thank you

    • Hello, If the images are visible locally with a web server, just to to create an account with no. - dns and configure its box. There are tutorials on this site for inadyn and nginx. Rest to make pages that will display images

  • Mat

    Super tuto… perfect for putting your foot in the Stirrup.
    I have just a trick or two thing that bother me.
    – I have images that are backed up during motion detection and no video
    – I have a fairly consistent temporal lag between reality and the image available in streaming.

    FYI I am using a logitech CS270.

    Thanks for your help.

  • a

    404 on the two images hosted on screencloud.

  • Pingback: Faire de la vidéosurveillance avec un serveur NAS Synology, un raspberry PI et une vieille webcam | Dev' in Alsace()

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop