├── Dockerfile ├── README.md ├── motion.conf └── run.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM resin/rpi-raspbian:latest 2 | 3 | RUN apt-get update && apt-get upgrade && apt-get install motion 4 | RUN mkdir /mnt/motion && chown motion /mnt/motion 5 | COPY motion.conf /etc/motion/motion.conf 6 | 7 | VOLUME /mnt/motion 8 | EXPOSE 8081 9 | ENTRYPOINT ["motion"] 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker image for motion camera on Raspberry Pi 2 | 3 | This runs a motion-detecting camera connected to a Raspberry Pi. The videos are saved into a folder on the host machine (i.e. outside of the Docker container), and can be streamed over the network too. 4 | 5 | 6 | ## Building the image 7 | 8 | docker build . -t lazyatom/rpi-motion 9 | 10 | 11 | ## Running 12 | 13 | If you're happy with the defaults, you can run this using the included script: 14 | 15 | ./run.sh 16 | 17 | This will connect to a webcam via `/dev/video0`, create and mount the video directory in a directory called `videos` within the current cdirectory, and start running as a daemon. 18 | 19 | If you need anything more customized, then you can use the commands inside `run.sh` as the basis for that. 20 | 21 | -------------------------------------------------------------------------------- /motion.conf: -------------------------------------------------------------------------------- 1 | # Rename this distribution example file to motion.conf 2 | # 3 | # This config file was generated by motion 3.2.12+git20140228 4 | 5 | 6 | ############################################################ 7 | # Daemon 8 | ############################################################ 9 | 10 | # Start in daemon (background) mode and release terminal (default: off) 11 | daemon off 12 | 13 | # File to store the process ID, also called pid file. (default: not defined) 14 | process_id_file /var/run/motion/motion.pid 15 | 16 | ############################################################ 17 | # Basic Setup Mode 18 | ############################################################ 19 | 20 | # Start in Setup-Mode, daemon disabled. (default: off) 21 | setup_mode off 22 | 23 | 24 | # Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined) 25 | ;logfile /tmp/motion.log 26 | 27 | # Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC) 28 | log_level 6 29 | 30 | # Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL) 31 | log_type all 32 | 33 | ########################################################### 34 | # Capture device options 35 | ############################################################ 36 | 37 | # Videodevice to be used for capturing (default /dev/video0) 38 | # for FreeBSD default is /dev/bktr0 39 | videodevice /dev/video0 40 | 41 | # v4l2_palette allows to choose preferable palette to be use by motion 42 | # to capture from those supported by your videodevice. (default: 17) 43 | # E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and 44 | # V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG. 45 | # Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8 46 | # instead. 47 | # 48 | # Values : 49 | # V4L2_PIX_FMT_SN9C10X : 0 'S910' 50 | # V4L2_PIX_FMT_SBGGR16 : 1 'BYR2' 51 | # V4L2_PIX_FMT_SBGGR8 : 2 'BA81' 52 | # V4L2_PIX_FMT_SPCA561 : 3 'S561' 53 | # V4L2_PIX_FMT_SGBRG8 : 4 'GBRG' 54 | # V4L2_PIX_FMT_SGRBG8 : 5 'GRBG' 55 | # V4L2_PIX_FMT_PAC207 : 6 'P207' 56 | # V4L2_PIX_FMT_PJPG : 7 'PJPG' 57 | # V4L2_PIX_FMT_MJPEG : 8 'MJPEG' 58 | # V4L2_PIX_FMT_JPEG : 9 'JPEG' 59 | # V4L2_PIX_FMT_RGB24 : 10 'RGB3' 60 | # V4L2_PIX_FMT_SPCA501 : 11 'S501' 61 | # V4L2_PIX_FMT_SPCA505 : 12 'S505' 62 | # V4L2_PIX_FMT_SPCA508 : 13 'S508' 63 | # V4L2_PIX_FMT_UYVY : 14 'UYVY' 64 | # V4L2_PIX_FMT_YUYV : 15 'YUYV' 65 | # V4L2_PIX_FMT_YUV422P : 16 '422P' 66 | # V4L2_PIX_FMT_YUV420 : 17 'YU12' 67 | # 68 | v4l2_palette 17 69 | 70 | # Tuner device to be used for capturing using tuner as source (default /dev/tuner0) 71 | # This is ONLY used for FreeBSD. Leave it commented out for Linux 72 | ; tunerdevice /dev/tuner0 73 | 74 | # The video input to be used (default: -1) 75 | # Should normally be set to 0 or 1 for video/TV cards, and -1 for USB cameras 76 | input -1 77 | 78 | # The video norm to use (only for video capture and TV tuner cards) 79 | # Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) 80 | norm 0 81 | 82 | # The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) 83 | frequency 0 84 | 85 | # Rotate image this number of degrees. The rotation affects all saved images as 86 | # well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270. 87 | rotate 0 88 | 89 | # Image width (pixels). Valid range: Camera dependent, default: 352 90 | width 640 91 | 92 | # Image height (pixels). Valid range: Camera dependent, default: 288 93 | height 480 94 | 95 | # Maximum number of frames to be captured per second. 96 | # Valid range: 2-100. Default: 100 (almost no limit). 97 | framerate 30 98 | 99 | # Minimum time in seconds between capturing picture frames from the camera. 100 | # Default: 0 = disabled - the capture rate is given by the camera framerate. 101 | # This option is used when you want to capture images at a rate lower than 2 per second. 102 | minimum_frame_time 0 103 | 104 | # URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///) 105 | # Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined 106 | ; netcam_url value 107 | 108 | # Username and password for network camera (only if required). Default: not defined 109 | # Syntax is user:password 110 | ; netcam_userpass value 111 | 112 | # The setting for keep-alive of network socket, should improve performance on compatible net cameras. 113 | # off: The historical implementation using HTTP/1.0, closing the socket after each http request. 114 | # force: Use HTTP/1.0 requests with keep alive header to reuse the same connection. 115 | # on: Use HTTP/1.1 requests that support keep alive as default. 116 | # Default: off 117 | netcam_keepalive off 118 | 119 | # URL to use for a netcam proxy server, if required, e.g. "http://myproxy". 120 | # If a port number other than 80 is needed, use "http://myproxy:1234". 121 | # Default: not defined 122 | ; netcam_proxy value 123 | 124 | # Set less strict jpeg checks for network cameras with a poor/buggy firmware. 125 | # Default: off 126 | netcam_tolerant_check off 127 | 128 | # Let motion regulate the brightness of a video device (default: off). 129 | # The auto_brightness feature uses the brightness option as its target value. 130 | # If brightness is zero auto_brightness will adjust to average brightness value 128. 131 | # Only recommended for cameras without auto brightness 132 | auto_brightness off 133 | 134 | # Set the initial brightness of a video device. 135 | # If auto_brightness is enabled, this value defines the average brightness level 136 | # which Motion will try and adjust to. 137 | # Valid range 0-255, default 0 = disabled 138 | brightness 0 139 | 140 | # Set the contrast of a video device. 141 | # Valid range 0-255, default 0 = disabled 142 | contrast 0 143 | 144 | # Set the saturation of a video device. 145 | # Valid range 0-255, default 0 = disabled 146 | saturation 0 147 | 148 | # Set the hue of a video device (NTSC feature). 149 | # Valid range 0-255, default 0 = disabled 150 | hue 0 151 | 152 | 153 | ############################################################ 154 | # Round Robin (multiple inputs on same video device name) 155 | ############################################################ 156 | 157 | # Number of frames to capture in each roundrobin step (default: 1) 158 | roundrobin_frames 1 159 | 160 | # Number of frames to skip before each roundrobin step (default: 1) 161 | roundrobin_skip 1 162 | 163 | # Try to filter out noise generated by roundrobin (default: off) 164 | switchfilter off 165 | 166 | 167 | ############################################################ 168 | # Motion Detection Settings: 169 | ############################################################ 170 | 171 | # Threshold for number of changed pixels in an image that 172 | # triggers motion detection (default: 1500) 173 | threshold 2000 174 | 175 | # Automatically tune the threshold down if possible (default: off) 176 | threshold_tune off 177 | 178 | # Noise threshold for the motion detection (default: 32) 179 | noise_level 32 180 | 181 | # Automatically tune the noise threshold (default: on) 182 | noise_tune on 183 | 184 | # Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined) 185 | # Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid. 186 | # (l)abeling must only be used once and the 'l' must be the last letter. 187 | # Comment out to disable 188 | despeckle_filter EedDl 189 | 190 | # Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3 191 | # A script (on_area_detected) is started immediately when motion is 4 5 6 192 | # detected in one of the given areas, but only once during an event. 7 8 9 193 | # One or more areas can be specified with this option. Take care: This option 194 | # does NOT restrict detection to these areas! (Default: not defined) 195 | ; area_detect value 196 | 197 | # PGM file to use as a sensitivity mask. 198 | # Full path name to. (Default: not defined) 199 | ; mask_file value 200 | 201 | # Dynamically create a mask file during operation (default: 0) 202 | # Adjust speed of mask changes from 0 (off) to 10 (fast) 203 | smart_mask_speed 0 204 | 205 | # Ignore sudden massive light intensity changes given as a percentage of the picture 206 | # area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled 207 | lightswitch 0 208 | 209 | # Picture frames must contain motion at least the specified number of frames 210 | # in a row before they are detected as true motion. At the default of 1, all 211 | # motion is detected. Valid range: 1 to thousands, recommended 1-5 212 | minimum_motion_frames 1 213 | 214 | # Specifies the number of pre-captured (buffered) pictures from before motion 215 | # was detected that will be output at motion detection. 216 | # Recommended range: 0 to 5 (default: 0) 217 | # Do not use large values! Large values will cause Motion to skip video frames and 218 | # cause unsmooth movies. To smooth movies use larger values of post_capture instead. 219 | pre_capture 2 220 | 221 | # Number of frames to capture after motion is no longer detected (default: 0) 222 | post_capture 5 223 | 224 | # Event Gap is the seconds of no motion detection that triggers the end of an event. 225 | # An event is defined as a series of motion images taken within a short timeframe. 226 | # Recommended value is 60 seconds (Default). The value -1 is allowed and disables 227 | # events causing all Motion to be written to one single movie file and no pre_capture. 228 | # If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An 229 | # event ends right after no more motion is detected and post_capture is over. 230 | event_gap 60 231 | 232 | # Maximum length in seconds of a movie 233 | # When value is exceeded a new movie file is created. (Default: 0 = infinite) 234 | max_movie_time 0 235 | 236 | # Always save images even if there was no motion (default: off) 237 | emulate_motion off 238 | 239 | 240 | ############################################################ 241 | # Image File Output 242 | ############################################################ 243 | 244 | # Output 'normal' pictures when motion is detected (default: on) 245 | # Valid values: on, off, first, best, center 246 | # When set to 'first', only the first picture of an event is saved. 247 | # Picture with most motion of an event is saved when set to 'best'. 248 | # Picture with motion nearest center of picture is saved when set to 'center'. 249 | # Can be used as preview shot for the corresponding movie. 250 | output_pictures off 251 | 252 | # Output pictures with only the pixels moving object (ghost images) (default: off) 253 | output_debug_pictures off 254 | 255 | # The quality (in percent) to be used by the jpeg compression (default: 75) 256 | quality 75 257 | 258 | # Type of output images 259 | # Valid values: jpeg, ppm (default: jpeg) 260 | picture_type jpeg 261 | 262 | ############################################################ 263 | # FFMPEG related options 264 | # Film (movies) file output, and deinterlacing of the video input 265 | # The options movie_filename and timelapse_filename are also used 266 | # by the ffmpeg feature 267 | ############################################################ 268 | 269 | # Use ffmpeg to encode movies in realtime (default: off) 270 | ffmpeg_output_movies on 271 | 272 | # Use ffmpeg to make movies with only the pixels moving 273 | # object (ghost images) (default: off) 274 | ffmpeg_output_debug_movies off 275 | 276 | # Use ffmpeg to encode a timelapse movie 277 | # Default value 0 = off - else save frame every Nth second 278 | ffmpeg_timelapse 0 279 | 280 | # The file rollover mode of the timelapse video 281 | # Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual 282 | ffmpeg_timelapse_mode daily 283 | 284 | # Bitrate to be used by the ffmpeg encoder (default: 400000) 285 | # This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled) 286 | ffmpeg_bps 500000 287 | 288 | # Enables and defines variable bitrate for the ffmpeg encoder. 289 | # ffmpeg_bps is ignored if variable bitrate is enabled. 290 | # Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, 291 | # or the range 2 - 31 where 2 means best quality and 31 is worst. 292 | ffmpeg_variable_bitrate 0 293 | 294 | # Codec to used by ffmpeg for the video compression. 295 | # Timelapse mpegs are always made in mpeg1 format independent from this option. 296 | # Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4. 297 | # mpeg1 - gives you files with extension .mpg 298 | # mpeg4 or msmpeg4 - gives you files with extension .avi 299 | # msmpeg4 is recommended for use with Windows Media Player because 300 | # it requires no installation of codec on the Windows client. 301 | # swf - gives you a flash film with extension .swf 302 | # flv - gives you a flash video with extension .flv 303 | # ffv1 - FF video codec 1 for Lossless Encoding ( experimental ) 304 | # mov - QuickTime ( testing ) 305 | # ogg - Ogg/Theora ( testing ) 306 | ffmpeg_video_codec mpeg4 307 | 308 | # Use ffmpeg to deinterlace video. Necessary if you use an analog camera 309 | # and see horizontal combing on moving objects in video or pictures. 310 | # (default: off) 311 | ffmpeg_deinterlace off 312 | 313 | ############################################################ 314 | # SDL Window 315 | ############################################################ 316 | 317 | # Number of motion thread to show in SDL Window (default: 0 = disabled) 318 | sdl_threadnr 0 319 | 320 | ############################################################ 321 | # External pipe to video encoder 322 | # Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only. 323 | # The options movie_filename and timelapse_filename are also used 324 | # by the ffmpeg feature 325 | ############################################################# 326 | 327 | # Bool to enable or disable extpipe (default: off) 328 | use_extpipe off 329 | 330 | # External program (full path and opts) to pipe raw video to 331 | # Generally, use '-' for STDIN... 332 | ;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps 333 | 334 | 335 | 336 | ############################################################ 337 | # Snapshots (Traditional Periodic Webcam File Output) 338 | ############################################################ 339 | 340 | # Make automated snapshot every N seconds (default: 0 = disabled) 341 | snapshot_interval 0 342 | 343 | 344 | ############################################################ 345 | # Text Display 346 | # %Y = year, %m = month, %d = date, 347 | # %H = hour, %M = minute, %S = second, %T = HH:MM:SS, 348 | # %v = event, %q = frame number, %t = thread (camera) number, 349 | # %D = changed pixels, %N = noise level, \n = new line, 350 | # %i and %J = width and height of motion area, 351 | # %K and %L = X and Y coordinates of motion center 352 | # %C = value defined by text_event - do not use with text_event! 353 | # You can put quotation marks around the text to allow 354 | # leading spaces 355 | ############################################################ 356 | 357 | # Locate and draw a box around the moving object. 358 | # Valid values: on, off, preview (default: off) 359 | # Set to 'preview' will only draw a box in preview_shot pictures. 360 | locate_motion_mode off 361 | 362 | # Set the look and style of the locate box if enabled. 363 | # Valid values: box, redbox, cross, redcross (default: box) 364 | # Set to 'box' will draw the traditional box. 365 | # Set to 'redbox' will draw a red box. 366 | # Set to 'cross' will draw a little cross to mark center. 367 | # Set to 'redcross' will draw a little red cross to mark center. 368 | locate_motion_style box 369 | 370 | # Draws the timestamp using same options as C function strftime(3) 371 | # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock 372 | # Text is placed in lower right corner 373 | text_right %Y-%m-%d\n%T-%q 374 | 375 | # Draw a user defined text on the images using same options as C function strftime(3) 376 | # Default: Not defined = no text 377 | # Text is placed in lower left corner 378 | ; text_left CAMERA %t 379 | 380 | # Draw the number of changed pixed on the images (default: off) 381 | # Will normally be set to off except when you setup and adjust the motion settings 382 | # Text is placed in upper right corner 383 | text_changes off 384 | 385 | # This option defines the value of the special event conversion specifier %C 386 | # You can use any conversion specifier in this option except %C. Date and time 387 | # values are from the timestamp of the first image in the current event. 388 | # Default: %Y%m%d%H%M%S 389 | # The idea is that %C can be used filenames and text_left/right for creating 390 | # a unique identifier for each event. 391 | text_event %Y%m%d%H%M%S 392 | 393 | # Draw characters at twice normal size on images. (default: off) 394 | text_double off 395 | 396 | 397 | # Text to include in a JPEG EXIF comment 398 | # May be any text, including conversion specifiers. 399 | # The EXIF timestamp is included independent of this text. 400 | ;exif_text %i%J/%K%L 401 | 402 | ############################################################ 403 | # Target Directories and filenames For Images And Films 404 | # For the options snapshot_, picture_, movie_ and timelapse_filename 405 | # you can use conversion specifiers 406 | # %Y = year, %m = month, %d = date, 407 | # %H = hour, %M = minute, %S = second, 408 | # %v = event, %q = frame number, %t = thread (camera) number, 409 | # %D = changed pixels, %N = noise level, 410 | # %i and %J = width and height of motion area, 411 | # %K and %L = X and Y coordinates of motion center 412 | # %C = value defined by text_event 413 | # Quotation marks round string are allowed. 414 | ############################################################ 415 | 416 | # Target base directory for pictures and films 417 | # Recommended to use absolute path. (Default: current working directory) 418 | target_dir /mnt/motion 419 | 420 | # File path for snapshots (jpeg or ppm) relative to target_dir 421 | # Default: %v-%Y%m%d%H%M%S-snapshot 422 | # Default value is equivalent to legacy oldlayout option 423 | # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot 424 | # File extension .jpg or .ppm is automatically added so do not include this. 425 | # Note: A symbolic link called lastsnap.jpg created in the target_dir will always 426 | # point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' 427 | snapshot_filename %v-%Y%m%d%H%M%S-snapshot 428 | 429 | # File path for motion triggered images (jpeg or ppm) relative to target_dir 430 | # Default: %v-%Y%m%d%H%M%S-%q 431 | # Default value is equivalent to legacy oldlayout option 432 | # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q 433 | # File extension .jpg or .ppm is automatically added so do not include this 434 | # Set to 'preview' together with best-preview feature enables special naming 435 | # convention for preview shots. See motion guide for details 436 | picture_filename %v-%Y%m%d%H%M%S-%q 437 | 438 | # File path for motion triggered ffmpeg films (movies) relative to target_dir 439 | # Default: %v-%Y%m%d%H%M%S 440 | # Default value is equivalent to legacy oldlayout option 441 | # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S 442 | # File extension .mpg or .avi is automatically added so do not include this 443 | # This option was previously called ffmpeg_filename 444 | movie_filename %v-%Y%m%d%H%M%S 445 | 446 | # File path for timelapse movies relative to target_dir 447 | # Default: %Y%m%d-timelapse 448 | # Default value is near equivalent to legacy oldlayout option 449 | # For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse 450 | # File extension .mpg is automatically added so do not include this 451 | timelapse_filename %Y%m%d-timelapse 452 | 453 | ############################################################ 454 | # Global Network Options 455 | ############################################################ 456 | # Enable or disable IPV6 for http control and stream (default: off ) 457 | ipv6_enabled off 458 | 459 | ############################################################ 460 | # Live Stream Server 461 | ############################################################ 462 | 463 | # The mini-http server listens to this port for requests (default: 0 = disabled) 464 | stream_port 8081 465 | 466 | # Quality of the jpeg (in percent) images produced (default: 50) 467 | stream_quality 50 468 | 469 | # Output frames at 1 fps when no motion is detected and increase to the 470 | # rate given by stream_maxrate when motion is detected (default: off) 471 | stream_motion off 472 | 473 | # Maximum framerate for stream streams (default: 1) 474 | stream_maxrate 5 475 | 476 | # Restrict stream connections to localhost only (default: on) 477 | stream_localhost off 478 | 479 | # Limits the number of images per connection (default: 0 = unlimited) 480 | # Number can be defined by multiplying actual stream rate by desired number of seconds 481 | # Actual stream rate is the smallest of the numbers framerate and stream_maxrate 482 | stream_limit 0 483 | 484 | # Set the authentication method (default: 0) 485 | # 0 = disabled 486 | # 1 = Basic authentication 487 | # 2 = MD5 digest (the safer authentication) 488 | stream_auth_method 0 489 | 490 | # Authentication for the stream. Syntax username:password 491 | # Default: not defined (Disabled) 492 | ; stream_authentication username:password 493 | 494 | 495 | ############################################################ 496 | # HTTP Based Control 497 | ############################################################ 498 | 499 | # TCP/IP port for the http server to listen on (default: 0 = disabled) 500 | webcontrol_port 8080 501 | 502 | # Restrict control connections to localhost only (default: on) 503 | webcontrol_localhost on 504 | 505 | # Output for http server, select off to choose raw text plain (default: on) 506 | webcontrol_html_output on 507 | 508 | # Authentication for the http based control. Syntax username:password 509 | # Default: not defined (Disabled) 510 | ; webcontrol_authentication username:password 511 | 512 | 513 | ############################################################ 514 | # Tracking (Pan/Tilt) 515 | ############################################################# 516 | 517 | # Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo) 518 | # The generic type enables the definition of motion center and motion size to 519 | # be used with the conversion specifiers for options like on_motion_detected 520 | track_type 0 521 | 522 | # Enable auto tracking (default: off) 523 | track_auto off 524 | 525 | # Serial port of motor (default: none) 526 | ;track_port /dev/ttyS0 527 | 528 | # Motor number for x-axis (default: 0) 529 | ;track_motorx 0 530 | 531 | # Set motorx reverse (default: 0) 532 | ;track_motorx_reverse 0 533 | 534 | # Motor number for y-axis (default: 0) 535 | ;track_motory 1 536 | 537 | # Set motory reverse (default: 0) 538 | ;track_motory_reverse 0 539 | 540 | # Maximum value on x-axis (default: 0) 541 | ;track_maxx 200 542 | 543 | # Minimum value on x-axis (default: 0) 544 | ;track_minx 50 545 | 546 | # Maximum value on y-axis (default: 0) 547 | ;track_maxy 200 548 | 549 | # Minimum value on y-axis (default: 0) 550 | ;track_miny 50 551 | 552 | # Center value on x-axis (default: 0) 553 | ;track_homex 128 554 | 555 | # Center value on y-axis (default: 0) 556 | ;track_homey 128 557 | 558 | # ID of an iomojo camera if used (default: 0) 559 | track_iomojo_id 0 560 | 561 | # Angle in degrees the camera moves per step on the X-axis 562 | # with auto-track (default: 10) 563 | # Currently only used with pwc type cameras 564 | track_step_angle_x 10 565 | 566 | # Angle in degrees the camera moves per step on the Y-axis 567 | # with auto-track (default: 10) 568 | # Currently only used with pwc type cameras 569 | track_step_angle_y 10 570 | 571 | # Delay to wait for after tracking movement as number 572 | # of picture frames (default: 10) 573 | track_move_wait 10 574 | 575 | # Speed to set the motor to (stepper motor option) (default: 255) 576 | track_speed 255 577 | 578 | # Number of steps to make (stepper motor option) (default: 40) 579 | track_stepsize 40 580 | 581 | 582 | ############################################################ 583 | # External Commands, Warnings and Logging: 584 | # You can use conversion specifiers for the on_xxxx commands 585 | # %Y = year, %m = month, %d = date, 586 | # %H = hour, %M = minute, %S = second, 587 | # %v = event, %q = frame number, %t = thread (camera) number, 588 | # %D = changed pixels, %N = noise level, 589 | # %i and %J = width and height of motion area, 590 | # %K and %L = X and Y coordinates of motion center 591 | # %C = value defined by text_event 592 | # %f = filename with full path 593 | # %n = number indicating filetype 594 | # Both %f and %n are only defined for on_picture_save, 595 | # on_movie_start and on_movie_end 596 | # Quotation marks round string are allowed. 597 | ############################################################ 598 | 599 | # Do not sound beeps when detecting motion (default: on) 600 | # Note: Motion never beeps when running in daemon mode. 601 | quiet on 602 | 603 | # Command to be executed when an event starts. (default: none) 604 | # An event starts at first motion detected after a period of no motion defined by event_gap 605 | ; on_event_start value 606 | 607 | # Command to be executed when an event ends after a period of no motion 608 | # (default: none). The period of no motion is defined by option event_gap. 609 | ; on_event_end value 610 | 611 | # Command to be executed when a picture (.ppm|.jpg) is saved (default: none) 612 | # To give the filename as an argument to a command append it with %f 613 | ; on_picture_save value 614 | 615 | # Command to be executed when a motion frame is detected (default: none) 616 | ; on_motion_detected value 617 | 618 | # Command to be executed when motion in a predefined area is detected 619 | # Check option 'area_detect'. (default: none) 620 | ; on_area_detected value 621 | 622 | # Command to be executed when a movie file (.mpg|.avi) is created. (default: none) 623 | # To give the filename as an argument to a command append it with %f 624 | ; on_movie_start value 625 | 626 | # Command to be executed when a movie file (.mpg|.avi) is closed. (default: none) 627 | # To give the filename as an argument to a command append it with %f 628 | ; on_movie_end value 629 | 630 | # Command to be executed when a camera can't be opened or if it is lost 631 | # NOTE: There is situations when motion don't detect a lost camera! 632 | # It depends on the driver, some drivers dosn't detect a lost camera at all 633 | # Some hangs the motion thread. Some even hangs the PC! (default: none) 634 | ; on_camera_lost value 635 | 636 | ##################################################################### 637 | # Common Options for database features. 638 | # Options require database options to be active also. 639 | ##################################################################### 640 | 641 | # Log to the database when creating motion triggered picture file (default: on) 642 | ; sql_log_picture on 643 | 644 | # Log to the database when creating a snapshot image file (default: on) 645 | ; sql_log_snapshot on 646 | 647 | # Log to the database when creating motion triggered movie file (default: off) 648 | ; sql_log_movie off 649 | 650 | # Log to the database when creating timelapse movies file (default: off) 651 | ; sql_log_timelapse off 652 | 653 | # SQL query string that is sent to the database 654 | # Use same conversion specifiers has for text features 655 | # Additional special conversion specifiers are 656 | # %n = the number representing the file_type 657 | # %f = filename with full path 658 | # Default value: 659 | # Create tables : 660 | ## 661 | # Mysql 662 | # CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), event_time_stamp timestamp(14)); 663 | # 664 | # Postgresql 665 | # CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp without time zone, event_time_stamp timestamp without time zone); 666 | # 667 | # insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') 668 | ; sql_query insert into security(camera, filename, frame, file_type, time_stamp, event_time_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') 669 | 670 | 671 | ############################################################ 672 | # Database Options 673 | ############################################################ 674 | 675 | # database type : mysql, postgresql, sqlite3 (default : not defined) 676 | ; database_type value 677 | 678 | # database to log to (default: not defined) 679 | ; database_dbname value 680 | 681 | # The host on which the database is located (default: localhost) 682 | ; database_host value 683 | 684 | # User account name for database (default: not defined) 685 | ; database_user value 686 | 687 | # User password for database (default: not defined) 688 | ; database_password value 689 | 690 | # Port on which the database is located 691 | # mysql 3306 , postgresql 5432 (default: not defined) 692 | ; database_port value 693 | 694 | ############################################################ 695 | # Database Options For SQLite3 696 | ############################################################ 697 | 698 | # SQLite3 database (file path) (default: not defined) 699 | ; sqlite3_db value 700 | 701 | 702 | 703 | ############################################################ 704 | # Video Loopback Device (vloopback project) 705 | ############################################################ 706 | 707 | # Output images to a video4linux loopback device 708 | # The value '-' means next available (default: not defined) 709 | ; video_pipe value 710 | 711 | # Output motion images to a video4linux loopback device 712 | # The value '-' means next available (default: not defined) 713 | ; motion_video_pipe value 714 | 715 | 716 | ############################################################## 717 | # Thread config files - One for each camera. 718 | # Except if only one camera - You only need this config file. 719 | # If you have more than one camera you MUST define one thread 720 | # config file for each camera in addition to this config file. 721 | ############################################################## 722 | 723 | # Remember: If you have more than one camera you must have one 724 | # thread file for each camera. E.g. 2 cameras requires 3 files: 725 | # This motion.conf file AND thread1.conf and thread2.conf. 726 | # Only put the options that are unique to each camera in the 727 | # thread config files. 728 | ; thread /etc/motion/thread1.conf 729 | ; thread /etc/motion/thread2.conf 730 | ; thread /etc/motion/thread3.conf 731 | ; thread /etc/motion/thread4.conf 732 | 733 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | IMAGE_NAME=lazyatom/rpi-motion 4 | VIDEO_DIRECTORY=`pwd`/videos 5 | 6 | mkdir -p $VIDEO_DIRECTORY 7 | docker run -d --device=/dev/video0:/dev/video0 -v $VIDEO_DIRECTORY:/mnt/motion -p 8081:8081 $IMAGE_NAME 8 | --------------------------------------------------------------------------------