From ac39be33f50403974476c9baa638b71a55291754 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 3 Feb 2022 17:24:33 -0500 Subject: [PATCH] Don't assume filename of mp4. We store it in the event record for a reason. Fixes #3422 --- scripts/zmfilter.pl.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index 960c090cb..3fb286039 100644 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -464,15 +464,18 @@ sub generateImage { my $event_path = $Event->Path(); my $capture_image_path = sprintf('%s/%0'.$Config{ZM_EVENT_IMAGE_DIGITS}.'d-capture.jpg', $event_path, $frame->{FrameId}); my $analyse_image_path = sprintf('%s/%0'.$Config{ZM_EVENT_IMAGE_DIGITS}.'d-analyse.jpg', $event_path, $frame->{FrameId}) if $analyse; - my $video_path = sprintf('%s/%d-video.mp4', $event_path, $Event->{Id}); + my $video_path = sprintf('%s/%s', $event_path, $Event->{DefaultVideo}); my $image_path = ''; # check if the image file exists. If the file doesn't exist and we use H264 try to extract it from .mp4 video if ( $analyse && -r $analyse_image_path ) { + Debug("Using analysis and jpeg exists $analyse_image_path"); $image_path = $analyse_image_path; } elsif ( -r $capture_image_path ) { + Debug("Using captures and jpeg exists $capture_image_path"); $image_path = $capture_image_path; } elsif ( -r $video_path ) { + Debug("mp4 exists $video_path"); my $command ="ffmpeg -nostdin -ss $$frame{Delta} -i '$video_path' -frames:v 1 '$capture_image_path'"; #$command = "ffmpeg -y -v 0 -i $video_path -vf 'select=gte(n\\,$$frame{FrameId}),setpts=PTS-STARTPTS' -vframes 1 -f image2 $capture_image_path"; my $output = qx($command); @@ -486,6 +489,8 @@ sub generateImage { } else { $image_path = $capture_image_path; } + } else { + Debug("No files found at $analyse_image_path, $capture_image_path or $video_path"); } return $image_path; } @@ -723,7 +728,7 @@ sub substituteTags { if ( -e $path ) { push @$attachments_ref, { type=>'image/jpeg', path=>$path }; } else { - Warning("Path to first image does not exist at $path"); + Warning("Path to first image does not exist at $path for image $first_alarm_frame"); } }