Skip to content

Instantly share code, notes, and snippets.

@fabioam
Last active February 3, 2017 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioam/3b47f84fac0a8e4f5b7bffc9b5109647 to your computer and use it in GitHub Desktop.
Save fabioam/3b47f84fac0a8e4f5b7bffc9b5109647 to your computer and use it in GitHub Desktop.
Zoneminder export mp4 from images (events)
#/bin/bash
#
# Export ZoneMinder events (images) into MP4 file
# Execute this script inside events/ directory
# directory where MP4 videos should be exported
EXPORT_VIDEO_PATH="/home/user/zoneminder/mp4"
for camera in $(find -maxdepth 1 -type l |sort); do
for day in $(find '$camera/' -mindepth 3 -maxdepth 3 -type d -mtime +1 |sort); do # apenas diretorio criados a mais de um dia atras
# for day in $(find $camera/ -mindepth 3 -maxdepth 3 -type d |sort); do
echo "********************************************"
echo "Camera: ${camera/\.\//}"
file="$day/images_of_the_day.txt"
echo "Dia: $day"
if [ -f "$file" ]
then
echo "Lista de arquivos já existe. IGNORADO."
else
echo -n "Criando lista de imagens."
find $day/ -name "*capture.jpg" -exec echo "file '`pwd`/{}'" \; | sort > $day/images_of_the_day.txt
echo "...OK"
fi
f="${day/\.\//}"
videoname=`echo $f|sed 's/\\//-/g'`
videoname="$videoname.mp4"
# videoname_full_path="$day/$videoname"
videoname_full_path="$EXPORT_VIDEO_PATH/$videoname"
echo $videoname_full_path
if [ -f "$videoname_full_path" ]
then
echo "Vídeo já criado para este dia. IGNORADO."
else
echo -n "Criando video..."
ffmpeg -r 4.5 -f concat -safe 0 -i $file $videoname_full_path
echo "...OK"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment