pi_portal/installation/templates/motion/motion.conf

  1# Rename this distribution example file to motion.conf
  2#
  3# This config file was generated by motion 4.1.1
  4# Documentation:  /usr/share/doc/motion/motion_guide.html
  5
  6############################################################
  7# Daemon
  8############################################################
  9
 10# Start in daemon (background) mode and release terminal (default: off)
 11daemon off
 12
 13# File to store the process ID, also called pid file. (default: not defined)
 14process_id_file {{ PID_FILE_MOTION }}
 15
 16############################################################
 17# Basic Setup Mode
 18############################################################
 19
 20# Start in Setup-Mode, daemon disabled. (default: off)
 21setup_mode off
 22
 23
 24# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)
 25logfile {{ LOG_FILE_CAMERA }}
 26
 27# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC)
 28log_level 5
 29
 30# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)
 31log_type all
 32
 33############################################################
 34# Round Robin (multiple inputs on same video device name)
 35############################################################
 36
 37# Number of frames to capture in each roundrobin step (default: 1)
 38roundrobin_frames 1
 39
 40# Number of frames to skip before each roundrobin step (default: 1)
 41roundrobin_skip 1
 42
 43# Try to filter out noise generated by roundrobin (default: off)
 44switchfilter off
 45
 46
 47############################################################
 48# Motion Detection Settings:
 49############################################################
 50
 51# Threshold for number of changed pixels in an image that
 52# triggers motion detection (default: 1500)
 53threshold {{ USER_CONFIG['CAMERA']['MOTION']['DETECTION']['THRESHOLD'] }}
 54
 55# Automatically tune the threshold down if possible (default: off)
 56threshold_tune off
 57
 58# Noise threshold for the motion detection (default: 32)
 59noise_level 32
 60
 61# Automatically tune the noise threshold (default: on)
 62noise_tune on
 63
 64# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)
 65# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.
 66# (l)abeling must only be used once and the 'l' must be the last letter.
 67# Comment out to disable
 68despeckle_filter EedDl
 69
 70# Detect motion in predefined areas (1 - 9). Areas are numbered like that:  1 2 3
 71# A script (on_area_detected) is started immediately when motion is         4 5 6
 72# detected in one of the given areas, but only once during an event.        7 8 9
 73# One or more areas can be specified with this option. Take care: This option
 74# does NOT restrict detection to these areas! (Default: not defined)
 75; area_detect value
 76
 77# PGM file to use as a sensitivity mask.
 78# Full path name to. (Default: not defined)
 79; mask_file value
 80
 81# PGM file to completely mask out a area of image.
 82# Full path name to. (Default: not defined)
 83# mask_privacy value
 84
 85# Dynamically create a mask file during operation (default: 0)
 86# Adjust speed of mask changes from 0 (off) to 10 (fast)
 87smart_mask_speed 0
 88
 89# Ignore sudden massive light intensity changes given as a percentage of the picture
 90# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled
 91lightswitch 0
 92
 93# Picture frames must contain motion at least the specified number of frames
 94# in a row before they are detected as true motion. At the default of 1, all
 95# motion is detected. Valid range: 1 to thousands, recommended 1-5
 96minimum_motion_frames 1
 97
 98# Specifies the number of pre-captured (buffered) pictures from before motion
 99# was detected that will be output at motion detection.
100# Recommended range: 0 to 5 (default: 0)
101# Do not use large values! Large values will cause Motion to skip video frames and
102# cause unsmooth movies. To smooth movies use larger values of post_capture instead.
103pre_capture 0
104
105# Number of frames to capture after motion is no longer detected (default: 0)
106post_capture 0
107
108# Event Gap is the seconds of no motion detection that triggers the end of an event.
109# An event is defined as a series of motion images taken within a short timeframe.
110# Recommended value is 60 seconds (Default). The value -1 is allowed and disables
111# events causing all Motion to be written to one single movie file and no pre_capture.
112# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An
113# event ends right after no more motion is detected and post_capture is over.
114event_gap {{ USER_CONFIG['CAMERA']['MOTION']['DETECTION']['EVENT_GAP'] }}
115
116# Maximum length in seconds of a movie
117# When value is exceeded a new movie file is created. (Default: 0 = infinite)
118max_movie_time 0
119
120# Always save images even if there was no motion (default: off)
121emulate_motion off
122
123
124############################################################
125# Image File Output
126############################################################
127
128# Output 'normal' pictures when motion is detected (default: off)
129# Valid values: on, off, first, best, center
130# When set to 'first', only the first picture of an event is saved.
131# Picture with most motion of an event is saved when set to 'best'.
132# Picture with motion nearest center of picture is saved when set to 'center'.
133# Can be used as preview shot for the corresponding movie.
134output_pictures off
135
136# Output pictures with only the pixels moving object (ghost images) (default: off)
137output_debug_pictures off
138
139# The quality (in percent) to be used by the jpeg and webp compression (default: 75)
140quality {{ USER_CONFIG['CAMERA']['MOTION']['SNAPSHOTS']['QUALITY'] }}
141
142# Type of output images
143# Valid values: jpeg, ppm or webp (default: jpeg)
144picture_type jpeg
145
146############################################################
147
148# Use ffmpeg to encode videos of motion (default: off)
149ffmpeg_output_movies on
150
151# Use ffmpeg to make videos showing the moving pixels (ghost images) (default: off)
152ffmpeg_output_debug_movies off
153
154# Bitrate to be used by the ffmpeg encoder (default: 400000)
155# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled)
156ffmpeg_bps 400000
157
158# Enables and defines variable bitrate for the ffmpeg encoder.
159# ffmpeg_bps is ignored if variable bitrate is enabled.
160# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps,
161# or the range 1 - 100 where 1 means worst quality and 100 is best.
162ffmpeg_variable_bitrate 0
163
164# Container/Codec output videos
165# Valid values: mpeg4, msmpeg4, swf,flv, ffv1, mov, mp4, mkv, hevc
166ffmpeg_video_codec mp4
167
168# When creating videos, should frames be duplicated in order
169# to keep up with the requested frames per second
170# (default: true)
171ffmpeg_duplicate_frames true
172
173# Interval in seconds between timelapse captures.  Default: 0 = off
174timelapse_interval 0
175
176# Timelapse file rollover mode. See motion_guide.html for options and uses.
177timelapse_mode daily
178
179# Frame rate for timelapse playback
180timelapse_fps 30
181
182# Container/Codec for timelapse video. Valid values: mpg or mpeg4
183timelapse_codec mpg
184
185############################################################
186# External pipe to video encoder
187# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only.
188# The options movie_filename and timelapse_filename are also used
189# by the ffmpeg feature
190#############################################################
191
192# Bool to enable or disable extpipe (default: off)
193use_extpipe off
194
195# External program (full path and opts) to pipe raw video to
196# Generally, use '-' for STDIN...
197;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h: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
198;extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4
199;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps
200;extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4
201
202
203############################################################
204# Snapshots (Traditional Periodic Webcam File Output)
205############################################################
206
207# Make automated snapshot every N seconds (default: 0 = disabled)
208snapshot_interval 0
209
210
211############################################################
212# Text Display
213# %Y = year, %m = month, %d = date,
214# %H = hour, %M = minute, %S = second, %T = HH:MM:SS,
215# %v = event, %q = frame number, %t = camera id number,
216# %D = changed pixels, %N = noise level, \n = new line,
217# %i and %J = width and height of motion area,
218# %K and %L = X and Y coordinates of motion center
219# %C = value defined by text_event - do not use with text_event!
220# You can put quotation marks around the text to allow
221# leading spaces
222############################################################
223
224# Locate and draw a box around the moving object.
225# Valid values: on, off, preview (default: off)
226# Set to 'preview' will only draw a box in preview_shot pictures.
227locate_motion_mode {{ USER_CONFIG['CAMERA']['MOTION']['MOVIES']['LOCATE_MOTION_MODE'] }}
228
229# Set the look and style of the locate box if enabled.
230# Valid values: box, redbox, cross, redcross (default: box)
231# Set to 'box' will draw the traditional box.
232# Set to 'redbox' will draw a red box.
233# Set to 'cross' will draw a little cross to mark center.
234# Set to 'redcross' will draw a little red cross to mark center.
235locate_motion_style box
236
237# Draws the timestamp using same options as C function strftime(3)
238# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
239# Text is placed in lower right corner
240text_right %Y-%m-%d\n%T-%q
241
242# Draw a user defined text on the images using same options as C function strftime(3)
243# Default: Not defined = no text
244# Text is placed in lower left corner
245text_left CAMERA %t
246
247# Draw the number of changed pixed on the images (default: off)
248# Will normally be set to off except when you setup and adjust the motion settings
249# Text is placed in upper right corner
250text_changes off
251
252# This option defines the value of the special event conversion specifier %C
253# You can use any conversion specifier in this option except %C. Date and time
254# values are from the timestamp of the first image in the current event.
255# Default: %Y%m%d%H%M%S
256# The idea is that %C can be used filenames and text_left/right for creating
257# a unique identifier for each event.
258text_event %Y%m%d%H%M%S
259
260# Draw characters at twice normal size on images. (default: off)
261text_double off
262
263
264# Text to include in a JPEG EXIF comment
265# May be any text, including conversion specifiers.
266# The EXIF timestamp is included independent of this text.
267;exif_text %i%J/%K%L
268
269############################################################
270# Target Directories and filenames For Images And Films
271# For the options snapshot_, picture_, movie_ and timelapse_filename
272# you can use conversion specifiers
273# %Y = year, %m = month, %d = date,
274# %H = hour, %M = minute, %S = second,
275# %v = event, %q = frame number, %t = camera id number,
276# %D = changed pixels, %N = noise level,
277# %i and %J = width and height of motion area,
278# %K and %L = X and Y coordinates of motion center
279# %C = value defined by text_event
280# Quotation marks round string are allowed.
281############################################################
282
283# Target base directory for pictures and films
284# Recommended to use absolute path. (Default: current working directory)
285target_dir {{ PATH_CAMERA_CONTENT }}
286
287# File path for snapshots (jpeg, ppm or webp) relative to target_dir
288# Default: %v-%Y%m%d%H%M%S-snapshot
289# Default value is equivalent to legacy oldlayout option
290# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot
291# File extension .jpg, .ppm or .webp is automatically added so do not include this.
292# Note: A symbolic link called lastsnap.jpg created in the target_dir will always
293# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'
294snapshot_filename %t-%Y%m%d%H%M%S-snapshot
295
296# File path for motion triggered images (jpeg, ppm or .webp) relative to target_dir
297# Default: %v-%Y%m%d%H%M%S-%q
298# Default value is equivalent to legacy oldlayout option
299# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q
300# File extension .jpg, .ppm or .webp is automatically added so do not include this
301# Set to 'preview' together with best-preview feature enables special naming
302# convention for preview shots. See motion guide for details
303picture_filename %t-%Y%m%d%H%M%S-%q
304
305# File path for motion triggered ffmpeg films (movies) relative to target_dir
306# Default: %v-%Y%m%d%H%M%S
307# File extensions(.mpg .avi) are automatically added so do not include them
308movie_filename %t-%Y%m%d%H%M%S
309
310# File path for timelapse movies relative to target_dir
311# Default: %Y%m%d-timelapse
312# File extensions(.mpg .avi) are automatically added so do not include them
313timelapse_filename %Y%m%d-timelapse
314
315############################################################
316# Global Network Options
317############################################################
318# Enable IPv6 (default: off)
319ipv6_enabled off
320
321############################################################
322# Live Stream Server
323############################################################
324
325# The mini-http server listens to this port for requests (default: 0 = disabled)
326stream_port 0
327
328# 50% scaled down substream (default: 0 = disabled)
329# substream_port 8082
330
331# Quality of the jpeg (in percent) images produced (default: 50)
332stream_quality 50
333
334# Output frames at 1 fps when no motion is detected and increase to the
335# rate given by stream_maxrate when motion is detected (default: off)
336stream_motion off
337
338# Maximum framerate for stream streams (default: 1)
339stream_maxrate 1
340
341# Restrict stream connections to localhost only (default: on)
342stream_localhost on
343
344# Limits the number of images per connection (default: 0 = unlimited)
345# Number can be defined by multiplying actual stream rate by desired number of seconds
346# Actual stream rate is the smallest of the numbers framerate and stream_maxrate
347stream_limit 0
348
349# Set the authentication method (default: 0)
350# 0 = disabled
351# 1 = Basic authentication
352# 2 = MD5 digest (the safer authentication)
353stream_auth_method 0
354
355# Authentication for the stream. Syntax username:password
356# Default: not defined (Disabled)
357; stream_authentication username:password
358
359# Percentage to scale the stream image for preview
360# This is scaled on the browser side, motion will keep sending full frames
361# Default: 25
362; stream_preview_scale 25
363
364# Have stream preview image start on a new line
365# Default: no
366; stream_preview_newline no
367
368############################################################
369# HTTP Based Control
370############################################################
371
372# TCP/IP port for the http server to listen on (default: 0 = disabled)
373webcontrol_port 8080
374
375# Restrict control connections to localhost only (default: on)
376webcontrol_localhost on
377
378# Output for http server, select off to choose raw text plain (default: on)
379webcontrol_html_output on
380
381# Authentication for the http based control. Syntax username:password
382# Default: not defined (Disabled)
383webcontrol_authentication {{ USER_CONFIG['CAMERA']['MOTION']['AUTHENTICATION']['USERNAME'] }}:{{ USER_CONFIG['CAMERA']['MOTION']['AUTHENTICATION']['PASSWORD'] }}
384
385# Parameters to include on webcontrol.  0=none, 1=limited, 2=advanced, 3=restricted
386# Default: 0 (none)
387webcontrol_parms 0
388
389
390############################################################
391# Tracking (Pan/Tilt)
392#############################################################
393
394# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo)
395# The generic type enables the definition of motion center and motion size to
396# be used with the conversion specifiers for options like on_motion_detected
397track_type 0
398
399# Enable auto tracking (default: off)
400track_auto off
401
402# Serial port of motor (default: none)
403;track_port /dev/ttyS0
404
405# Motor number for x-axis (default: 0)
406;track_motorx 0
407
408# Set motorx reverse (default: 0)
409;track_motorx_reverse 0
410
411# Motor number for y-axis (default: 0)
412;track_motory 1
413
414# Set motory reverse (default: 0)
415;track_motory_reverse 0
416
417# Maximum value on x-axis (default: 0)
418;track_maxx 200
419
420# Minimum value on x-axis (default: 0)
421;track_minx 50
422
423# Maximum value on y-axis (default: 0)
424;track_maxy 200
425
426# Minimum value on y-axis (default: 0)
427;track_miny 50
428
429# Center value on x-axis (default: 0)
430;track_homex 128
431
432# Center value on y-axis (default: 0)
433;track_homey 128
434
435# ID of an iomojo camera if used (default: 0)
436track_iomojo_id 0
437
438# Angle in degrees the camera moves per step on the X-axis
439# with auto-track (default: 10)
440# Currently only used with pwc type cameras
441track_step_angle_x 10
442
443# Angle in degrees the camera moves per step on the Y-axis
444# with auto-track (default: 10)
445# Currently only used with pwc type cameras
446track_step_angle_y 10
447
448# Delay to wait for after tracking movement as number
449# of picture frames (default: 10)
450track_move_wait 10
451
452# Speed to set the motor to (stepper motor option) (default: 255)
453track_speed 255
454
455# Number of steps to make (stepper motor option) (default: 40)
456track_stepsize 40
457
458
459############################################################
460# External Commands, Warnings and Logging:
461# You can use conversion specifiers for the on_xxxx commands
462# %Y = year, %m = month, %d = date,
463# %H = hour, %M = minute, %S = second,
464# %v = event, %q = frame number, %t = camera id number,
465# %D = changed pixels, %N = noise level,
466# %i and %J = width and height of motion area,
467# %K and %L = X and Y coordinates of motion center
468# %C = value defined by text_event
469# %f = filename with full path
470# %n = number indicating filetype
471# Both %f and %n are only defined for on_picture_save,
472# on_movie_start and on_movie_end
473# Quotation marks round string are allowed.
474############################################################
475
476# Do not sound beeps when detecting motion (default: on)
477# Note: Motion never beeps when running in daemon mode.
478quiet on
479
480# Command to be executed when an event starts. (default: none)
481# An event starts at first motion detected after a period of no motion defined by event_gap
482; on_event_start value
483
484# Command to be executed when an event ends after a period of no motion
485# (default: none). The period of no motion is defined by option event_gap.
486; on_event_end value
487
488# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
489# To give the filename as an argument to a command append it with %f
490on_picture_save /bin/bash -c "source '{{ PI_PORTAL_INSTALL_LOCATION }}/bin/activate'; python -m pi_portal upload_snapshot %f"
491
492# Command to be executed when a motion frame is detected (default: none)
493; on_motion_detected value
494
495# Command to be executed when motion in a predefined area is detected
496# Check option 'area_detect'.   (default: none)
497; on_area_detected value
498
499# Command to be executed when a movie file (.mpg|.avi) is created. (default: none)
500# To give the filename as an argument to a command append it with %f
501; on_movie_start value
502
503# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)
504# To give the filename as an argument to a command append it with %f
505on_movie_end /bin/bash -c "source '{{ PI_PORTAL_INSTALL_LOCATION }}/bin/activate'; python -m pi_portal upload_video %f"
506
507# Command to be executed when a camera can't be opened or if it is lost
508# NOTE: There is situations when motion don't detect a lost camera!
509# It depends on the driver, some drivers dosn't detect a lost camera at all
510# Some hangs the motion thread. Some even hangs the PC! (default: none)
511; on_camera_lost value
512
513# Command to be executed when a camera that was lost has been found (default: none)
514# NOTE: If motion doesn't properly detect a lost camera, it also won't know it found one.
515; on_camera_found value
516
517#####################################################################
518# Common Options for database features.
519# Options require database options to be active also.
520#####################################################################
521
522# Log to the database when creating motion triggered picture file  (default: on)
523; sql_log_picture on
524
525# Log to the database when creating a snapshot image file (default: on)
526; sql_log_snapshot on
527
528# Log to the database when creating motion triggered movie file (default: off)
529; sql_log_movie off
530
531# Log to the database when creating timelapse movies file (default: off)
532; sql_log_timelapse off
533
534# SQL query string that is sent to the database
535# Use same conversion specifiers has for text features
536# Additional special conversion specifiers are
537# %n = the number representing the file_type
538# %f = filename with full path
539# Default value:
540# Create tables :
541##
542# Mysql
543# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), event_time_stamp timestamp(14));
544#
545# Postgresql
546# 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);
547#
548# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
549; 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')
550
551
552############################################################
553# Database Options
554############################################################
555
556# database type : mysql, postgresql, sqlite3 (default : not defined)
557; database_type value
558
559# database to log to (default: not defined)
560# for sqlite3, the full path and name for the database.
561; database_dbname value
562
563# The host on which the database is located (default: localhost)
564; database_host value
565
566# User account name for database (default: not defined)
567; database_user value
568
569# User password for database (default: not defined)
570; database_password value
571
572# Port on which the database is located
573#  mysql 3306 , postgresql 5432 (default: not defined)
574; database_port value
575
576# Database wait time in milliseconds for locked database to
577# be unlocked before returning database locked error (default 0)
578; database_busy_timeout 0
579
580
581
582############################################################
583# Video Loopback Device (vloopback project)
584############################################################
585
586# Output images to a video4linux loopback device
587# Specify the device associated with the loopback device
588# For example /dev/video1 (default: not defined)
589; video_pipe value
590
591# Output motion images to a video4linux loopback device
592# Specify the device associated with the loopback device
593# For example /dev/video1 (default: not defined)
594; motion_video_pipe value
595
596
597##############################################################
598# camera config files - One for each camera.
599# Except if only one camera - You only need this config file.
600# If you have more than one camera you MUST define one camera
601# config file for each camera in addition to this config file.
602##############################################################
603
604# Remember: If you have more than one camera you must have one
605# camera file for each camera. E.g. 2 cameras requires 3 files:
606# This motion.conf file AND camera1.conf and camera2.conf.
607# Only put the options that are unique to each camera in the
608# camera config files.
609{% for CAMERA in USER_CONFIG['CAMERA']['MOTION']['CAMERAS'] %}
610camera /etc/motion/camera{{ loop.index }}.conf
611{% endfor %}
612
613##############################################################
614# Camera config directory
615# Any files ending in '.conf' in this directory will be read
616# as a camera config file.
617##############################################################
618
619; camera_dir /etc/motion/conf.d