Jun 232011
 

Hi All,

I’ve been working on fitting a webcam streaming server on a thin client.

Using Debian, I managed to get the base distribution down to 150 megabytes with my own kernel and stripping out unwanted packages like aptitude, logrotate, vim, and the default kernel with all of it’s modules.

After installing ffmpeg and openssh server, the distribution was brought to just under 200 megabytes.

Once I have the kernel installed and detecting my webcam, I can use ffmpeg and ffserver to stream video from the webcam to my network.

I created this ffserv.conf file in my root home directory –


Port 81
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon

<Feed webcam.ffm>
file /tmp/webam.ffm
FileMaxSize 10M
</Feed>

<Stream webcam.mjpeg>
Feed webcam.ffm
Format mjpeg
VideoSize qvga
VideoFrameRate 10
VideoBitRate 100
</Stream>

That conf file will setup the parameters, and stream settings for ffserver to use when it starts streaming.

The first stanza sets up the port that the server will listen on, and the address.
The other 3 lines are self explanatory.

The Feed stanza is just defining the feed name and file it will use, while the stream stanza sets up the stream.

I am using mjpeg format as it’s light on the CPU but you can use other formats like FLV or ASF.

Once the config file has been created, you can use this command to start the streaming server.


ffserver -f /root/ffserv.conf & ffmpeg -v verbose -r 5 -s 320x240 -f video4linux2 -i /dev/video0 http://localhost:81/webcam.ffm

That command with start ffserver with the parameters in /root/ffserv.conf, and then start ffmpeg with a verbosity level of verbose, a default frame rate of 5, a size of 320×240, format of video4linux2, and an input device of /dev/video0, streaming it to http://localhost:81/webcam.ffm.

If you want to add audio to the stream, add the parameters –

-f oss -i /dev/dsp

Once the server has started streaming, you should be able to open the stream with a browser if the webcam is being streamed via mjpeg using the address of http://yourwebcamserver:81/webcam.mjpeg – replacing ‘yourwebcamserver’ with the IP address of the server hosting the stream.

You can also use a player like VLC to open a FLV or ASF stream.

Any questions of feedback ?
Please leave me a comment 🙂

Share
Jun 192011
 

Hi All,

Recently, I had to copy over some files from one computer to another.
Using the network was too slow, but using a USB stick wasn’t quite what I needed as the files I was moving over had permissions that needed to be kept.
However the USB stick was formatted in FAT32 and I did not want to reformat into a Linux friendly format as I used the USB stick on other operating systems.

One of the solutions that can be used is to create a tarball ( .tar file ) of all the files. This is the easiest method of doing it, but is a bit inconvenient if you have to modify the files inside the tarball as you would have to untar it first, modify the files, and then retarball it all.

The solution that I use is to create a file on Linux that we can use as a container for a Linux file system. Then we can place this file onto the USB stick and mount it as though it were a normal file system.

Step 1 – Creating the container

First thing we need to do is create the file that is going to contain the file system.
Running this at the command line will create a file full of nothingness.
This can be run from anywhere, I’m running it from my home directory but you can run it on the usb stick itself –


dd if=/dev/zero of=usblinux bs=1M count=512

What that command does is read 1M of zeroes and writes it to the file ‘usblinux’ 512 times, in effect creating a file full of zeroes.

Step 2 – Creating the file system

Next up we need to create the file system that we want to use.
For me, I’m using an ext2 file system but you can use what you want.
The following command will need to be run as root, what it does is create a file system inside the file ‘usblinux’


mke2fs -t ext2 usblinux

Step 3 – Mounting the file

Now that we have a special file with a file system inside, we can mount it and use it as a file system as if it were a hard drive.
First step is to make the mount point first, then after we make the mount point we can then mount the file.


mkdir mount
mount -o loop usblinux mntdir

Step 4 – Moving the file to the USB

With it mounted, you won’t be able to move the file, so you will need to unmount the file first before you move it –


umount mntdir

Once unmounted, you can move your newly created filesystem to the USB drive, and mount it on any machine like a normal file system and use it to keep Linux files as they should be kept.

Share
Jun 132011
 

Hi All,

I’ve recently been playing around with some small distributions so I can setup a tiny webcam server – no luck there yet, but I thought I’d post up how to boot Puppy over PXE as I tried that out while messing around.

Step 1 – Getting Puppy

So first thing we need to do, is to get Puppy Linux from here

wget http://distro.ibiblio.org/pub/linux/distributions/puppylinux/puppy-5.2.5/lupu-525.iso

Wget is my weapon of choice here, so the above command will download the ISO file into the current directory. I am logged in as root to set everything up so it has downloaded the iso to /root/.

After we get the ISO file, we need to extract a few files from the ISO so we can use them to boot over PXE.

mount -o loop lupu-525.iso /mnt

With the above command, we mount the ISO from the current directory onto /mnt so we can copy the files off the ISO.
Once it is mounted, we will need 3 files off the ISO:
initrd.gz
vmlinuz
lupu_525.sfs

mkdir /tftpboot/puppy/
cp /mnt/initrd.gz /tftpboot/puppy/
cp /mnt/vmlinuz /tftpboot/puppy/
cp /mnt/lupu_525.sfs /tftpboot/puppy/

With those commands, we create a directory to store the files in, and copy them over.

Step 2 – Setting it up

We will need to pack lupu_525.sfs into the initrd image for this to work as the livecd expects it to be somewhere on the boot media but we don’t have any boot media as we are booting over the network.

So what we do is make a folder so we can modify the initrd –

mkdir /tftpboot/puppy/temp

Change to that directory

cd /tftpboot/puppy/temp

Then we will extract the contents of the initrd.

zcat /tftpboot/puppy/initrd.gz | cpio -i -H newc -d

Now the contents of the initrd are in /tftpboot/puppy/temp
We’ll move the lupu_525.sfs file into the temp folder –

mv /tftpboot/puppy/lupu_525.sfs /tftpboot/puppy/temp

Then we’ll repack it up into a new initrd.gz file by running this command while inside the temp directory –

find | cpio -o -H newc | gzip -4 > ../newinitrd.gz

Now we have our new initrd.gz file, we can setup the pxelinux config file with a new menu item.

Step 3 – Setting up pxelinux.cfg

So now we will need to add the following codeblock to /tftpboot/pxelinux.cfg/default


LABEL Puppylinux
MENU LABEL Puppy Linux 5.2.5
kernel puppy/vmlinuz
append initrd=puppy/newinitrd.gz

Notice we have used the name of the newinitrd.gz file as that is the one we will need to boot from in order for Puppylinux to get the lupu_525.sfs file.

Once you have updated the configuration file, you are now ready to boot Puppy Linux 5.2.5 !

Share
Jun 082011
 

A continuation of this post.

You can also create machine specific configuration files by naming the file the same as the mac address but replacing the colons ( : ) with dashes ( – ) and adding a 01 to the front to signify that this is an ethernet address..
So 00:15:af:69:31:79 becomes 01-00-15-af-69-31-79.

This is also the “BOOTIF” that you see on the previous screenshot.

Share