Best way to extract video for time range?

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
bigf
Posts: 2
Joined: Fri Jul 09, 2021 1:22 pm

Best way to extract video for time range?

Post by bigf »

Hi all,
Currently on zoneminder v1.34.25 on debian 10 with 4 cameras
I've been running zoneminder for the past three years, and I've had an event actually happen last week. Unfortunately, I did not realize that zoneminder falsely claims the functionality to either scrub footage or download video, so I'm kind of stuck and frustrated.
  • Going to the date/time with "Montage Review" gives me a blank white screen on firefox and /sometimes/ gives me a 500 error on Chromium, so that won't work
  • Selecting any amount of clips in the "Event list" view and clicking "Download video" gives me a zip without any image or video data, I guess thats not a very useful feature then
  • "Exporting" clips from the event list works, but I want to know whether there is a real way of getting video before doing this by hand.
So, is there a dedicated part of the zoneminder micro-services model that produces these things that I can run locally on the database, or am I going to have to look through each frame by hand to figure out when it happened?

Thanks for your time

Mini-rant: Apology for the sarcasm, but this made me give up on zoneminder. I understand that this is a foss project written by awesome volunteers, but I no longer think this can be used in production as it is not worth the hassle. I BEG you to tell me I've configured it incorrectly so it works properly, otherwise I will probably not keep zoneminder for very long.
LBDG
Posts: 20
Joined: Mon Jun 23, 2014 10:17 am

Re: Best way to extract video for time range?

Post by LBDG »

Hy

I have a solution which works for me.

See link
viewtopic.php?f=9&t=30216

Works with passthrough and 1.34 but had a previous version working with jpeg stills
bigf
Posts: 2
Joined: Fri Jul 09, 2021 1:22 pm

Re: Best way to extract video for time range?

Post by bigf »

Hi LBDG,
this looks like a great tool, but unfortunately it doesn't look like it will work from me.
From what I understand, the ffmpeg command here expects each directory to have a *-video.mp4 file as described by $videos, for whatever reason my zoneminder does not generate those files.
This did however make me more comfortable with usage of ffmpeg, and turns out its very easy to stitch together image files with ffmpeg, so thank you anyway!

In case anyone else encounters the same problem, below is a rudimentary script which can stitch together all image files in a zm directory, starting with whatever you specify in firstEvent and lastEvent, and produces the stitched mp4 as <event number>.mp4 in your current directory. You will have to find out which event you need though (either by looking at the individual files and matching the dates you need, or through the web interface), as I can't be arsed to do SQL at the moment.

Code: Select all

#!/bin/bash

# edit these to desired values
zmDir="/path/to/zm"
cameraName="yard"
selectedDate="2021-01-01"
firstEvent="20000"
lastEvent="21000"
frameRate="4"
resolution="1280x720"

# don't edit anything else
eventDirs="$(ls $zmDir/$cameraName/$selectedDate)"

for event in $eventDirs
do
    if [[ $event < "$firstEvent" ]]
    then
	continue
    fi
    if [[ $event > "$lastEvent" ]]
    then
	break
    fi
    curdir="$zmDir/$cameraName/$selectedDate/$event"
    ffmpeg -r $frameRate \
    	   -s $resolution \
	   -i $curdir/%05d-capture.jpg \
	   -vcodec libx264 \
	   -crf 25 \
	   ./$event.mp4
    echo "info: finished $event"
done

LBDG
Posts: 20
Joined: Mon Jun 23, 2014 10:17 am

Re: Best way to extract video for time range?

Post by LBDG »

All my cameras have mp4 streams so JPG stills makes no sense to me any more. If cameras use mp4 streams, I don't understand why anyone would still use jpegs and not enable passthrough only.

Anyways before mp4 passthrough (zm 1.28), I did have a front end PHP script for stitching jpegs. Similar to your script but with a HTML front end and dates instead of frames (did the sql lookup)

This script worked on ZM 1.28. I never tried it with 1.34 though with JPG stills.
https://github.com/lbdc/zm-movie
Post Reply