<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.staging.zoneminder.com/index.php?action=history&amp;feed=atom&amp;title=Exporting_Videos_Hack</id>
	<title>Exporting Videos Hack - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.staging.zoneminder.com/index.php?action=history&amp;feed=atom&amp;title=Exporting_Videos_Hack"/>
	<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=Exporting_Videos_Hack&amp;action=history"/>
	<updated>2026-05-03T14:28:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.staging.zoneminder.com/index.php?title=Exporting_Videos_Hack&amp;diff=14381&amp;oldid=prev</id>
		<title>Snake: moved from dummies guide</title>
		<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=Exporting_Videos_Hack&amp;diff=14381&amp;oldid=prev"/>
		<updated>2017-02-12T22:27:59Z</updated>

		<summary type="html">&lt;p&gt;moved from dummies guide&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Warning==&lt;br /&gt;
&lt;br /&gt;
Using the below is not recommended. It&amp;#039;s much easier to use Modect, and changing the source could lead to problems when upgrading ZoneMinder, if you are not extremely careful. However, I will leave the documentation here for posterity.&lt;br /&gt;
&lt;br /&gt;
==About==&lt;br /&gt;
&lt;br /&gt;
If you set cameras to &amp;#039;&amp;#039;&amp;#039;Record&amp;#039;&amp;#039;&amp;#039; and if you have enough high resolution cameras you will see your disk space fill&lt;br /&gt;
up fast. ZM records in 10 minute segments and captures every&lt;br /&gt;
frame as a jpeg. There is no compression of similar jpegs. Also, higher frame rate means more jpegs, more disk space.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;How do you avoid filling up the HDD with lots of cameras?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
You hack ZM. Use a filter which will take recordings from a specified&lt;br /&gt;
range and create a video for all matches. Then you make a filter &lt;br /&gt;
that will delete the events which have already had videos created.&lt;br /&gt;
&lt;br /&gt;
Or alternatively, you use motion detection (see below), recording only &lt;br /&gt;
when motion occurs (modect, not mocord).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;What do you mean filter?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
On the zm home console, there is a filter button. Click that, specify the range&lt;br /&gt;
of videos you want to create videos for, click the checkbox for &amp;#039;create video for&lt;br /&gt;
al matches&amp;#039;, submit/save, select it to run in the background, done.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;How is it going to make the video?&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
You can specify parameters in FFMPEG_OUTPUT_OPTIONS in the &lt;br /&gt;
options of zm. Make sure you are using ffmpeg, not avconv. You&lt;br /&gt;
also need to specify the path for ffmpeg. I used the ffmpeg binary.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I settled on the following path for ffmpeg&lt;br /&gt;
output options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;-c:v libx264 -preset ultrafast  /videosfolder/on/some/path/`date -d &amp;quot;-1 days&amp;quot; +&amp;quot;%Y%m%d-%H%M%S-%N&amp;quot;`.avi &amp;lt; /dev/null&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VP9 compresses best, but is slower to encode. If you have hardware optimized &lt;br /&gt;
for VP8 or VP9, maybe it will be better. Webm / MKV is great.&lt;br /&gt;
&lt;br /&gt;
Here are a couple others I found on the forums, before settling on libx264:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;-c:v libx264 -preset fast -crf 38 -vf hqdn3d=8:6:12&lt;br /&gt;
&lt;br /&gt;
* -r 1 -f image2 -i %07d.jpg -vcodec libvpx-vp9 -crf 18 &lt;br /&gt;
&lt;br /&gt;
* -r 25 -q:v 1  /mnt/where/my/videos/go/`date -d &amp;quot;-1 days&amp;quot; +&amp;quot;%Y%m%d-%H%M%S-%N&amp;quot;`.webm&lt;br /&gt;
&lt;br /&gt;
* -r 1 -f image2 -i %07d.jpg -vcodec libx264 -crf 18 -preset slower&amp;#039;&amp;#039; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More are on Zoneminder forums. The general idea is you can specify a codec with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
-c:v libx264&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
-c:v libvpx-vp9&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find any codec you like, and put it in -c:v and it should encode. Find one your hardware supports well, and go from there.&lt;br /&gt;
&lt;br /&gt;
So I used in my FFMPEG_OUTPUT_OPTIONS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;-c:v libx264 -preset ultrafast  /videosfolder/on/some/path/`date -d &amp;quot;-1 days&amp;quot; +&amp;quot;%Y%m%d-%H%M%S-%N&amp;quot;`.avi &amp;lt; /dev/null&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This works, but we have a problem. All videos are in one folder. &lt;br /&gt;
The next step was to make script [https://forums.zoneminder.com/viewtopic.php?f=32&amp;amp;t=24799&amp;amp;p=94709#p94709  Script for Deleting Old Exported Video Folders] that would take files daily from this folder&lt;br /&gt;
and put them into subdirectories labeled by the date. Then I made script [https://forums.zoneminder.com/viewtopic.php?f=32&amp;amp;t=24799  Script for Deleting Old Exported Video Folders pt.2 ] that would&lt;br /&gt;
measure the filesystem capacity of this folder (it is a dedicated drive) and if&lt;br /&gt;
the capacity is over a set amount, delete the oldest two days.&lt;br /&gt;
&lt;br /&gt;
This worked well, except that finding videos among the dozens in one day was slow.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The next step was based off of this post:&lt;br /&gt;
&lt;br /&gt;
[https://forums.zoneminder.com/viewtopic.php?t=13578  Event Video Saved to Custom Location by Default]&lt;br /&gt;
&lt;br /&gt;
So I edited zmvideo.pl and was able to get most of the cameras to export to their own&lt;br /&gt;
folders (see above forum posts). Though now I had to change ffmpeg output options to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;-c:v libx264 -preset ultrafast&amp;#039;&amp;#039; &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
as now the perl script is managing where the output folders go.&lt;br /&gt;
&lt;br /&gt;
I had to debug when setting up the perl script in order to make it work.&lt;br /&gt;
Permissions, and watching the /var/log/zm/{zmvideo,zmfilter}.log helped.&lt;br /&gt;
&lt;br /&gt;
All these steps for &amp;quot;Recording / Exporting Videos&amp;quot; are optional. It is recommended you use Motion Detection or Mocord, unless you enjoy pain.&lt;/div&gt;</summary>
		<author><name>Snake</name></author>
	</entry>
</feed>