Tuesday, July 10, 2007

df - A disk usage reporting tool

What is df?
It is a command to report filesystem disk space usage (on Linux).

Problem
Recently I checked my backup server's disk space. I issued df for that. The output was:

df: cannot read table of mounted filesystems: No such file or directory

Something wrong here. After some googling, I managed to get the solution. I issued this command:

grep -v rootfs /proc/mounts > /etc/mtab

After running this command, df worked again. One lesson learned. df relies on /etc/mtab for it to work. Now I can easily know how much disk space left for each partition. Thanks df!.

Tuesday, June 26, 2007

Compiz Fusion - the merge of Compiz and Beryl

What is Compiz Fusion?
Compiz Fusion is an extension of the Compiz compositing window manager for the X Window System. It was created from the remerging of Beryl into Compiz. It aims to port almost all of the features of Beryl to Compiz plugins, and continue to improve Compiz's core functionality.

Some screenshots (taken from my desktop):




































































































































Installation

This package is not officially included in main repository of Fedora. It is even conflicts with the official compiz package. For Fedora users, you can install it through yum with kageshensi's repo. Instructions are in there. Ubuntu users may want to check Ubuntu Forum for more info. Click here for a start.

Friday, June 22, 2007

Converting video and extracting audio from a video

Converting video formats into another

To convert mkv format to dvd format:

ffmpeg -i myfile.mkv -target dvd -copyts -aspect 16:9 myfile.mpg

To convert mp4 video to avi:

mencoder video.mp4 -ovc lavc -vf scale=352:288 -oac lavc -o video.avi

To convert avi to mpeg video:

ffmpeg -i video.avi -target pal-vcd video.mpg

or

ffmpeg -i video.avi -target pal-vcd -s 352x192 -padtop 32 -padbottom 32 video.mpg

Note: -target pal-vcd is for PAL. For NTSC, use -target ntsc-vcd. -padtop 32 and -padbottom 32 will add black padding at the top and bottom.

In certain cases, if you have problem with de-sync audio for the resulted mpeg, try using mencoder like this for PAL format VCD:

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\
vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
-o movie.mpg movie.avi

More options can be found here.

To convert avi to SVCD format:

ffmpeg -i video.avi -target pal-svcd video.mpg

Note: -target pal-svcd is for PAL. For NTSC, use -target ntsc-svcd.

Burn to CDs
This command will cut the mpeg video files into 3 to fit 3 CDs.

mpgtx -3 video.mpg -b m

The resulting file will be m-1.mpg, m-2.mpg and m-3.mpg. These files can be burnt to one CD each. The argument -b means basename.

or you can also use avisplit to split AVI movie:

avisplit -s 700 -i video.avi

Where to get the tools?
If you use Fedora, you can install all of the tools with yum. For other distro, please consult the manual for it. avisplit is part of transcode package.

Fixing desynched audio

avisync is easy to use: just provide an input file (-i name.avi), an output file (-o newname.avi) and the synchronization offset in frames (-n count). From avisync's help: count>0: audio starts with frame 'count'. count>0: prepend 'count' padding audio frames.

An example:
avisync -i ally-not-synched.avi -o ally-synched.avi -n -2

Splitting AVIs

avisplit -i ally-big-file.avi -o ally -s 700

This will produce files named ally-0000.avi, ally-0001.avi etc. that are each 100megs big at most.

Extracting audio from VOBs/MPEGs/AVIs

MPlayer can be used easily to extract sound. The -vo null options tells MPlayer not to show the video.
I'm not listing all possible options. Generally use -dumpaudio -dumpfile newaudio.extension if you want to extract the audio without processing and -ao pcm -aofile newaudio.wav if you want the WAV itself.

Using separate audio files

Sometimes you want to play another audio file along with your video. MPlayer makes this rather easy: mplayer -audiofile anotherlang.mp3 myvideo.avi plays video from myvideo.avi and audio from anotherlang.mp3. A lot of Windows media players support external audio files, too. This way you can provide several language versions as separate audio files. A combination often used is to have the AVI include the English audio track and to provide additional audio tracks in separate files.

A visual AVI editor: avidemux

If you've done video editing with Windows before you probably know the excellent OpenSource editor VirtualDub. An OpenSource utility for Linux that aims at providing the user with a similar set of features is avidemux. You can use it in order to easily cut specific parts from a movie, to apply filters, to reencode movies and to do a lot more. I suggest you take a look at it even if using the command line is as natural to you as it is for me.

Credit to :
moritz@bunkus.org (http://www.bunkus.org)
Gentoo Wiki (http://gentoo-wiki.com/HOWTO_Create_a_VCD_or_SVCD)
MPlayer Doc (http://www.mplayerhq.hu/DOCS/HTML/en/index.html)

Friday, June 8, 2007

yumex - yum extender

Installing a package in Fedora using yum is good. It is faster than pirut or pup in GUI. I discovered yumex a while ago. Installing it was trivial :

yum -y install yumex

It is a GUI-front-end for yum but faster than pirut or pup. The Ouput View gives you "what's going on'. I just love it. Try it!.





To make installation packages faster with yum, I highly recommend you to install the following yum plugins :
  1. yum-fastestmirror (yum install yum-fastestmirror)
  2. yum-skip-broken
To see other plugins for yum, please run this command: yum list "yum*"

Thursday, May 24, 2007

Capturing video off your desktop with xvidcap on Linux

What is xvidcap?
It is a small tool to capture things going on an X-Windows display to either individual frames or an MPEG video. On Windows machines there are commercial tools like Lotus ScreenCam or Camtasia. From my experience, new user will take some time to take off with a video. I just think it needs more work on user-friendliness.

Where to download?
If you use Fedora, you can install with yum: yum install xvidcap
If u use Ubuntu or Debian, you can install with apt-get : apt-get install xvidcap
or for advanced user, you can download the source code here.

My desktop
Below is a video off my desktop I took with xvidcap. On the video, you can see that I was showing off Compiz. :)

Saturday, May 19, 2007

Dansguardian - web content filtering for all


What is dansguardian?
(Excerpt from dansguardian's website)

DansGuardian
is an award winning Open Source web content filter which currently runs on Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X, HP-UX, and Solaris. It filters the actual content of pages based on many methods including phrase matching, PICS filtering and URL filtering. It does not purely filter based on a banned list of sites like lesser totally commercial filters.

DansGuardian is designed to be completely flexible and allows you to tailor the filtering to your exact needs. It can be as draconian or as unobstructive as you want. The default settings are geared towards what a primary school might want but DansGuardian puts you in control of what you want to block.

DansGuardian is a true web content filter.

Where to download?

The latest beta when this article is published is 2.9.8.5. Download it here. Beta doesn't mean it is unstable. From my experience, it is a very reliable piece of software. Downloading source code and compile it yourself is the best way to take full advantage of its (latest) capabilities and speed.

My setup
I have more than 200 clients in my network. To provide a fast and reliable internet connection, I have to use a proxy server and dansguardian is used for filtering unwanted websites and scanning for viruses of downloaded files and websites.

Startup script
Startup script can be taken from [source dir]/data/scripts/systemv-init. Copy it to init.d:

~#cp systemv-init /etc/init.d/dansguardian

Run chkconfig to make it start across booting properly:

~#chkconfig --add dansguardian
~#chkconfig --level 35 dansguardian on

Note: For Fedora users, you may need to use /sbin/chkconfig instead of chkconfig.

How to upgrade?
If you have installed dansguardian via package manager, it is easy to upgrade it with package manager too. So you don't need to mess up with compilation and dependencies. It will take care of them for you. I like to download source code because I can download the latest and to take the advantage of its speed. You can not always get the latest packages with package manager and the package may not optimized for your machine. YMMV.

Steps:
1. Download the latest source code.
2. Extract it: tar xzvf dansguardian-2.9.8.5.tar.gz
3. cd into the source dir.
4. configure : ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-clamd=yes
5. Run make : make
6. Install : make install

If you have previous version of dansguardian, please backup directory /etc/dansguardian/lists because installing the new one will overwrite all the files in it. You don't want to refill all the sites you have entered in all files in there for banned sites , exception site (unfiltered sites) etc2.

Configuration
The main configuration file for dansguardian is /etc/dansguardian/dansguardian.conf. It is heavily documented. Tkae your time to read the comments in there before modifying. Below is the most important directives to be modified (example):

filter_ip = 192.168.5.2
filter_port = 3128
proxy_ip = 127.0.0.1

Note: 192.168.5.2 is the IP which dansguardian will listen on. If left empty, it will listen on all IPs. For increase security, please state IP(s) that it needs to listen on. filter_port is the port it will bind to. proxy _ip is the ip where the proxy server (daemon, e.g squid) listens on. Note that you must run proxy server before running dansguardian or it will fail to start.

Integration with antivirus
Dansguardian can use antivirus for content scanning of viruses. I use clamav for this. You need to uncomment the directive contentscanner and modify file /etc/dansguardian/contentscanners/clamdscan.conf.

contentscanner = '/etc/dansguardian/contentscanners/clamdscan.conf'

In this file, change clamdudsfile like this :

clamdudsfile = '/tmp/clamd'

/tmp/clamd is the socket file for my clamav daemon (clamd). Change it accordingly.

Saturday, April 28, 2007

Repositories for Fedora Core 6


Fedora Core is in rapid development. Repositories or in short repos (plural of repo) are servers which provide packages for Fedora Core users to install and update packages. For those who likes to live on the edge should enable testing repo. For newbie, you can use pirut or go to Application --> Add/Remove Software and enable the testing repo. Be warned that the packages provided are not stable. They can even make your computer system hang and your CD drive burnt ;). I don't like it. I like everything to be stable and I have experienced how it was to be living on the bleeding edge. Things were not that good. :D

Beside core, updates and extras repositories, you might need to add livna and kde repositories too. These sites provide non-free/proprietary packages like mp3 support and proprietary display drivers (ATI and NVIDIA). The kde repo stated above provides unofficial kde packages from kde community itself. The packages comes as updates for the packages provided by official Fedora repo.

To add livna repo, run this command :
rpm -ivh http://rpm.livna.org/livna-release-6.rpm

To add kde repo, download this file using wget:
wget http://apt.kde-redhat.org/apt/kde-redhat/fedora/kde.repo

and put this file in /etc/yum.repos.d/

Afterthat, try checking updates by running yum check-update. You should see many updates come from both repos.

Nvidia new hotplug feature on Linux

 If you use nvidia driver for your GPU, you probably wonder why in some config, you can't hotplug your second monitor. You need to reboo...