Showing posts with label ip camera. Show all posts
Showing posts with label ip camera. Show all posts

Saturday, 5 October 2013

Using Raspberry Pi as an IP Camera to Analogue Converter

I have an old-fashioned analogue TV distribution system in our house.   We use it for a video monitor for our disabled son so we can check he is ok.
The quality of the analogue camera we use is not good, but rather than getting a new analogue one, I thought I should really get into digital IP cameras.
I have had quite a nice IP camera with decent infra-red capabilities for a while (a Ycam Knight).   You can view the images and hear the audio on a computer, but it is not as useful as it working on the little portable flat panel TVs we have installed in a few rooms for the old analogue camera.

I am trying an experiment using a raspberry Pi to take the audio and video from the IP camera, and convert it to analogue signals so my old equipment can be used to view it.

What we have is:

  • IP Camera connected to home network.
  • Raspberry Pi connected to same network.
  • Analogue video and audio signals from Pi connected to an RF modulator, which is connected to our RF distribution system.
Using this I can tune the TVs on the RF distribution system to view the Raspberry Pi output.

I set up the Pi to view the audio and video streams from the IP camera by using the omxplayer video player, which is optimised for the Pi.   I added the following to /etc/rc.local:
omxplayer rtsp://192.168.1.18/live_mpeg4.sdp &
Now when the Pi boots, it displays the video from the IP camera on its screen, which is visible to other monitors via the RF modulator.

My concern is how reliable this will be - I tried earlier in the year and the Pi crashed after a few weeks with a completely mangled root filesystem, which is no good at all.   This time I am using a new Pi and new SD card for the filesystem, so I will see how long it lasts.

Saturday, 7 July 2012

Webcam using NLSU2 and OpenWRT

I am trying to set up a simple web camera to take some photos and videos of birds on our bird table.
I have had an edimax ip camera for a long time, but have had some trouble with using and configuring it from Linux.  So, I am having an attempt with a different approach from bits of hardware I have around.   There is a Linksys NLSLU2, which is made as a network storage device, and I just picked up a logitech usb web camera.   I decided to use OpenWRT as the operating system, because I used that on a previous project (bifferboard weather station).
This post is a few notes of where I have got to, and the problems encountered.

Operating System

  • Download OpenWRT:   To start with I used a tarball of OpenWRT 'backfire' 10.03, but it problems with packages not being compatible.   Rather than understand why, I went for checking out the latest source code from the 'backfire' branch of the OpenWRT SVN repository.
  • Build OpenWRT:  This is as simple as changing into the source directory and doing 'make menuconfig', selecting the target system as 'IXP4xx', then the profile as NSLU2, exiting and typing 'make'.   This creates a flash disk image as bin/ixp4xx/openwrt-nslu2-squashfs.bin.
  • Put the NSLU2 into upgrade mode by powering off, pressing and holding the reset button with a paper clip then powering on.  Wait for ~10 sec until the top LED changes colour (very difficult for me to tell as I am colour blind...), then release the reset button.  The top LED now flashes two slightly different colours.
  • Connect the computer with the OpenWRT image on it to the same ethernet network as the NSLU2 - Wireless connections do not work!.
  • Flash the new image onto the NSLU2 using 'sudo upslug2 -i openwrt-nslu2-squashfs.bin'.
  • Once the flashing is complete, the NSLU2 reboots and you should be able to telnet into it - default ip address is 192.168.1.1, which is a pain if that is the same one as your router...
Configuring OpenWRT
The basic OpenWRT build does not do much, so it needs to be configured and the extra required packages adding:
  • Default IP Address - this can be set by editing package/base-files/files/etc/config/network [there is probably a better way to do this, but this works...].
  • Add the drivers for the USB video cameras - using menuconfig select them in the kernel config section - make sure they are selected to be built-in [*] rather than modules [M], because otherwise they are not included in the flash drive image.
  • Add some software to do something with the video source - add the mjpg-streamer and motion packages.
  • Re-build OpenWRT and re-flash it.
  • You should now be able to look at :8080?action=stream and see the image from the camera from mjpeg-stream
Making it Do Something Useful
  • mjpg-streamer seems to work nicely and produces a jpeg stream that can be viewed on a browser.  No sound though - will have to look into how to deal with that.
  • motion also seems to work - need to modify /etc/motion.conf to tell it what to do.
  • I would really like to to record video clips when motion is detected, so am currently trying to see if I can build ffmpeg to link that to motion.....
  • I have run out of time this weekend.  What I have done is just used motion and removed mjpeg-streamer, as motion provides a mjpeg stream too.  The basic set-up is:
  • Logitec usb web cam.
  • Motion records images to /tmp/cam1/// - separated into different directories to stop the numbers of files getting out of hand.
  • A little php script /cgi-bin/browse.php is used to browse through the directories and view the images.
  • I could not get ffmpeg to compile, so no videos for now.
  • This is going to be installed at my sisters, so will have to talk her through setting up her router so I can ssh into it remotely to fix it when it does not work.....
  • My version, using the same motion and php script set up, but using the edimax ip camera can be seen at http://maps.webhop.net/webcam.

Friday, 31 December 2010

Inside the Edimax IC-3010WG IP Camera

I have just added my photos of the inside of the Edimax IC-3010WG IP camera to my web page: http://ic-3010wg.webhop.net.
If anyone knows what 'J1' is, I would like to know!

Sunday, 6 September 2009

Progress with IP Camera Viewer

The Edimax IP Camera seems to work fairly well, but the video stream seems to get interrupted every now and again, which makes the player crash - vlc just hangs, and mplayer exits.
I decided that exiting was better so I have written a simple pyGTK front end for mplayer to play the screen. It also includes a wireless network link quality monitor to help understand why it is not working - it is here as 'bentv'.

Note that bentv uses a library that I have started work on (named ntpylib for want of a better name) - so far it only contains one class, 'prefs', which deals with saving and loading of simple key/value data from XML files. It includes a dialog box that GUI programs (such as bentv.py) can use to allow the user to edit the data. prefs.py and prefs.glade need copying or linking into the bentv directory to make it work - there is no clever installer!

Sunday, 23 August 2009

Embedded Linux Firmware Binary Files

I have always struggled to understand the format of the binary files that store the firmware upgrades.
They tend to be a mixture of some simple text labels, a kernel image and one or more mountable filesystems.
I have written a little script that goes through a file in a brute force (one byte at a time) way and attempts to mount it as various filesystem types (script stored here).
I used the information found by this script, and the source code provided by Edimax to work out some information about the internals of the IC-3010WG IP Camera - it is written up here.

Saturday, 22 August 2009

Practical Experience using the Edimax IP Camera

We were away on holiday last week so I got to try using the Edimax IP camera 'for real' as a monitor to keep an eye on our disabled son - known as 'BenTV-ng' (next generation) to distinguish it from 'BenTV' which was the old analogue system I used to use.

I gave up on using ad-hoc networking and instead took my wireless access point with me. This had the added advantage of improving the range of transmission because I could arrange for the access point to be between the camera and the computer. The computer I used was a Toshiba netbook running Ubuntu Linux.

The first thing I noticed was that when I powered everything up, nothing happened. At first I thought it was because the access point needed to see a wired connection as well as a wireless one, because when I connected the computer to it using a wire things started to work. I soon realised that the range was awful - it stopped working as soon as you were outside of his room. This turned out to be my fault because I had also switched on the analogue camera, which transmitted on the same frequency as the wireless network, so the noise level was huge. Things got better when I switched off the analogue camera.

At first everything appeared to work - vlc rtsp://admin:1234@bentv/ipcam.sdp played the video stream with sound.
I soon noticed that if the network got interrupted vlc froze, giving an apparently good picture, but no movement, which was no use to me. Instead I changed to mplayer - at least if that got into trouble it crashed and closed the video playback window so you knew something was wrong.

I set up a simple shell script that loops indefinitely starting mplayer then when mplayer exits it re-boots the ip camera, waits for 30 seconds and starts mplayer again.
This approach worked pretty well - the 30 second interruptions during the re-boot were not usually too troublesome.

We did find some problems when the video stream only worked for a few seconds before mplayer exited and the re-boot sequence started again, which was no good at all. The only way I found to cure this was to power off the camera all together - a software re-boot via the web interface did not cure it. I'll set up a little test at home now to see how long it takes to get into this state, and whether it makes a difference if you use wireless or wired networking.

The code to achieve this is stored at http://code.google.com/p/ntmisc/source/browse/bentv/.

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.

Friday, 24 July 2009

Ad-Hoc Wireless Network Troubles

Now that I have the Edimax IP Camera working I want it to connect to my Toshiba NB100 netbook computer as simply as possible - the idea is to use it when we are away on holiday so I don't want to have to set up a whole network with an access point etc. Instead I just want to set up an ad-hoc network between the computer and the IP Camera.
According to the instructions this should be easy - I tell the IP Camera to connect to an ad-hoc network called 'bentv', and then use NetworkManager in the Ubuntu desktop of the netbook to create the ad-hoc network.
This works fine on my main laptop, but fails on the netbook.
It turns out that NetworkManager is not capable of putting the wireless card into ad-hoc mode.
The work around was to have the script to start the VLC viewer shutdown network manager and set up the network manually as follows:

#!/bin/sh
/etc/init.d/NetworkManager stop
ifconfig ath1 down
wlanconfig ath1 destroy
wlanconfig ath1 create wlandev wifi0 wlanmode adhoc
iwconfig ath1 essid bentv
iwconfig ath1 channel 1
iwconfig ath1 192.168.1.35
iwconfig ath1 netmask 255.255.255.0
ifconfig ath1 up

vlc --fullscreen rtsp://192.168.1.17/ipcam.sdp

/etc/init.d/NetworkManager start

This is based on information I found here.
This seems to work, but the wireless networking is a bit iffy after the script exits - I might have to do the wlanconfig destroy bit again to put it into infrastructure mode.

Sunday, 12 July 2009

More on Edimax IP Camera

I think we're getting somewhere. Searching around for references to IP cameras and mplayer yielded this thread which suggested the following:

mkfifo fifo.mpeg4
wget -q http://admin:1234@192.168.1.117:4322 -Ofifo.mpeg4 &
mplayer -V -demuxer 35 fifo.mpeg4
This seems to work ok - there is a bit of a delay in the video, but probably ~0.1 sec, which is acceptable.
Progress!
Just need to get sound working now....

Well, I did a bit more hunting around in the camera web set-up and realised I had missed a section about RTSP. The default was for RTSP to be enabled on port 554 with a rtsp path of ipcam.sdp.
When I tried

mplayer rtsp://192.168.1.117:554/ipcam.sdp

I got pictures AND sound!
I had tried rtsp before, but had missed the ipcam.sdp bit. Mplayer complains that my little netbook is too slow to play the stream, so there is a bit more work to do, but it looks promising. I'll try VLC now.

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.

Saturday, 11 July 2009

Edimax IC-3010Wg yet again

Still struggling with my IP Camera. Although mplayer can sort of play the mp4 stream, it does not seem reliable and takes a long time to start to play, so I do not think it is working correctly. I think I'll try the Edimax support, but have upgraded from version 1.20 to 1.25 of the firmware first, because they are bound to ask if I am using the latest software....

Thursday, 9 July 2009

Edimax IC-3010Wg again

I have made a bit more progress getting my Edimax IP Camera working, and detailed what I have learned at http://ic-3010wg.webhop.net.

The main problems are still that although I can download an MPEG4 stream using wget, neither mplayer nor vlc will play it directly, which is no good.
The other issue is that sound still does not work.....

Tuesday, 7 July 2009

Edimax IC-3010Wg IP Camera and Linux

I have just got an Edimax IC-3010Wg IP Camera. I intend to use it as a replacement for the analogue video system we use to keep an eye on our disabled son.
I was rather disappointed to find that it does not work with Firefox - you need an Internet Explorer ActiveX control to view the video images. This means it will not work on my Linux computers as supplied by the manufacturer.

What works:
  1. The camera gets its network configuration by DHCP (despite what the quick start guide says) so by checking the DHCP deamon log you can find its IP address.
  2. You can access its configuration screen with a web browser (default username admin, password 1234)
  3. Receive a snapshot picture using http:///snapshot.jpg
  4. Download a mjpeg video stream using wget http://admin:1234@192.168.1.117/mjpg/video.mjpg. (I don't know how to display this in real time though - mplayer doesn't seem to work).
  5. Some other things are detailed here.
  6. Someone has written a tcl application that works with a similar camera, but not this one (see here).
I think I am going to end up writing something based on the tcl application shown above to display live video with sound, which is what I need. If anyone knows an off-the shelf one, please let me know!

The most up to date information I have on using this camera with linux can be found at http://ic-3010wg.webhop.net.