I have a couple of Wifi IP cameras that I'd like to record output from. I can either capture an image or (I think) an RTSP stream.
I just want to store them somewhere I can refer back to them in future if needed. Ideally making efficient use of storage.
Any suggestions?
At the moment I have ZoneMinder installed but it's quite big and heavy, I frequently find it isn't running (eg after a system update) and it stores all the images as JPEGs rather than as a movie, where I would have thought that the latter would be rather more efficient.
It crossed my mind I could probably script something that captured images at a regular frame rate and then turned batches of them into videos later, but there's probably a way to avoid reinventing the wheel.
Note: The camera is constantly seeing motion (it's view is through a tree apart from anything else) so motion detection isn't much use unless it can be quite intelligent.
On 12/11/15 10:54, Mark Rogers wrote:
I have a couple of Wifi IP cameras that I'd like to record output from. I can either capture an image or (I think) an RTSP stream.
I just want to store them somewhere I can refer back to them in future if needed. Ideally making efficient use of storage.
Any suggestions?
At the moment I have ZoneMinder installed but it's quite big and heavy, I frequently find it isn't running (eg after a system update) and it stores all the images as JPEGs rather than as a movie, where I would have thought that the latter would be rather more efficient.
I personally would have thought that JPGs were better for storage space than a movie, esp if you want a snapshot every minute, hour, second (whatever). Also, jpgs would tend to be named with the timestamp embedded in them, or at the very least, the O/S would store the created time. Not something you'd necessary get from a movie. However, if you go down the batch file to change jpgs into a movie, there's a bunch of articles on-line about how to do things like this. One search phrase would be "use a rapsberrypi to make a time-lapse video", or "make a stop motion animation". There are various encoders, and ways of doing it so I won't go into it (as I'd have to google).
It crossed my mind I could probably script something that captured images at a regular frame rate and then turned batches of them into videos later, but there's probably a way to avoid reinventing the wheel.
Note: The camera is constantly seeing motion (it's view is through a tree apart from anything else) so motion detection isn't much use unless it can be quite intelligent.
If I recall correctly, some of the camera software (and I thought it was Zoneminder, but I could be wrong), has a facility to add a user-defined mask to the image it sees. This mask is excluded from motion detection. This might help. I've never done this so I don't know how easy it is.
I'm sure there must be a way of automating a task (using crontab?) to check if Zoneminder is still running, and starting it if it isn't. Checking for a PID, or grepping PS and starting it if it's not there?
Good luck. Steve
On 12 November 2015 at 11:11, steve-ALUG@hst.me.uk wrote:
I personally would have thought that JPGs were better for storage space than a movie, esp if you want a snapshot every minute, hour, second (whatever).
My thinking was that movie compression works by storing deltas between images rather than keeping each frame in full so should be "smaller". I can't see how storing each image in full would be better, and indeed movies only store key frames periodically (to assist with random access) to keep the file size down.
Also, jpgs would tend to be named with the timestamp embedded in them, or at the very least, the O/S would store the created time. Not something you'd necessary get from a movie.
The camera can embed a timestamp in the image (ie overlaid on the image, not just as Exif data) so that should solve this.
However, if you go down the batch file to change jpgs into a movie, there's a bunch of articles on-line about how to do things like this.
Thanks, I'll go hunting!
If I recall correctly, some of the camera software (and I thought it was Zoneminder, but I could be wrong), has a facility to add a user-defined mask to the image it sees. This mask is excluded from motion detection.
Yes it can, and actually the camera can do this internally too, but viewing through a tree means the whole image is subject to movement, even though there is enough visibility through the tree to always be able to see the objects of interest. (The view is to a boat on a mooring, and that has the second issue that the water is always rippling and the boat drifts around a bit as well. What I'd like would be to detect the absence of a boat (ie it was pinched!) but just the fact that it's moving isn't cause for concern - indeed lack of movement would be!)
I'm sure there must be a way of automating a task (using crontab?) to check if Zoneminder is still running, and starting it if it isn't. Checking for a PID, or grepping PS and starting it if it's not there?
I've used the likes of monit in the past and can go down this route, but ZoneMinder seems quite heavy for my needs and dependent on lots of libraries that I don't otherwise need when I'm not really doing all that much with it. It might still be the best option though. (It would appear that Ubuntu 15.10 has the latest version, where 15.04 had quite an old version that meant I had to use a PPA version to get some key functionality (I can't remember what that was now).)
Mark
On 12 November 2015 at 11:56, Mark Rogers mark@more-solutions.co.uk wrote:
My thinking was that movie compression works by storing deltas between images rather than keeping each frame in full so should be "smaller".
I have done some experiments (see below) using cvlc to capture the RTSP stream from the camera.
An hour's worth of data in .ts (MPEG) video format comes in at 312MB. An hour's worth of photos (captured at a rate of 1 every 4 sec by zoneminder) comes in at 640MB.
That's not necessarily a fair comparison as I don't know what frame rate the video is at (how do I find out?) but it's a good saving so far.
So, for reference, what I did was create the following script:
#!/bin/sh d=$(date +"%Y/%m/%d") f=$(date +"%Y%m%d-%H%M%S") d="/home/mark/IPCam/$d" for ip in 128 129 ; do ip=192.168.1.$ip mkdir -p $d/$ip cvlc -q --no-audio rtsp://$ip:554/11 --sout=file/ts:$d/$ip/$f.ts -I dummy --stop-time=905 vlc://quit 2>/dev/null & done
I'd by lying if I claimed to fully understand it, as it's mostly cobbled together from commandlines I found online, but the gist of it is that it captures a 905s stream (just over 15 mins) on each of two cameras (192.168.1.128 / 129) and stores it as (eg) ~/IPCam/2015/11/12/192.168.1.128/20151112-234501.ts. I run this script cron crontab every 15 mins, thus capturing video in 15min chunks.
However, reviewing the results from last night, out of 23 15 min captures from one camera, 7 have zero byte file length; from the other camera it's 5 out of 23, and there's no obvious overlap between the two cameras as to which failed to indicate a network issue.
So, does anyone have any idea what I can do to make it more robust?
Mark
On Fri, 13 Nov 2015 09:21:17 +0000 Mark Rogers mark@more-solutions.co.uk wrote:
On 12 November 2015 at 11:56, Mark Rogers mark@more-solutions.co.uk wrote:
My thinking was that movie compression works by storing deltas between images rather than keeping each frame in full so should be "smaller".
I have done some experiments (see below) using cvlc to capture the RTSP stream from the camera.
An hour's worth of data in .ts (MPEG) video format comes in at 312MB. An hour's worth of photos (captured at a rate of 1 every 4 sec by zoneminder) comes in at 640MB.
That's not necessarily a fair comparison as I don't know what frame rate the video is at (how do I find out?) but it's a good saving so far.
VLC will play a .TS file. It will also give you information about the file - Ctrl I will display that.
On 13/11/15 09:21, Mark Rogers wrote:
On 12 November 2015 at 11:56, Mark Rogers mark@more-solutions.co.uk wrote:
My thinking was that movie compression works by storing deltas between images rather than keeping each frame in full so should be "smaller".
I have done some experiments (see below) using cvlc to capture the RTSP stream from the camera.
An hour's worth of data in .ts (MPEG) video format comes in at 312MB. An hour's worth of photos (captured at a rate of 1 every 4 sec by zoneminder) comes in at 640MB.
You were right & I was wrong!
That's not necessarily a fair comparison as I don't know what frame rate the video is at (how do I find out?) but it's a good saving so far.
So, for reference, what I did was create the following script:
#!/bin/sh d=$(date +"%Y/%m/%d") f=$(date +"%Y%m%d-%H%M%S") d="/home/mark/IPCam/$d" for ip in 128 129 ; do ip=192.168.1.$ip mkdir -p $d/$ip cvlc -q --no-audio rtsp://$ip:554/11
--sout=file/ts:$d/$ip/$f.ts -I dummy --stop-time=905 vlc://quit 2>/dev/null & done
I'd by lying if I claimed to fully understand it, as it's mostly cobbled together from commandlines I found online, but the gist of it is that it captures a 905s stream (just over 15 mins) on each of two cameras (192.168.1.128 / 129) and stores it as (eg) ~/IPCam/2015/11/12/192.168.1.128/20151112-234501.ts. I run this script cron crontab every 15 mins, thus capturing video in 15min chunks.
However, reviewing the results from last night, out of 23 15 min captures from one camera, 7 have zero byte file length; from the other camera it's 5 out of 23, and there's no obvious overlap between the two cameras as to which failed to indicate a network issue.
So, does anyone have any idea what I can do to make it more robust?
Mark
My thoughts, qualified by, I've never tried this before. I'd be tempted to...
Try to get it working with just one camera first. Split it into two separate crontab jobs. If you're doing 15 minute periods, stagger by about 7 minutes. That way they're not going to be both writing to disk at the same time and thus going slow. Add some logging. e.g. echo "starting cronjob at" >>MyLogFile echo date >>MyLogFile
I think the -q flag on cvlc makes it quiet. Try it without q, or with v (verbose) instead. Instead of running it in the background, run it in the foreground. I think this will result in its output going in the system log. You're redirecting errors to /dev/null. To work out why it's not working, redirect to a/the log file.
Good luck Steve
On Thu, 12 Nov 2015 10:54:23 +0000 Mark Rogers mark@more-solutions.co.uk wrote:
I have a couple of Wifi IP cameras that I'd like to record output from. I can either capture an image or (I think) an RTSP stream.
I just want to store them somewhere I can refer back to them in future if needed. Ideally making efficient use of storage.
Any suggestions?
I've just read the latest issue of the MagPi magazine (issue 39) where they use a Pi (unsurprisingly) to capture images and turn them in to a video stream so some of the ideas might be useful for you.