Motion-Project / motion

Motion, a software motion detector. Home page: https://motion-project.github.io/
GNU General Public License v2.0
3.67k stars 549 forks source link

I looks like on_movie_start/on_movie_end is called twice #1752

Closed joeschmitt closed 8 months ago

joeschmitt commented 8 months ago

Did you read the guide?

Yes

What is the base version number of Motion being used?

4.6.x

What was the install method?

Installed via package tool

What is base architecture?

ARM-32bit

What is the distro being used?

Raspbian

Disto version number

Raspbian GNU/Linux 11 (bullseye)

Camera type(s) being used?

PI cam via libcamerify

Describe the issue/problem and steps to reproduce

The "problem" I think is that external programs are called twice. Once when the recording ends and a second time when the pipe to the external ffmpeg program is closed. For the first time the name of the file into which the recording happens contains the extension ".mp4" and the second time the extension is missing. This is can also be seen in the motion.log (log_level 9)

In my called programs I'm able to ignore the second call based on the missing extension. I stumbled over this when I tried to understand the behavior of my called programs. The programs are written (golang) by myself so I can do the logging as I want/need.

So what I try to understand is if this an intended behavior or a fault. I couldn't find an explanation based on the config options and it feels more like an error then a feature, or?

Motion log output at log_level 8

[0:motion] [NTC] [ALL] [Feb 11 17:38:15] motion_startup: Motion 4.6.0 Started
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] motion_startup: Using default log type (ALL)
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] motion_startup: Using log type (ALL) log level (ALL)
[0:motion] [INF] [ALL] [Feb 11 17:38:15] conf_output_parms: Writing configuration parameters from all files (1):
[0:motion] [INF] [ALL] [Feb 11 17:38:15] Thread 0 - Config file: /home/pi/motion/motion.conf
[0:motion] [INF] [ALL] [Feb 11 17:38:15] daemon                    off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] setup_mode                off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] pid_file                  
[0:motion] [INF] [ALL] [Feb 11 17:38:15] log_file                  /home/pi/motion/log/motion.log
[0:motion] [INF] [ALL] [Feb 11 17:38:15] log_level                 9
[0:motion] [INF] [ALL] [Feb 11 17:38:15] log_type                  ALL
[0:motion] [INF] [ALL] [Feb 11 17:38:15] quiet                     on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] native_language           on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] watchdog_tmo              30
[0:motion] [INF] [ALL] [Feb 11 17:38:15] watchdog_kill             10
[0:motion] [INF] [ALL] [Feb 11 17:38:15] camera_name               
[0:motion] [INF] [ALL] [Feb 11 17:38:15] camera_id                 0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] target_dir                /home/pi/motion/ramdisk
[0:motion] [INF] [ALL] [Feb 11 17:38:15] video_device              /dev/video0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] video_params              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] auto_brightness           0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] tuner_device              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] roundrobin_frames         1
[0:motion] [INF] [ALL] [Feb 11 17:38:15] roundrobin_skip           1
[0:motion] [INF] [ALL] [Feb 11 17:38:15] roundrobin_switchfilter   off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] netcam_url                
[0:motion] [INF] [ALL] [Feb 11 17:38:15] netcam_params             
[0:motion] [INF] [ALL] [Feb 11 17:38:15] netcam_high_url           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] netcam_high_params        
[0:motion] [INF] [ALL] [Feb 11 17:38:15] netcam_userpass           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] mmalcam_name              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] mmalcam_params            
[0:motion] [INF] [ALL] [Feb 11 17:38:15] width                     1920
[0:motion] [INF] [ALL] [Feb 11 17:38:15] height                    1072
[0:motion] [INF] [ALL] [Feb 11 17:38:15] framerate                 24
[0:motion] [INF] [ALL] [Feb 11 17:38:15] minimum_frame_time        0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] rotate                    180
[0:motion] [INF] [ALL] [Feb 11 17:38:15] flip_axis                 none
[0:motion] [INF] [ALL] [Feb 11 17:38:15] locate_motion_mode        on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] locate_motion_style       redbox
[0:motion] [INF] [ALL] [Feb 11 17:38:15] text_left                 
[0:motion] [INF] [ALL] [Feb 11 17:38:15] text_right                %Y-%m-%d  %T
[0:motion] [INF] [ALL] [Feb 11 17:38:15] text_changes              off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] text_scale                3
[0:motion] [INF] [ALL] [Feb 11 17:38:15] text_event                %Y%m%d%H%M%S
[0:motion] [INF] [ALL] [Feb 11 17:38:15] emulate_motion            off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] pause                     off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] threshold                 800
[0:motion] [INF] [ALL] [Feb 11 17:38:15] threshold_maximum         0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] threshold_tune            off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] noise_level               32
[0:motion] [INF] [ALL] [Feb 11 17:38:15] noise_tune                on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] despeckle_filter          edeEedDedl
[0:motion] [INF] [ALL] [Feb 11 17:38:15] area_detect               
[0:motion] [INF] [ALL] [Feb 11 17:38:15] mask_file                 /home/pi/motion/newmask23HD.pgm
[0:motion] [INF] [ALL] [Feb 11 17:38:15] mask_privacy              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] smart_mask_speed          7
[0:motion] [INF] [ALL] [Feb 11 17:38:15] lightswitch_percent       0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] lightswitch_frames        5
[0:motion] [INF] [ALL] [Feb 11 17:38:15] minimum_motion_frames     1
[0:motion] [INF] [ALL] [Feb 11 17:38:15] event_gap                 5
[0:motion] [INF] [ALL] [Feb 11 17:38:15] pre_capture               1
[0:motion] [INF] [ALL] [Feb 11 17:38:15] post_capture              125
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_event_start            
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_event_end              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_picture_save           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_area_detected          
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_motion_detected        
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_movie_start            /home/pi/motion/lockrd %f
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_movie_end              /home/pi/motion/unlockrd %f
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_camera_lost            
[0:motion] [INF] [ALL] [Feb 11 17:38:15] on_camera_found           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_output            off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_output_motion     off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_type              jpeg
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_quality           75
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_exif              
[0:motion] [INF] [ALL] [Feb 11 17:38:15] picture_filename          %Y-%m-%d--%H-%M-%S
[0:motion] [INF] [ALL] [Feb 11 17:38:15] snapshot_interval         0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] snapshot_filename         %v-%Y%m%d%H%M%S-snapshot
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_output              on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_output_motion       off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_max_time            60
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_bps                 400000
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_quality             70
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_codec               mp4
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_duplicate_frames    off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_passthrough         off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_filename            %Y-%m-%d__%H-%M-%S
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_extpipe_use         on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] movie_extpipe             /usr/bin/ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset fast -f mp4 %f.mp4
[0:motion] [INF] [ALL] [Feb 11 17:38:15] timelapse_interval        0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] timelapse_mode            daily
[0:motion] [INF] [ALL] [Feb 11 17:38:15] timelapse_fps             30
[0:motion] [INF] [ALL] [Feb 11 17:38:15] timelapse_codec           mpg
[0:motion] [INF] [ALL] [Feb 11 17:38:15] timelapse_filename        %Y%m%d-timelapse
[0:motion] [INF] [ALL] [Feb 11 17:38:15] video_pipe                
[0:motion] [INF] [ALL] [Feb 11 17:38:15] video_pipe_motion         
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_port           8080
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_ipv6           off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_localhost      on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_parms          0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_interface      0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_auth_method    0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_authentication 
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_tls            off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_cert           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_key            
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_header_params  
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_lock_minutes   5
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_lock_attempts  5
[0:motion] [INF] [ALL] [Feb 11 17:38:15] webcontrol_lock_max_ips   25
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_port               8081
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_localhost          on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_auth_method        0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_authentication     
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_tls                off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_header_params      
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_preview_scale      25
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_preview_newline    off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_preview_method     4
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_quality            40
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_grey               off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_motion             on
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_maxrate            8
[0:motion] [INF] [ALL] [Feb 11 17:38:15] stream_limit              0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_type             
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_dbname           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_host             localhost
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_port             0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_user             
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_password         
[0:motion] [INF] [ALL] [Feb 11 17:38:15] database_busy_timeout     0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_log_picture           off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_log_snapshot          off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_log_movie             off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_log_timelapse         off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_query_start           
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_query_stop            
[0:motion] [INF] [ALL] [Feb 11 17:38:15] sql_query                 
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_type                0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_auto                off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_port                
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_motorx              0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_motorx_reverse      off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_motory              0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_motory_reverse      off
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_maxx                0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_minx                0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_maxy                0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_miny                0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_homex               128
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_homey               128
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_iomojo_id           0
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_step_angle_x        10
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_step_angle_y        10
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_move_wait           10
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_speed               255
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_stepsize            40
[0:motion] [INF] [ALL] [Feb 11 17:38:15] track_generic_move        
[0:motion] [INF] [ALL] [Feb 11 17:38:15] camera                    
[0:motion] [INF] [ALL] [Feb 11 17:38:15] camera_dir                
[0:motion] [DBG] [ALL] [Feb 11 17:38:15] motion_ntc: v4l2   : available
[0:motion] [DBG] [ALL] [Feb 11 17:38:15] motion_ntc: bktr   : not available
[0:motion] [DBG] [ALL] [Feb 11 17:38:15] motion_ntc: webp   : available
[0:motion] [DBG] [ALL] [Feb 11 17:38:15] motion_ntc: mmal   : not available
[0:motion] [DBG] [ALL] [Feb 11 17:38:15] motion_ntc: ffmpeg : available
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] motion_ntc: mysql  : not available
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] motion_ntc: MariaDB: available
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] motion_ntc: sqlite3: available
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] motion_ntc: pgsql  : available
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] motion_ntc: nls    : available
[0:motion] [NTC] [STR] [Feb 11 17:38:15] webu_start_strm: Starting all camera streams on port 8081
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_basic: Basic authentication: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_digest: Digest authentication: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_ipv6: IPV6: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_tls: SSL/TLS: available
[0:motion] [NTC] [STR] [Feb 11 17:38:15] webu_strm_ntc: Started camera 0 stream on port 8081
[0:motion] [NTC] [STR] [Feb 11 17:38:15] webu_start_ctrl: Starting webcontrol on port 8080
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_basic: Basic authentication: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_digest: Digest authentication: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_ipv6: IPV6: available
[0:motion] [DBG] [STR] [Feb 11 17:38:15] webu_mhd_features_tls: SSL/TLS: available
[0:motion] [NTC] [STR] [Feb 11 17:38:15] webu_start_ctrl: Started webcontrol on port 8080
[0:motion] [NTC] [ENC] [Feb 11 17:38:15] ffmpeg_global_init: ffmpeg libavcodec version 58.91.100 libavformat version 58.45.100
[0:motion] [DBG] [DBL] [Feb 11 17:38:15] dbse_global_init: Initializing database
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] translate_init: Language: English
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] motion_start_thread: Camera ID: 0 is from /home/pi/motion/motion.conf
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] motion_start_thread: Camera ID: 0 Camera Name: (null) Device: /dev/video0
[0:motion] [NTC] [ALL] [Feb 11 17:38:15] main: Waiting for threads to finish, pid: 28421
[1:ml1] [NTC] [ALL] [Feb 11 17:38:15] motion_init: Camera 0 started: motion detection Enabled
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] vid_start: Opening V4L2 device
[1:ml1] [DBG] [ALL] [Feb 11 17:38:15] util_parms_add: Parsed: >palette< >17<
[1:ml1] [DBG] [ALL] [Feb 11 17:38:15] util_parms_add: Parsed: >input< >-1<
[1:ml1] [DBG] [ALL] [Feb 11 17:38:15] util_parms_add: Parsed: >norm< >0<
[1:ml1] [DBG] [ALL] [Feb 11 17:38:15] util_parms_add: Parsed: >frequency< >0<
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_device_open: Using videodevice /dev/video0 and input -1
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: ------------------------
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: cap.driver: "libcamera"
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: cap.card: "/base/soc/i2c0mux/i2c@1/imx708@"
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: cap.bus_info: "libcamera:0"
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: cap.capabilities=0x84200001
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_device_capability: ------------------------
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_device_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_device_capability: - STREAMING
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_input_select: Name = "/base/soc/i2c0mux/i2c@1/imx708@", type 0x00000002, status 00000000
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_input_select: Name = "/base/soc/i2c0mux/i2c@1/imx708@"- CAMERA
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_norm_select: Device does not support specifying PAL/NTSC norm
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_pixfmt_try: Testing palette YU12 (1920x1072)
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_pixfmt_stride: Checking image size 1920x1072 with stride 1920
[1:ml1] [NTC] [VID] [Feb 11 17:38:15] v4l2_pixfmt_set: Using palette YU12 (1920x1072)
[1:ml1] [INF] [VID] [Feb 11 17:38:15] v4l2_fps_set: Trying to set fps to 24
[1:ml1] [ERR] [VID] [Feb 11 17:38:15] v4l2_fps_set: Error setting fps. Return code -1
[1:ml1] [INF] [VID] [Feb 11 17:38:15] v4l2_fps_set: Device set fps to 24
[1:ml1] [INF] [VID] [Feb 11 17:38:15] v4l2_ctrls_list: No Controls found for device
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_mmap_request: mmap information: frames=4
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_mmap_query: 0 length=3087360 Address (e810c000) offset 0
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_mmap_query: 1 length=3087360 Address (e7e1a000) offset 3087360
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_mmap_query: 2 length=3087360 Address (e7b28000) offset 6174720
[1:ml1] [DBG] [VID] [Feb 11 17:38:15] v4l2_mmap_query: 3 length=3087360 Address (e7836000) offset 9262080
[1:ml1] [NTC] [ALL] [Feb 11 17:38:16] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1] [DBG] [ALL] [Feb 11 17:38:16] get_pgm: Magic P5: Width 1920(1920): Height 1080(1080): MaxVal: 255(255)
[1:ml1] [WRN] [ALL] [Feb 11 17:38:16] get_pgm: The mask file specified is not the same size as image from camera.
[1:ml1] [WRN] [ALL] [Feb 11 17:38:16] get_pgm: Attempting to resize mask image from 1920x1080 to 1920x1072
[1:ml1] [INF] [ALL] [Feb 11 17:38:16] motion_init: Maskfile "/home/pi/motion/newmask23HD.pgm" loaded.
[1:ml1] [NTC] [ALL] [Feb 11 17:38:16] image_ring_resize: Resizing pre_capture buffer to 2 items
[1:ml1] [NTC] [ALL] [Feb 11 17:42:51] motion_detected: Motion detected - starting event 1.
[1:ml1] [INF] [EVT] [Feb 11 17:42:51] event_ffmpeg_newfile: Source FPS 8
[1:ml1] [INF] [ENC] [Feb 11 17:42:51] ffmpeg_set_quality: libx264 codec vbr/crf/bit_rate: 15
[1:ml1] [DBG] [EVT] [Feb 11 17:42:51] exec_command: Executing external command '/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-11__17-42-51.mp4'
[1:ml1] [NTC] [EVT] [Feb 11 17:42:51] event_newfile: Writing movie to file: /home/pi/motion/ramdisk/2024-02-11__17-42-51.mp4
[1:ml1] [INF] [EVT] [Feb 11 17:42:51] event_create_extpipe: Source FPS 8
[1:ml1] [NTC] [ALL] [Feb 11 17:42:51] mycreate_path: creating directory /home/pi/motion/ramdisk
[1:ml1] [NTC] [EVT] [Feb 11 17:42:51] event_create_extpipe: pipe: /usr/bin/ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size 1920x1072 -framerate 8 -i pipe:0 -vcodec libx264 -preset fast -f mp4 /home/pi/motion/ramdisk/2024-02-11__17-42-51.mp4
[1:ml1] [NTC] [EVT] [Feb 11 17:42:51] event_create_extpipe: cnt->moviefps: 8
[1:ml1] [DBG] [EVT] [Feb 11 17:42:51] exec_command: Executing external command '/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-11__17-42-51'
[1:ml1] [NTC] [EVT] [Feb 11 17:42:51] event_newfile: Writing movie to file: /home/pi/motion/ramdisk/2024-02-11__17-42-51
[1:ml1] [DBG] [EVT] [Feb 11 17:43:30] exec_command: Executing external command '/home/pi/motion/unlockrd /home/pi/motion/ramdisk/2024-02-11__17-42-51.mp4'
[1:ml1] [DBG] [EVT] [Feb 11 17:43:30] event_closefile: Saved movie to file: /home/pi/motion/ramdisk/2024-02-11__17-42-51.mp4
[1:ml1] [NTC] [EVT] [Feb 11 17:43:30] event_extpipe_end: CLOSING: extpipe file desc 52, error state 0
[1:ml1] [NTC] [EVT] [Feb 11 17:43:38] event_extpipe_end: pclose return: 0
[1:ml1] [DBG] [EVT] [Feb 11 17:43:38] exec_command: Executing external command '/home/pi/motion/unlockrd /home/pi/motion/ramdisk/2024-02-11__17-42-51'
[1:ml1] [DBG] [EVT] [Feb 11 17:43:38] event_closefile: Saved movie to file: /home/pi/motion/ramdisk/2024-02-11__17-42-51
[1:ml1] [NTC] [ALL] [Feb 11 17:43:38] mlp_actions: End of event 1
[1:ml1] [NTC] [ALL] [Feb 11 17:54:01] motion_detected: Motion detected - starting event 2.
[1:ml1] [INF] [EVT] [Feb 11 17:54:01] event_ffmpeg_newfile: Source FPS 7
[1:ml1] [INF] [ENC] [Feb 11 17:54:01] ffmpeg_set_quality: libx264 codec vbr/crf/bit_rate: 15
[1:ml1] [DBG] [EVT] [Feb 11 17:54:01] exec_command: Executing external command '/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-11__17-54-00.mp4'
[1:ml1] [NTC] [EVT] [Feb 11 17:54:01] event_newfile: Writing movie to file: /home/pi/motion/ramdisk/2024-02-11__17-54-00.mp4
[1:ml1] [INF] [EVT] [Feb 11 17:54:01] event_create_extpipe: Source FPS 7
[1:ml1] [NTC] [ALL] [Feb 11 17:54:01] mycreate_path: creating directory /home/pi/motion/ramdisk
[1:ml1] [NTC] [EVT] [Feb 11 17:54:01] event_create_extpipe: pipe: /usr/bin/ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size 1920x1072 -framerate 7 -i pipe:0 -vcodec libx264 -preset fast -f mp4 /home/pi/motion/ramdisk/2024-02-11__17-54-00.mp4
[1:ml1] [NTC] [EVT] [Feb 11 17:54:01] event_create_extpipe: cnt->moviefps: 7
[1:ml1] [DBG] [EVT] [Feb 11 17:54:01] exec_command: Executing external command '/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-11__17-54-00'
[1:ml1] [NTC] [EVT] [Feb 11 17:54:01] event_newfile: Writing movie to file: /home/pi/motion/ramdisk/2024-02-11__17-54-00
[1:ml1] [DBG] [EVT] [Feb 11 17:54:01] event_extpipe_put: Using extpipe
[1:ml1] [DBG] [EVT] Above message repeats 3 times
[1:ml1] [DBG] [EVT] [Feb 11 17:54:38] exec_command: Executing external command '/home/pi/motion/unlockrd /home/pi/motion/ramdisk/2024-02-11__17-54-00.mp4'
[1:ml1] [DBG] [EVT] [Feb 11 17:54:38] event_closefile: Saved movie to file: /home/pi/motion/ramdisk/2024-02-11__17-54-00.mp4
[1:ml1] [NTC] [EVT] [Feb 11 17:54:38] event_extpipe_end: CLOSING: extpipe file desc 52, error state 0
[1:ml1] [NTC] [EVT] [Feb 11 17:54:42] event_extpipe_end: pclose return: 0
[1:ml1] [DBG] [EVT] [Feb 11 17:54:42] exec_command: Executing external command '/home/pi/motion/unlockrd /home/pi/motion/ramdisk/2024-02-11__17-54-00'
[1:ml1] [DBG] [EVT] [Feb 11 17:54:42] event_closefile: Saved movie to file: /home/pi/motion/ramdisk/2024-02-11__17-54-00
[1:ml1] [NTC] [ALL] [Feb 11 17:54:42] mlp_actions: End of event 2
tosiara commented 8 months ago

Looks like you have defined both movie_output onand movie_extpipe_use on, and therefore you get two video files, right?

joeschmitt commented 8 months ago

No I have only one video file. And yes both settings are on. "movie_output on" I understood is needed to create videos after a motion event is detected. And "movie_extpipe_use on" to tell motion to use the external program given by movie_extpipe.

And my experience after usage of motion for a longer time seems to support this. For example when I tried to integrate sound recording with the help of movie_extpipe and ffmpeg (which didn't work) I set movie_extpipe_use off for test which leads to the usage of the own motion encoder as expected . And movie_output on was still on. I looked a little bit into the source code for the on_movie_end (the only one I go deeper) and found that it's called for two cases, but I didn't dig deeper.

To verify it, I will check with my called program if two recordings with corresponding files can be detected.

joeschmitt commented 8 months ago

It seems to happen as I told. This is the log of my called program. The log shows that the called program can verify the file with extension mp4 (line 29 of program). The next log line 43 logs the call to another program. Afterwards lockrd is called again but now the filename has no extension mp4. This is the reason for that the line numbers between 43 and 45 are interrupted by another call to lockrd signaled by the fresh starting of the line numbers. And in the second case the message of line 29 that a recording file already exists is not logged instead the log shows that my next test afterwards for the missing extension is true and the log says that the second call is ignored means program exits then. This pattern happens each time motion detects an event. Hope this helps a little bit.

time=2024-02-12T18:40:06.306+01:00 level=DEBUG source=/home/pi/goprog/lockrd/lockrd.go:26 msg="lockrd called for movie file: [/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-1218-40-05.mp4]" time=2024-02-12T18:40:06.306+01:00 level=DEBUG source=/home/pi/goprog/lockrd/lockrd.go:29 msg="lockrd /home/pi/motion/ramdisk/2024-02-1218-40-05.mp4 exists after start" time=2024-02-12T18:40:06.306+01:00 level=DEBUG source=/home/pi/goprog/lockrd/lockrd.go:43 msg="lockrd calling rec_audio with:/home/pi/motion/ramdisk/2024-02-1218-40-05.mp4" time=2024-02-12T18:40:06.307+01:00 level=DEBUG source=/home/pi/goprog/lockrd/lockrd.go:26 msg="lockrd called for movie file: [/home/pi/motion/lockrd /home/pi/motion/ramdisk/2024-02-1218-40-05]" time=2024-02-12T18:40:06.307+01:00 level=DEBUG source=/home/pi/goprog/lockrd/lockrd.go:33 msg="lockrd second call which makes no sense and can be identified due to a missing file extension. Return immediately" time=2024-02-12T18:40:06.312+01:00 level=DEBUG source=/home/pi/goprog/rec_audio/main.go:45 msg="rec_audio called for movie file: [/home/pi/motion/rec_audio /home/pi/motion/ramdisk/2024-02-12__18-40-05.mp4]"

tomwhipple commented 8 months ago

I'm seeing similar behavior, with the on_movie_start and on_movie_end called multiple times, several seconds apart. It also appears that the movie may be getting overwritten at the same time.

tosiara commented 8 months ago

Do you also have defined both movie and extpipe?

tomwhipple commented 8 months ago

No, I don't have extpipe defined at all.

I think this was caused by setting max_movie_time to 11. If an event took longer than those 11 seconds, it seems like the event was reset, both triggering a new on_movie_end, and then beginning with a new on_movie_start as well as overwriting the video file from the prior interval. Now that I've removed that limit, the problem seems to have been resolved.

joeschmitt commented 8 months ago

I think you mean movie_max_time. The standard value is 120 (seconds) and I have set it to 60. So if your finding is right that every given value above 11 will show the observed behavior then it's a fault in my world.

tomwhipple commented 8 months ago

I'm using an older config syntax I think... https://github.com/tomwhipple/camera-watcher/blob/9f515789f90477660c5fa458efd1463fd869d245/etc/motion/motion.conf#L237

But in any case, I do think it's a bug, because I see the same behavior at every multiple of this setting. That might be OK if each video wasn't overwritten and '%v' incremented, but the current behavior caused a bunch of other issues downstream that had puzzled me for a while.

If I get the motivation I'll see about tracking it down further and submitting a PR, but no promises. :/

Mr-Dave commented 8 months ago

These are different issues and not a bugs.

First, specification of both a ext_pipe movie as well as movie_output causes two movies to be created and therefore the on_event's are called for each movie. This can not be observed via the OP because both of the movie file names are identical. If the movie names are changed between ext_pipe and movie_output is will become more apparent.

Next, there is an assumption was that the %v should be unique to each movie. This is not correct. %v is the event number not the movie number. Since there can be multiple movies per event, then if the name of the file only specifies an event number, it will get overwritten as new movies occur over the course of the event. Adding a time parameter to the movie file name will clarify this.

tomwhipple commented 8 months ago

I stand corrected. Further inspection shows that time was being set in the definition of %C, which I was then using for the filename, so I've added a minute/second parameter to the filename, which I expect will fully resolve my case.

Thanks @Mr-Dave!!