video generation script

Forum for questions and support relating to the 1.24.x releases only.
Locked
rockmanchile
Posts: 15
Joined: Wed Jun 17, 2009 12:53 am

video generation script

Post by rockmanchile »

Hi all..

Im writing a little program to burn DVD`s over the web interface of ZM so the user can make bakcups of the alarms and events.

The thing is that i need to make a little script that can automatically converts the large number of jpegs images into an MPG or AVI video (just like ZM does from the console but from the command line)

I know that ZM uses ffmpeg for this purpose but until now i can´t get the correct command string.

The idea is simple, automatize the video generation.

Can you help me?

Best regards.

Eric.

P.S: Excuse my english.
User avatar
kingofkya
Posts: 1110
Joined: Mon Mar 26, 2007 6:07 am
Location: Las Vegas, Nevada

Post by kingofkya »

dvds taake forever to make but here us a start for you http://joerghaeger.de/webCDwriter/

http://www.zoneminder.com/forums/viewto ... +jpegs+mpg

also as far as ffmpeg

ffmpeg -i *.jpg output.mpeg
rockmanchile
Posts: 15
Joined: Wed Jun 17, 2009 12:53 am

Post by rockmanchile »

This is wath i get when i try to generate a video:

video-vigilancia:/var/www/zm/events/4/2214# ffmpeg -i *.jpg output.mpeg
FFmpeg version r11872+debian_0.svn20080206-17+lenny1, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-libfaad --enable-pp --enable-swscaler --enable-x11grab --prefix=/usr --enable-libgsm --enable-libtheora --enable-libvorbis --enable-pthreads --disable-strip --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-altivec --disable-vis --enable-shared --disable-static
libavutil version: 49.6.0
libavcodec version: 51.50.0
libavformat version: 52.7.0
libavdevice version: 52.0.0
built on Apr 28 2009 02:12:01, gcc: 4.3.2
Input #0, image2, from '001-capture.jpg':
Duration: 00:00:00.0, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 320x240 [PAR 1:1 DAR 4:3], 25.00 tb(r)
Unable to find a suitable output format for '002-capture.jpg'


Wath im doing wrong?
vanbosco
Posts: 11
Joined: Fri Feb 02, 2007 8:02 pm
Location: Italy

Post by vanbosco »

Hi rockmanchile, i have made 3 simple script for my personal use that uses cron to generate avi video from events using ffmpeg.
Perhaps you can use these script as a starting point for your purpose.

ab_trova_eventi:

Code: Select all

#!/bin/bash
DIR=/media/sda6/events_rolling/1/
DIR1=/media/sda6/events_intrepi/1/
DIR2=/media/sda6/events_sidXFCE/1/
DIR3=/media/sda6/events___lenny/1/

find "$DIR" -type d -exec ab_genera_video_lowres {} \;
find "$DIR1" -type d -exec ab_genera_video_lowres {} \;
find "$DIR2" -type d -exec ab_genera_video_lowres {} \;
find "$DIR3" -type d -exec ab_genera_video_lowres {} \;
ab_genera_video_lowres:

Code: Select all

#!/bin/bash
#copiare in /usr/bin assieme a trova_eventi
#min e max sono le ore di inizio e fine archiviazione 
min=6
max=22
#
###########################################
#
let "min -= 1"
for i in $@
do
cd $i
if [ -e "001-capture.jpg" ]; then
ora=$(date --reference=001-capture.jpg +%H)
nome_video_anno=$(date --reference=001-capture.jpg +%F)
nome_video_ora=$(date --reference=001-capture.jpg +%H)
nome_video_minuti=$(date --reference=001-capture.jpg +%M)
nome_video_secondi=$(date --reference=001-capture.jpg +%S)
nome_video=$nome_video_anno"_"$nome_video_ora"_"$nome_video_minuti"_"$nome_video_secondi
if [ $ora -gt $min ]; then
if [ $ora -lt $max ]; then
if [ ! -e "fatto" ]; then
mkdir /media/sda5/videosorveglianza/Bassa_Risoluzione/$nome_video_anno
chown vanbosco:vanbosco /media/sda5/videosorveglianza/Bassa_Risoluzione/$nome_video_anno
ffmpeg -r 4 -i %03d-capture.jpg -b 180k  /media/sda5/videosorveglianza/Bassa_Risoluzione/$nome_video_anno/$nome_video.avi
chown vanbosco:vanbosco /media/sda5/videosorveglianza/Bassa_Risoluzione/$nome_video_anno/$nome_video.avi
touch fatto
chown www-data:www-data fatto
fi
fi
fi
fi
done
video_lowres:

Code: Select all

#!/bin/bash
sudo ab_trova_eventi
video_lowres is in my home directory and is used by cron to launch the other scripts that are in /usr/bin.
In the ffmpeg string -r 4 is my capture rate and -b 180k is the bitrate of generated video, in this way three days of events from 6 am to 10 pm generates about 3.6 GB of video (320x240).

Best regards, Arnaldo.
Locked