Streaming a web cam in Ubuntu
It’s pretty easy to get a webcam to stream in Ubuntu, or indeed any Debian distribution. In this example I’m using Ubuntu 10.04 (Karmic) and a Microsoft Lifecam VX-1000 web cam.
First get root access with the usual command.
$ sudo bash [sudo] password for user: *********
Next open up a terminal window and install webcam-server as follows:
$ apt-get install webcam-server
Now go to the /dev directory and list the contents. From your home directory type:
$ cd .. $ cd .. $ cd /dev $ ls
You’ll now see a list of files that will look similar to this:
input ram11 tty32 vcsa4 kmsg ram12 tty33 vcsa5 log ram13 tty34 vcsa6 loop0 ram14 tty35 vcsa7 loop1 ram15 tty36 tty7 vcsa8 loop2 ram2 tty37 tty8 zero loop3 ram3 tty38 tty9 loop4 ram4 tty39 ttyS0Now plug in your webcam into one of the USB ports, wait a couple of seconds then type the same command again:
$ lsYou should see another file has appeared that starts with video. Mine’s shown up as video0 as it’s the first video device connected to the system. If you have an integrated webcam, subsequent webcam handles will be incremented, i.e. video1, video2 etc..
Now to start the webcam-server daemon, type the following:
$ webcam-server -d /dev/video0If it’s working, you’ll just see the cursor continue to blink. To confirm that the daemon is running, go to http://localhost:8888. You should see a JPEG image with a timestamp, showing what your webcam can see.
If not, check the terminal for errors.
libv4lconvert: Error decompressing JPEG: fill_nbits error: need 6 more bitsIf you see the above message or similar, you’ll need to try and run your webcam in compatibility mode, as follows:
$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so webcam-server -d /dev/video0Now check http://localhost:8888 again, and all things being well, you’ll see the JPEG snapshot. (if not, check the Ubuntu forums to check that your device is supported)
Now as that’s not strictly speaking a stream, there’s one last thing to do.
$ cp /usr/share/doc/webcam-server/applet/* /var/www/This will copy some files, including the Java streaming applet, to your web accessible directory, /var/www. Now if you go to http://localhost/webcam.html, you’ll see an applet load, followed by a live stream from your webcam.
Note: The useful thing about this, is that you can run as many daemons as your system can handle, so you can plug in a number of webcams to the same system and with some additional webcam-server switches, you can assign each camera to a different port.
Removing an entire directory/folder (that still contains files) in Linux
This one’s easy, but I’ve just been asked by someone new to Linux so here it is:
$ rm -r <path to directory>
So for example if you want to delete a folder called temporary from your home directory:
$ rm -r ~/temporary
The -r switch stands for recursive, so you’re not actually deleting the directory with the files within it, you’re deleting each file within the directory first, then removing the directory afterwards.
Simples.
Get Windows 7 snap window resizing in XP
I’m not a fan of Windows 7’s bloat and visual and marketing fluff, but one killer feature that I’ve found genuinely useful in Redmond’s most recent offering is the ability to resize a window to exactly half of the screen by simply dragging it all the way to the left or right of the screen.
As I use an XP development machine at work, I wanted the same functionality on the older generation operating system. Unsusprisingly Microsoft do not provide a way for this feature to be added to XP themselves, but there is a free alternative that does the job; WinSplit-Revolution.
In fact WinSplit-Revolution does more than Windows 7, by allowing you to define a range of sizes for your snap-resized window to take. Whilst this adds a little more complexity to the configuration options, I’ve found it to strike just the right balance between configurable and easy to use, without being a pain to set up. Highly recommended.
Add A Directory to PATH in Ubuntu 10.04
gedit ~/.bashrc
PATH=$PATH:/home/user/somefolder export PATH
source ~/.bashrc
Done! You can now access anything in that folder from the bash prompt without typing the path.
You must be logged in to post a comment.