Monthly Archive for June, 2005

HowTo Compile and Use xvidcap

Compile gvidcap !

Get the last stable source code archive on xvidcap Sourceforge project page or download it from the CVS:

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/xvidcap co -P xvidcap

Install required dependencies:

urpmi gcc automake libgtk+2-devel ffmpeg-devel liblame0-devel

Dirty compile:

make distclean [optional]
CPPFLAGS=-I/usr/include/ffmpeg LDFLAGS=-L/usr/bin/ffmpeg
./configure –with-gtk2 –with-forced-embedded-ffmpeg && make gvidcap
make gvidcap
make install [optional]

Quick test:

./src/gvidcap &

Use gvidcap !

Raw capture:

gvidcap --gui no -v --file ~/img_%04d.xwd --frames 0 --fps 10 --cap_geometry 1024x768+0+0

The following can be used but it slow down the machine (png compression require too cpu):

gvidcap --gui no -v --compress 9 --file ~/img_%04d.png --frames 0 --fps 10 --cap_geometry 1024x728+0+0

Convert .xwd images to .png images because mplayer only support .png, .jpg, .tga and .sgi image file format:

convert img_*.xwd img_%04d.png && rm -rf ./*.xwd

Preview the video:

mplayer "mf://*.png" -mf fps=10

Make a video from successive screenshots:

mencoder "mf://*.png" -mf fps=10 -ovc lavc -o ./video.avi

Documentation:

Qemu: How-To Share Network Access with the Ghest OS

Qemu Network Sharing

Create a file /etc/qemu-ifup that contain:

#!/bin/sh
sudo modprobe tun
sudo /sbin/ifconfig $1 up 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255

# IP masquerade
sudo echo "1" > /proc/sys/net/ipv4/ip_forward
sudo /sbin/iptables -N nat
sudo /sbin/iptables -t nat -F
sudo /sbin/iptables -t nat -A POSTROUTING -s 10.0.2.15 -j MASQUERADE
sudo /sbin/iptables -t nat -A POSTROUTING -d 10.0.2.15 -o $1

Don’t forget to give it execution permissions:

chmod 755 /etc/qemu-ifup

Start qemu with the following parameters:

qemu /home/kevin/qemu-mdk10.1.img -n /etc/qemu-ifup

Setup the network in your ghest OS in qemu:

ifconfig eth0 10.0.2.15
route add default gw 10.0.2.2

Test the visibility of the guest OS from the host OS:

[root@localhost kevin]# ping 10.0.2.15
PING 10.0.2.15 (10.0.2.15) 56(84) bytes of data.
64 bytes from 10.0.2.15: icmp_seq=1 ttl=64 time=2.96 ms
64 bytes from 10.0.2.15: icmp_seq=2 ttl=64 time=0.295 ms
64 bytes from 10.0.2.15: icmp_seq=3 ttl=64 time=0.296 ms

— 10.0.2.15 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.295/1.185/2.965/1.258 ms

Test the visibility of the host from the guest:

[root@localhost root]# ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=1.08 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.433 ms
64 bytes from 10.0.2.2: icmp_seq=3 ttl=64 time=0.383 ms

— 10.0.2.2 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.383/0.634/1.087/0.321 ms

Some QEMU Commands

Some usefull command to help running and setup qemu…

  • Create an empty compressed 10 Go disk image (in qcow format):

    qemu-img create -f qcow /home/kevin/qemu-disk-image.qcow 10G

  • Boot on your machine’s CD-Rom in qemu with previous disk image as primary HDD:

    qemu -cdrom /dev/cdrom -hda /home/kevin/qemu-disk-image.qcow -boot d

  • Same as above but with a CD-Rom iso image:

    qemu -cdrom /home/kevin/ubuntu.iso -hda /home/kevin/qemu-disk-image.qcow -boot d

  • Boot the previously created disk image:

    qemu /home/kevin/qemu-disk-image.qcow

  • Convert qcow image to a raw image:

    qemu-img convert /home/kevin/qemu-disk-image.qcow -O raw /home/kevin/qemu-disk-image.raw

  • Mount a RAW disk image:

    mount -o loop,offset=32256 /home/kevin/qemu-disk-image.raw /mnt/qemu/

  • To run a x86_64 guest system on a 32-bit host, simply use qemu-system-x86_64 binary command instead of qemu.