Processing of offline video files - tosiara/motion GitHub Wiki
Sometimes motion is useful to process a pre-recorded video file form a camera or a third-party recording system.
You can process a file with 25fps original frame rate at a higher rate, depending on your resources. For example, 250 fps.
The most efficient config so far found is:
netcam_url file:///tmp/CAM09_20220121090602_584364.avi
netcam_params capture_rate=250
mask_file mask.pgm
width 1920
height 1080
framerate 250
# motion detection params are reduced by 10
event_gap 6
movie_max_time 60
locate_motion_mode on
threshold 10
timelapse_interval 0
picture_output best
movie_output on
movie_passthrough on
movie_codec mp4
picture_filename %v
movie_filename %v
stream_port 8081
The recorded movies will be faster and there is no way to fix it from the motion side yet. But you can change the framerate using ffmpeg later:
# slow down 10x times
ffmpeg -itsscale 10 -i /tmp/01-20220126-1203.mp4 -codec copy /tmp/01-20220126-1203-fpsfixed.mp4
If you don't want to concatenate video files for processing, you can process them in batch mode using this script:
#!/bin/bash
CONF="/home/motion/motion-file.conf"
MOTION="/home/motion/src/motion"
for input_file in *.avi
do
input_file_safe=`echo $input_file | tr '/' '_'`
sed -i "s@netcam_url file://.*@netcam_url file://$input_file@g" "$CONF"
sed -i "s@picture_filename .*@picture_filename $input_file_safe-%v@g" "$CONF"
sed -i "s@movie_filename .*@movie_filename $input_file_safe-%v@g" "$CONF"
$MOTION -c "$CONF" -d 9 -n
done