Stories
Slash Boxes
Comments

SoylentNews is people

The Fine print: The following are owned by whoever posted them. We are not responsible for them in any way.

Journal by fliptop

A year ago I wondered if it was possible to use a cheap IP camera I had to record the wildlife activity (mainly deer) on my property. As you may know, most of the cheaper (<$100) IP cameras have shitty firmware and require Java or (even worse) ActiveX in order to view video. Additionally, the software that comes w/ these cameras requires Windows, and since I run Linux that's not going to work.

For what I wanted, though, I figured continuous footage was overkill and started to investigate if it were possible to just pull an image every 10 seconds or so, store it somewhere, then use ffmpeg to tie them all together into an mpeg once a day. All IP cameras have the ability to grab snapshots so I set about figuring out how to accomplish this.

Turns out it's pretty simple. Using a little perl and a few cron commands I was able to get everything working and, once it was put into motion, needed very little babysitting to work.

So over the next couple of weeks I'm going to write about what hardware I used (and what I don't recommend using), how I set my server up, show the code I used, and some results.

First off, some specifications:

  • the cameras must be cheap, less than $100
  • I wanted to use wireless cameras so I didn't have to run a bunch of CAT5 throughout my house
  • the camera I had at the time did not include infrared, but the ones I wound up buying later did, and they were rated at 0 lux
  • I chose to control everything w/ an old computer running CentOS 6 (basic server setup)

Coming up next, the cameras I used.

Display Options Threshold/Breakthrough Reply to Article Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by clone141166 on Saturday March 01 2014, @02:38AM

    by clone141166 (59) on Saturday March 01 2014, @02:38AM (#8938)

    Sounds like a fun project fliptop, I will be interested to read more about how you set it all up and managed to pull the images off the cameras. I wouldn't mind setting up some sort of cheap surveillance camera system where I am living at the moment.

    • (Score: 1) by LukeSkywalker on Saturday March 01 2014, @10:15PM

      by LukeSkywalker (1190) on Saturday March 01 2014, @10:15PM (#9259)

      I have a couple of IP camera's I am not using for anything at the moment so I would be interested in anything you would like to share on your project. I have a few ideas where I can put them to good use.

  • (Score: 2) by evilviper on Saturday March 01 2014, @10:30PM

    by evilviper (1760) on Saturday March 01 2014, @10:30PM (#9264) Homepage Journal

    I don't quite understand the challenges you've listed...

    require Java or (even worse) ActiveX in order to view video

    None of the networked MJPEG cameras I've bought over the past two decades have ever required java, including the expensive ones. ActiveX is required only if you want audio in your web browser (native apps don't need it). And the cameras certainly aren't ever Windows-only... They can all be viewed from mobile devices after all. They don't even REQUIRE javascript, since they just embed the MJPEG stream into a static page, and your browser renders it like any video.

    Heck, you don't need any more than wget to fully control these cameras. The instructions for accessing and configuring these cameras at a low-level is documented all over the internet, and hard NOT to find just by accident. Here's one source:

    http://www.openipcam.com/files/Manuals/IPCAM%20CGI %20SDK%202.1.pdf [openipcam.com]

    Additionally, the software that comes w/ these cameras requires Windows, and since I run Linux that's not going to work.

    Right. You'll have to script the process of fetching the MJPEG stream. If you don't have complex requirements, it can really just be a 1-line "while true; do wget $IP/video.cgi ; done" script.

    I figured continuous footage was overkill and started to investigate if it were possible to just pull an image every 10 seconds or so, store it somewhere, then use ffmpeg to tie them all together into an mpeg once a day. All IP cameras have the ability to grab snapshots so I set about figuring out how to accomplish this.

    Dumping a bunch of images to disk for later processing seems like quite a waste. Not to mention the extra overhead of opening/closing all those HTTP connections, which will limit your maximum rate.

    Modern WiFi/MJPEG cameras allow you to limit the frame rate of the MJPEG stream.

    Here's the URL for the MJPEG stream at 1/5th FPS:

        http://camera/videostream.cgi?resolution=32&rate=2 3 [camera]

    And you can process that MJPEG stream with ffmpeg or (my preference) mplayer/mencoder. In fact, here's the EXACT command (after you remove slashcode-inserted extra spaces) to record 2hr 30min of 1/5th FPS video from a WiFi camera directly to MPEG-4 ASP (DivX) in an AVI container.

        mencoder -fps 1/5 -demuxer lavf -lavfdopts format=mjpeg -nocache -ovc lavc -lavcopts vcodec=mpeg4:autoaspect:vqscale=4 "http://$user:$pass@$CAMERA /videostream.cgi?resolution=32&rate=23" -o "$(date +%F_%T).avi" -endpos 2:30:00

    Personally, I prefer 5-10 FPS for surveillance use. You can always skip whatever interval you like, later, in the recorded file for time-lapse or other effects.

    the cameras must be cheap, less than $100
    I wanted to use wireless cameras so I didn't have to run a bunch of CAT5 throughout my house

    The cheapest WiFi PTZ camera I've found on Amazon is the $37 (currently) EasyN FS-613B-M166: http://amazon.com/dp/B005B6QULG [amazon.com] . Mine has been rock-solid stable, and the very wide-angle lens a positive change versus the previous models. The above CGI URL was tested/confirmed working on one of mine.

    If you've got an old (possibly damaged) Android cell phone lying around, the "IP Webcam" app will turn it into a very capable wifi surveillance camera as well, with the added benefit of highdef still shots whenever desired. URL's (and FPS) I've given will need modifications if using IP Webcam (instead of one of the many Foscam knockoffs like that EasyN).

    Also, you're missing-out if you don't consider using the built-in relay for something... You've basically got an internet-connected light-switch on your cheap WiFi camera. Programatically and/or interactively control your lights, coffee-maker, anything...

    I apologize if I've jumped the gun and you refine your question and eventually give all this information in your follow-up journals, but I guess I'm just not patient enough to wait around.

    • (Score: 1) by fliptop on Sunday March 02 2014, @02:04AM

      by fliptop (1666) on Sunday March 02 2014, @02:04AM (#9342) Journal

      Personally, I prefer 5-10 FPS for surveillance use

      Thanks for all the advice, I'll have to peruse it in depth some other time, but I just wanted to comment - I didn't want to have constant video (FPS) because my hard drive storage is limited to 500MB right now. Plus, since I'm just surveilling deer, 1 pic every 5 or 10 seconds is enough. They really don't move that fast when they're in my yard.

      The cheapest WiFi PTZ camera I've found on Amazon is the $37 (currently) EasyN FS-613B-M166

      The cameras I'm looking at are being purchased from my wholesaler. They don't seem to carry this particular model camera. Usually when I buy something like this I piggyback it on an order for another customer so I don't have to pay extra shipping.

      I'll look into the openipcam.com site you mentioned before posting my next entry. Thanks again!

      --
      To be oneself, and unafraid whether right or wrong, is more admirable than the easy cowardice of surrender to conformity
      • (Score: 2) by evilviper on Sunday March 02 2014, @09:53AM

        by evilviper (1760) on Sunday March 02 2014, @09:53AM (#9485) Homepage Journal

        I didn't want to have constant video (FPS) because my hard drive storage is limited to 500MB right now

        That's an issue when dumping JPEG images to disk, but far less so when using a real video codec. If you encode directly, as I've specified, the space saved by lower frame rates diminishes very quickly. When I first tested that out, I found (even with low-CPU usage settings) going from 1fps to 2fps only increased size by 50% (not 100% you would expect). And as you increase that to reasonable frame rates, the penalty just keeps getting lower and lower.

        The cameras I'm looking at are being purchased from my wholesaler. They don't seem to carry this particular model camera.

        That just happens to be the cheapest I spotted on Amazon, where anybody can buy it, and I can confirm they work well. Almost all of these sub-$100 WiFi PTZ "bullet" cameras have practically identical firmware... Foscam (expensive), EasyN, Wansview, Apexis, Esky, Loftek, Tenvis, HooToo, etc. I see from reviews that KaiKong is one notable (incompatible) exception, so just avoid them.

        There's minor differences in picture quality between them, but all are pretty close. Some might have narrow rather than wide-angle lenses. And other details like a few (Esky) that allow you to shut-off the IR-LEDs in software (rather than putting electrical tape over them).

        The biggest (cheap) improvement is finding a model with (automatic) switchable (day/night) IR-filter. That's important so the leaves on trees don't look PINK, and you still get infrared night-vision in low-light.

        Beyond that, you can go for cameras that do H.264, instead of just MJPEG, which reduces WiFi bandwidth usage, and disk space storage (if you're downloading/dumping the video to disk directly, rather than having your computer re-encoding it with MEncoder on-the-fly).

        Many of these H.264 cameras also come with a microSDHC card slot, so they can be told to circularly record up to 2-weeks of video locally on a 32GB card, without needing a continually running computer to act as the DVR, or a WiFi signal... useful at extreme distances.

        And finally, the biggest improvement is higher resolution HD cameras. Sadly, many claim 1280x720p resolution with the same sorry, tiny sensor that can't actually record a higher-quality picture, so you've got to ensure you get something with a CMOS sensor bigger than the common 1/4inch low-res one.

        --
        Hydrogen cyanide is a delicious and necessary part of the human diet.