Archive Events to MPEG Video
Archive Events to MPEG Video
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.
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.
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
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.
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.
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
I really need this bad...
any current movement on it? Is it compatible with current versions (1.21.1+)?
Could you post the script? ;-)
Could you post the script? ;-)
No, never mind...
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.
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.
- krzys31337
- Posts: 65
- Joined: Wed Jul 06, 2005 7:43 pm
- Location: Poland,Warsaw N 52°09'10" E 20°55'09"
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?
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...
Best Regards and sorry for my poor english...
Where is it?
Hello,Baylink wrote:Posting that script now...
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.
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 ..
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
I would be glad to get some help
This would be very nice to have.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.
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?
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
/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.