vraa wrote:Any update on the 1000+ frame issue?
I will post my results in a bit, if I forgot someone remind me
But I figured out a way to get around the 1000 frame issue, I use "sort -V"
I am working on speeding up the video generation, It seems mencoder or libavc only uses 1 core for mpeg4 encoding, even with threads=4 passed as an option, I see the threads in htop, but cpu usage isnt maxed out
I'll perhaps try h264
Or better yet, rewrite the script to create all the sorted.lists from the monitors, and then use bash parallel to spawn off as many mencoder threads as we have cores on the box
I do not think it's possible to speed up the find command.
Code: Select all
#!/bin/bash
# Use this script for creating alarm video-files with zoneminder 1.25.0
# by Nightcrawler
# UPDATE the archive directory (YOURARCHIVEDIRECTORY)
#make temp directory
mkdir -p /tmp/alarmvideos
# Enumerate existing ZoneMinder Monitors
cameraname=(`ls /usr/share/zoneminder/events/ | grep '[a-zA-Z]'`)
cameraList=(`ls /usr/share/zoneminder/events/ | grep '[0-9]'`)
cameraNum=${#cameraList[@]}
eventsFolder=/usr/share/zoneminder/events/
echo Number of detected ZoneMinder Monitors: ${#cameraList[@]}
# Start working through all detected ZoneMinder Monitors
# The camera's get the name from the directory symlink on alphanumeric order!
# Alter every parameter entry BELOW THIS LINE called {cameraname[$i]} to ${cameralist[$i]} if you don't want this.
for (( i=0; i<${cameraNum}; i++ ));
do
echo Doing ZoneMinder Monitor: ${cameraname[$i]}
# Get a list of images for the last 24 hours from each of the detected ZoneMinder Monitors.
find $eventsFolder${cameraList[$i]} -mtime -3 -name \*capture.jpg > /tmp/alarmvideos/${cameraname[$i]}.list
# Sort output file for a consistent movie
sort /tmp/alarmvideos/${cameraname[$i]}.list -V -o /tmp/alarmvideos/${cameraname[$i]}-sorted.list
# use local time settings to order the events right.
#LC_ALL=C sort /tmp/alarmvideos/${cameraname[$i]}.list -d -o /tmp/alarmvideos/${cameraname[$i]}-sorted-time.list
# Encode each 24hr events into a movie Mpeg4 (edit with&hight (w=640:h=480) for your own cam settings)
# to edit the framespeed edit -FPS=5 and -OFPS 5 in the syntax
mencoder mf://@/tmp/alarmvideos/${cameraname[$i]}-sorted.list -mf w=640:h=480:fps=15:type=jpg -ovc lavc -lavcopts threads=4:vcodec=mpeg4 -ofps 15 -oac copy -o /tmp/alarmvideos/`date +%d`-${cameraname[$i]}.avi
echo video files ready, now moving to archive
# ------------------- start moving files ------------------
# create directory for year and month (if it's nog existing)
#mkdir -p /YOURARCHIVEDIRECTORY/images/videos/`date +%Y`/`date +%m`/
# Find avi's with actual events-move to new dir
#cd /tmp/alarmvideos
#find *.avi -size +5k -exec mv {} /YOURARCHIVEDIRECTORY/images/videos/`date +%Y`/`date +%m` \;
# Cleanup temp files
#rm -rf /tmp/alarmvideos/*.list
#rm -rf /tmp/alarmvideos/*.avi
# Cleanup after 1 year archive (optional feature!)
#find /YOURARCHIVEDIRECTORY/images/videos* -mtime +365 -exec rm {} \;
# ------------------- end moving files ------------------
echo DONE!
done
I have commented a lot of the original code out for my testing
I changed my location for events to fit Ubuntu style
I changed mtime to 3, for 3 days rather than 1 day
I changed the sort command and added -V for --version-sort
I changed my camera fps to 15, and added threads=4