jaysix79 wrote: ↑Mon Jul 17, 2017 3:20 pm
I see one potential problem in your shell script:
Code: Select all
DEST_DIR=/OUTPUT/zoneminder/${folder}/
I don't see where you define ${folder}. That will probably evaluate to an empty string, so your files get written to /OUTPUT/zoneminder/ whereas you presumably what /OUTPUT/zoneminder/something else.
Also, just to be pedantic:
jaysix79 wrote: ↑Mon Jul 17, 2017 3:20 pm
Code: Select all
for monitor in ${ZM_MONITORS_1} ; do
log=${LOG_DIR}/zm_mkvid.${monitor}.${NOW_STRING}.txt
${ZM_MKVID} \
--scale=0 \
--yesterday=${ZM_EVENTS_DIR}/${monitor} \
--timefmt="%b.%d.%Y-Time.%H.%M.%S" \
--outfmt='Dog_cam-1.from.{START_TIME}-to.{END_TIME}.mkv' > ${log} 2>&1
done
I would change that to:
Code: Select all
for monitor in ${ZM_MONITORS_1} ; do
log=${LOG_DIR}/zm_mkvid.${monitor}.${NOW_STRING}.txt
${ZM_MKVID} \
--scale=0 \
--yesterday=${ZM_EVENTS_DIR}/${monitor} \
--timefmt="%b.%d.%Y-Time.%H.%M.%S" \
--outfmt="${monitor}.from.{START_TIME}-to.{END_TIME}.mkv" > ${log} 2>&1
done
Notice I changed --outfmt in two ways: (1) I used ${monitor} instead of Dog_cam-1. What you have is fine, since there is only one monitor. But if you ever add another monitor, then you could possibly overwrite previously-written videos. (2) I used double quotes (") instead of single quotes ('). This allows the shell (bash) to expand the ${monitor} variable. (Not to be confused with the {START_TIME} and {END_TIME} tokens - those are evaluated by the Python script, not by the shell. In hindsight, perhaps using curly brackets wasn't the best choice.)
jaysix79 wrote: ↑Mon Jul 17, 2017 3:20 pm
thank you it works well with this... took me a while to figure how to edit my SH file but it works. its kinda messy
another question or request would be is it possible to run this script to convert video that was taken in the last X amount of hours...... lets say i just want to convert the last 3 hours so that i can upload on my cloud and share it....
I think what you're asking for is a parameter similar to --yesterday, say --last-x-time=3h, or more generally, --start-datetime and --end-datetime parameters. This isn't terribly hard to do. However, my thought was that the directory structure Zoneminder uses to store images is in my mind fairly intuitive. Here's an example from my own system:
/var/lib/zoneminder/events/Front_Porch_Camera/17/07/20/07/28/54
The /var/lib/zoneminder/events might differ from one platform to the next. But below that, I believe the tree is always the same. And the format is events/monitor_id/year/month/day/hour/minute/second/<JPG files>.
Just look at the timestamps on my jpg files:
Code: Select all
$ ls -lah /var/lib/zoneminder/events/Front_Porch_Camera/17/07/20/07/28/54/
... (snip) ...
-rw-r--r-- 1 apache apache 122K Jul 20 07:28 00057-capture.jpg
-rw-r--r-- 1 apache apache 120K Jul 20 07:28 00058-capture.jpg
-rw-r--r-- 1 apache apache 121K Jul 20 07:28 00059-capture.jpg
-rw-r--r-- 1 apache apache 121K Jul 20 07:28 00060-capture.jpg
-rw-r--r-- 1 apache apache 122K Jul 20 07:28 00061-capture.jpg
... (snip) ...
See how they are all Jul 20 (implicitly 2017) 7:28, and they live in 17/07/20/07/28 tree?
That is why I specified the --event-dir parameter as a directory tree and/or glob pattern. That's why you can specify, for example, --event-dir=/var/lib/zoneminder/events/Front_Porch_Camera/17/07/20 and it will grab everything for July 20, 2017. But if I instead said --event-dir=/var/lib/zoneminder/events/Front_Porch_Camera/17/07/20/07, it would only grab everything from 7:00am to 7:59am on July 20, 2017. Don't forget you can specify --event-dir multiple times and/or use shell wildcards. (I've been a Linux guy for 20+ years, so doing shell stuff is second nature to me. It's easy for me to forget glob patterns and such may not be second nature to everyone else!)
Take a look at "man date" (or web search example usage of the date shell command). With clever use of using the output of the date command within the --event-dir argument, you can create this behavior yourself. Depending on how fancy you want to get, it could get ugly to do it in your shell wrapper script; so that's an argument for using Python's much more convenient date and time manipulation routines to do it...
The code itself isn't hard, I just have to give some thought how the user interface will look. For example, if I were to add --start-datetime --end-datetime parameters, do I then change the behavior of --event-dir? If keep --event-dir's behavior as-is, and someone uses both --event-dir
and the new --start/end params, which takes precedence?
I'll give it some thought, though I'm also open to input.