Shortcuts to updates:
Update #1
Update #2
This is a project I have been working on for a little while now, and realized recently that I haven't documented it at all until now. 

I am working on making a video baby monitor for my upcoming offspring, using a webcam and a raspberry pi. I am piecing the process together from a multitude of different online sources and guides, but none of them have been very effective. I have managed to get the video up and running over WiFi and the internet via port forwarding. I am using the mjpg-streamer software on the pi and it works rather well. I have tried using ffmpg, but it doesn't seem to be very friendly with my webcam... 

This is the 'Pi I'm using right now. It's a model B in a Rainbow PiBow case I got from Adafruit. (I love those guys) The finished product will be a model A 'Pi embedded in an enclosure with the webcam and WiFi card all enclosed, so that all you do is plug in the power and walk away. I decided to go with the model a for a few reasons: it's cheaper, it doesn't have Ethernet, and I don't need that much ram for this project. But mainly because it's cheaper :)

Speaking of webcams, I snagged this beauty at goodwill for 5 bucks! It has a great exposure, good white balance adjustment when changing the amount of light in the room, and AUTOFOCUS!!!!! Here is a sample shot of it's picture quality:

(Please excuse my messy living room lol)

I am having issues getting the audio working however... I haven't gotten it working at all streaming with the video. I have managed to get live audio streaming with a program called "Darkice" which has good quality and is well suitled for live broadcasts, but there is a significant time delay. The lowest I've gotten the delay is about 8 seconds. This may not sound like a long time, but for a baby monitor it's pretty impractical. I am still playing around with the command lines and if I get it working I'll post the code up here.

Code! To get my vision of power up and walk away to work, I added the following to /etc/rc.local file.


echo "Starting Cam!!"
bash /home/pi/mjpg-streamer/

This boots up the cam software and gets it running without even needing to log into the pi, using the configuration file defined within itself. This opens up the stream on port 8080 so you can log it from any web browser. You simply punch in the ip address of the pi into your browser and tell it to stream. In my case you use "" on my local network and it streams like a champ! 
I had a bit of difficulty getting it to work on my iPad and iPhone, so I wrote a nifty little HTML page and bookmarked it on each device. I could then access it from the file system in safari using the file:/// jailbreak tweak. and it works well. Here is the code for the webpage if you are interested:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
      Local Cam
    <img src="">

This embeds the stream into an image in the webpage and that lets it run smoothly on my mobile devices.

I am going to keep fiddling with the audio options in the configuration files and see what I can come up with. As with all my projects, I'll keep you posted as I get more accomplished so check back for updates!

I have gotten audio working on the BabyPi!!! Albeit in a rather convoluted way, but working nonetheless.
After several weeks of fiddling with settings in FFMPG and and Mjpg-streamer, I decided to see what else was out there. I stumbled across a nice audio sever and multi-client program called Mumble. Mumble is primarily designed for doing online chat during gameplay, either locally or over the internet. I also learned that mumble's client and server software have already been ported, with much success, to the Raspberry Pi. This meant that I could use the BabyPi as a mumble server AND as a client, listening to the webcam's microphone. I could then open the mumble client on any of my PC's and log into the BabyPi's server and stream the audio to it.

Now, this isn't the end result I was looking for. The mumble iOS app hasn't made it past apple's scrutiny yet, so I can't stream the audio to my iPad or iPhone yet... This isn't really that big of a deal for me though, I don't really need my baby's audio monitor coming from like 5 places all at once. I can still view the camera stream at full frame-rate, though I had to lower the resolution a bit to compensate for the additional bandwidth the audio is using. 

The biggest problem I ran into with this setup was getting the mumble client on the 'Pi to start on boot. Up until now, I had only used startup scripts that executed before the GUI loads. Mumble is only available in a GUI interface, so it took me quite some time to work out how exactly to make it work. I ended up making a little script and added it to my openbox configuration folder (~/.config/openbox/script) and forcing it to open in openbox instead of LXDE. I did this for two reasons. First, I didn't want any other background programs running or any resources being used that I didn't need and secondly, I couldn't, for the life of me, get anything to start once LXDE had loaded lol.

If you're interested the script I used is something to the effect of:
murmurd     &

mumble mumble://BabyPi@localhost:64738


This simply tells the pi to start murmur (the server software) in the background and then start mumble, log into the server it just started, and to use the username: BabyPi. This alleviates the need to physically log in on the 'Pi, which means I can still run this whole thing headless, like I originally intended. 

That's all for now! If there is anything you all have questions about of would like to see more detail on, leave a note in the comments below. I never know if I'm putting too much or too little detail into these things, so let me know :)

After frying the HDMI port on my bench 'pi, I decided it would be best to delegate it to a headless system. So I've decided it would be this one. I also came up with a nice solution to deal with the overheating as well. 
I took an old case fan I had laying around and wired it to the top to keep a nice breeze blowing over it. It's not pretty but it does the trick. To power the fan, I plugged it up to the GPIO header's 5v and ground. The fan is a 12v fan, but it runs well enough at 5v to keep the pi' from overheating. 

Since I didn't need any pwm on the fan, I took that wire from the fan and ran it through the mounting holes and strapped it to the 'pi. Again, it's not a pretty or elegant solution, but it works very well.

Anyway, once I got it up and functional again, I hooked up the baby 'pi card and it booted up and crashed... Upon rebooting, I found that the SD card had corrupted, so I did a fresh install, reconfigured everything, and 5 hours of tweaking later, it's running better than before it crashed!

I also found out that Apple had finally cleared the Mumble App for iOS, so I grabbed it and it is fantastic! Using mumble and CamViewer, I am able to have live audio and video on the same device! Here's some screenshots:

The basic interface:
CamViewer with mumble running in the background

It looks much better in landscape

I have the cam set up on the corner on the crib, well out of her reach. If not for the blue light on the webcam, it wouldn't be noticeable at all. 

Now we just have to wait for the baby to get here, which should be any day now :)

No comments:

Post a Comment