This is a collection of tools for manipulating output from Tenvis IP cameras. Works fine on Windows and GNU/Linux with Python 2.6.x-2.7.x
Takes JPEGs dumped by an IP camera and sorts them into subdirectories in the following format:
camera name/year/month/day/timestamp.jpg
camsort will also embed the timestamp into the bottom left-hand corner of the image using the droid sans mono
font (this can be changed if this font is unavailable). JPEGs are compressed if jpegtran
is available.
Takes the output of camsort and stitches the images into an MPEG-4 video file (1 frame per second). cam2mpg also creates backups before operating on a directory. These backups are stored in a .backup subdirectory of a given month. cam2mpg operates on yesterdays set of images by default, although it can be made to operate on an arbitrary directory. Run python cam2mpg --help
for full usage instructions.
- ffmpeg (compiled with libjpeg and x264 support)
- jpegtran (typically bundled with libjpeg-turbo)
You should probably have a read of camsort before running it, as you might want to change the font used when timestamping files. Default is Google DroidSansMono.ttf (assumed to be living in /usr/share/fonts/truetype/DroidSansMono.ttf).
camsort and cam2mpg should be placed in the directory where the IP camera uploads its images to. I personally recommend setting up two cronjobs as such:
@hourly cd path/to/toplevel/camera/dir; python camsort.py &> /dev/null
10 0 * * * cd path/to/toplevel/camera/dir; python cam2mpg.py &> /dev/null
The first entry runs camsort every hour, and the second runs cam2mpg ten minutes after midnight allowing it to operate on the previous day.
This toolset, with the exception of progressmeter.py, is licensed under the 3-clause BSD license. progressmeter.py is licensed under the PSF license.
This toolset has only been tested with one model of camera: the JPT3815W. While cam2mpg was recently rewritten to be conservative about what it does, camsort is still a little rough around the edges. I am not responsible for any data loss that may occur through the use of this toolset. Always test against a small sample of images first before deploying, and read the output of python cam2mpg --help
.