Archive Events to MPEG Video

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
steidley
Posts: 2
Joined: Sat Jan 08, 2005 9:23 pm

Archive Events to MPEG Video

Post by steidley » Sat Jan 08, 2005 9:40 pm

I've been trying to write a script to automatically archive events to mpeg video files to a specific directory (based on the day of the event) and then remove the event from zoneminder.

The main reason I've been wanting to do this is to get better hard drive usage so I can store 30 days or more and to organize the video for easy burning to cd if it is necessary.

I haven't had much luck and any help would be appreciated.

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder » Sat Jan 08, 2005 11:31 pm

I would suggest doing it in perl, and either getting your script to use zmvideo.pl to generate the video or even just extending it. You want to generate the video file and then remove the event from the DB or fielsystem, once gone from one or the other zmaudit should clean up everything else.

Phil

SyRenity
Posts: 301
Joined: Mon Jan 24, 2005 2:43 pm

Post by SyRenity » Wed Mar 09, 2005 10:26 pm

Hello.

I recently had to free disc space really fast from the video server, so I quick hacked a php script, which will convert all of the events, and will erase the JPGs. Currently, it dumps all of the videos in the monitor dir (where all of the events are stored, in the directories named on their IDs). It required slight modification of video.pl, and several more modifications of zm_html_view, and zm_funcs. The script behaved poorly when launched from browser, so I had to allow running it from the shell (another modification of zm_config which removed the authorization), in a form of php index.php view=compressall.

In short, it's really not ready for distribution, but if I already on it, perhaps you will suggest some must have features, which will make it more usable. One of them is to allow using the generated videos from the ZM, meaning script will only erase the JPGs, but will leave the dirs and DB entries intact, and the ZM will recognize the mpeg and will simply play it back, without any fancy per-frame analysis features.

BTW - it really makes a huge difference in the disk space usage - from 92% to 22% (80 GB in total), so it compensates the loss of all the per-frame features.

steidley
Posts: 2
Joined: Sat Jan 08, 2005 9:23 pm

Post by steidley » Sat Mar 12, 2005 1:32 pm

That sounds great. As long as it is self-contained and can be run from a cron job, it sounds like it will do exactly what I need.

SyRenity
Posts: 301
Joined: Mon Jan 24, 2005 2:43 pm

Post by SyRenity » Tue Mar 22, 2005 5:27 pm

Hello Phil.

I'm looking for an easy way to integrate this script in the existing ZM, so I would like to define it via the filter "execute command on event". Could you please elaborate, how exactly ZM executes the command, e.g.
"compress.sh /var/lib/zm/events/12345" ?

Thanks you.

User avatar
zoneminder
Site Admin
Posts: 5220
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder » Tue Mar 22, 2005 7:41 pm

That is correct, though I would advise given the full path to your script. I would also advise disabling it initially and just writing some debug to a file to ensure that it is doing what you expect before you set it free on real events!

Phil

Baylink
Posts: 330
Joined: Sun Jun 19, 2005 3:19 am

I really need this bad...

Post by Baylink » Thu Jun 23, 2005 2:40 pm

any current movement on it? Is it compatible with current versions (1.21.1+)?

Could you post the script? ;-)

Baylink
Posts: 330
Joined: Sun Jun 19, 2005 3:19 am

No, never mind...

Post by Baylink » Sat Jun 25, 2005 4:43 pm

As noted in another thread, I'm about 90% done with this -- it turned out to be much less complicated than I'd feared, since Phil gives good schema. :-)

I got hung up getting a good ffmpeg-and-dependencies setup in, since that machine was off-line (it's going on-line Monday morning), but as soon as I get that finished, I should have a "convert yesterday's events to MPEG and burn them on a CD with useful names" script ready to post.

When I do, I'll start a new thread here, so it doesn't get lost.

Baylink
Posts: 330
Joined: Sun Jun 19, 2005 3:19 am

Post by Baylink » Wed Jul 06, 2005 7:31 pm

Posting that script now...

User avatar
krzys31337
Posts: 65
Joined: Wed Jul 06, 2005 7:43 pm
Location: Poland,Warsaw N 52°09'10" E 20°55'09"

Post by krzys31337 » Sun Sep 18, 2005 11:44 am

Hi!

After some poking around with mencoder i've figured that creating avi/divx files saves much space in zm boxes.

This script removes jpg older than 24 hours (still I would like to save the one with "Thunibal" jpg for easy navigating through events).

Another script just like that one with "mencoder" invocation crates avi file.

Maybe some of this functionallity shoud be included in ZM?

Code: Select all

#!/bin/sh

touch /tmp/szukaj.$$

for i in $( echo 'select MonitorId,Id from Events WHERE DATE_SUB(CURDATE(),INTERVAL 24 HOUR) >= StartTime AND EndTime is not NULL;' | /usr/bin/mysql -u zm --password=zmpassword zm --silent --batch | tr \\t - ) ; do
    if [ -d "/var/lib/zm/events/$( echo $i | tr - '/')/" ]; then
    nice find /var/lib/zm/events/$( echo $i | tr - '/' )/ -name \*.jpg | xargs rm
    fi
done
--
Best Regards and sorry for my poor english...

ekiboy69
Posts: 101
Joined: Tue Jun 22, 2004 9:26 pm
Location: Kaarina-Finland

Where is it?

Post by ekiboy69 » Thu Sep 29, 2005 6:41 pm

Baylink wrote:Posting that script now...
Hello,

I feel a bit stupid but where is it posted? I cannot see the video creation script.

I need a way to create a mpeg video of all events.

User avatar
fernando
Posts: 240
Joined: Thu Jul 10, 2003 6:00 pm

Post by fernando » Mon Oct 03, 2005 5:30 am

yes i have made same but is on PHP. and run by cron jobs.

the main script write all the videos "based on specific search" to a usb disk, so need to detect it "yes a plug&play on php". look if is format, how much space, do not copy prossesed events and many other things. like the use of ffmpeg directly.
have some bugs,, and i dont have much time. and the main problem i dont have program structure.. so is imposible even by me to see how its works.. :) and needs database modifications.

iam going to add a web setup. and the posibility to write cd or dvd and copy to networks drives.

i give you ideas.. wasnt so dificult .. even by me that i dont know much programing and linux. i have read a lot ..
Fernando

ekiboy69
Posts: 101
Joined: Tue Jun 22, 2004 9:26 pm
Location: Kaarina-Finland

I would be glad to get some help

Post by ekiboy69 » Mon Oct 03, 2005 7:06 am

fernando wrote: the main script write all the videos "based on specific search" to a usb disk, so need to detect it "yes a plug&play on php". look if is format, how much space, do not copy prossesed events and many other things. like the use of ffmpeg directly.
This would be very nice to have.

I have a problem already with ffmpeg. I am not able to generate MPEG2 videos with ffmpeg so that the video would be proper, standard obeying MPEG2 stream.

In many threads the "video generation error" has got to do with the fact that without extra parametres ffmpeg refuses to generate a video if the frame rate is less than 25 FPS. This is because of the specification.

There is a workaround in thread
http://www.zoneminder.com/forums/viewto ... mpeg+video
that uses the -strict -option. That however creates a video that _does not conform to MPEG2 -specification_ and therefore is not playable with commercial video player software (windows machines).

I have tried to find out what the -strict option really does but it is not documented on ffmpeg man pages.

Any hints how to generate a proper MPEG2 video?

SyRenity
Posts: 301
Joined: Mon Jan 24, 2005 2:43 pm

Post by SyRenity » Sun Oct 09, 2005 6:12 pm

Hi.

This is very interesting - perhaps it's the reason I was never able to stream a video? This is what the FFMPEG manual says:

"
`-strict strictness'
how strictly to follow the standards
"

So I guess, the strict of 1 is the most loosest one, which is not playable by Windows Media Player?

skydiver
Posts: 86
Joined: Wed Jun 16, 2004 7:15 pm

Post by skydiver » Mon Oct 24, 2005 6:02 pm

I am using 1.21.3 anb I love the new export ability. I would like to easily create the video files for archived events so that I can export them via the export function. I am trying to run this ffmpeg command:

/usr/sbin/ffmpeg -hq -intra -strict -1

on each archived event via the saved filter interface but am not having any luck.

I do not wish to delete anything (events, jpeg, etc.) I need to preserve all original events in their original formats for forensic investigative purposes.

Does anyone have any suggestions on how to perform video creation on a filter list of events so that they may be exported via the eport feature?

Skydiver
Last edited by skydiver on Sun Nov 06, 2005 12:15 am, edited 2 times in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests