strix

A simple web UI for motion
git clone https://www.brianlane.com/git/strix
Log | Files | Refs | LICENSE

commit 80badff40826241a53a15372c991acb7e74f2e81
parent 9c5f646e7c1f1093215d0b39cec8bab6663f5df8
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat, 25 Jun 2022 07:40:35 -0700

Add timelapse threshold of 5 minutes

If the event is longer than 5 minutes apply setpts to the ffmpeg filter
to create a 16x timelapse of the event.

Diffstat:
Msrc/strix/queue.py | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/strix/queue.py b/src/strix/queue.py @@ -29,6 +29,9 @@ from . import logger THUMBNAIL_SIZE = (640, 480) +# More than 5 minute events have a timelapse created +TIMELAPSE_MIN = 5 * 60 * 5 + def max_cores() -> int: return max(1, mp.cpu_count() // 2) @@ -118,8 +121,15 @@ def process_event(log: structlog.BoundLogger, base_dir: str, event: str, queue_t except Exception as e: log.debug("Failed to move debug images into ./debug/") - ffmpeg_cmd = ["ffmpeg", "-f", "image2", "-pattern_type", "glob", "-framerate", "5", "-i", "*.jpg", - "-vf", "scale=1280:-2", "-c:v", "h264", "-b:v", "2M", "video.m4v"] + ffmpeg_cmd = ["ffmpeg", "-f", "image2", "-pattern_type", "glob", "-framerate", "5", + "-i", "*.jpg", "-vf", "scale=1280:-2"] + + # Make a timelapse for events that are too long + if len(glob(f"{event_path}/*jpg")) > TIMELAPSE_MIN: + ffmpeg_cmd += ["-vf", "setpts=0.0625*PTS"] + + ffmpeg_cmd += ["-c:v", "h264", "-b:v", "2M", "video.m4v"] + log.debug("ffmpeg cmdline", ffmpeg_cmd=ffmpeg_cmd) # Make a movie out of the jpg images with ffmpeg try: