Feeds:
Posts
Comments

I was trying to convert a .dat file from VCD to mpeg or avi format.

Linux helps you to do it with ease. I use Ubuntu and all you need is ffmpeg [Is tools/library to record, convert, stream and play multimedia content including libavcodec and libavformat, two libraries used by many other open source projects.]

To install ffmpeg

CMD: sudo apt-get install ffmpeg

To convert .dat to avi using follow the command below

CMD: ffmpeg -i source-file.dat -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 destination-file.avi

When there is the need to download files like pictures, PDFs, or any other type of file from internet, it can be done from commad line with wget lib very easy to use.

Few insight on Wget Pacakge

Wget is a network utility to retrieve files from the Web using http(s) and ftp, the two most widely used Internet protocols. It works non-interactively, so it will work in

the background, after having logged off. The program supports recursive retrieval of web-authoring pages as well as ftp sites — you can use wget to make mirrors of archives and

home pages or to travel the Web like a WWW robot.

Wget works particularly well with slow or unstable connections by continuing to retrieve a document until the document is fully downloaded. Re-getting files from where it left off works on servers (both http and ftp) that support it. Both http and ftp retrievals can be time stamped, so wget can see if the remote file has changed since the last retrieval and automatically retrieve the new version if it has.

http://www.gnu.org/software/wget/

Homepage: http://www.gnu.org/software/wget/

Original-Maintainer: Noèl Köthe <noel@debian.org>

To Install

Debian / Ubuntu

apt-get install wget

Fedora / CentOS

yum install wget

Features

Download Single file

wget http://www.site.com/file.pdf

  • Download the entire site, use the recursive option

wget -r http://www.site.com

  • Restrict to Particular format :

download only pdf and jpg

wget -r -A pdf,jpg http://www.site.com

  • Follow external links

wget -r -H -A pdf,jpg http://www.site.com

  • By default wget will follow 5 levels when using -r option, we can change this behaviour with the -l option.

wget -r -l 2 http://www.site.com

Few updates After a long time.. The last two months have been really tough for me both professionally and personally.
Now, Getting back to form 🙂

Recently, I was evaluating the json parser. I must tell that now I have become a serious admirer or evangelist for the JSON.. Guyz JSON is excellent light-weight data-exchange format. I have used it for various application like lastfm API, Youtube, to get location & for paranomia.

It is indeed way too interesting.

For people who don’t know what  JSON please visit json.org.

I have prepared a presentation for my team please find it link below.

http://docs.google.com/present/view?id=df8mt25m_18crng9xgt&revision=_latest&start=0&theme=blank&cwj=true

API specification be reached from link below:
http://folks.o-hand.com/~ebassi/docs/json-glib

Sample Code:

I Also have a sample implement of JSON usage in Youtube, Panoromia & get location

Download the sample code from http://docs.google.com/leaf?id=0BxeLM3cdHY8EMjBjNGYwOTItYzc3Yi00MDQ1LWJiODgtYTZlYTMyNTExZDll&hl=en

Pre-requirement for JSON support
install json-glib-dev

ubuntu:
$> sudo apt-get install libjson-glib-dev
$> sudo ldconfig

Extract the soure code tar -xvf json.tar.gz

make

$>./json_parser 0 parnaromia.json

$> ./json_parser 1 youtube.json

$> ./json_parser 2 location.json

Enjoy JSON..

Introduction

This write up describel how you can create a simple project by using Autotool set along with autoconf/automake/libtool/texinfo/emacs

Getting started:

a. Download sources from SF.net (http://sourceforge.net/projects/autotoolset/)

b. Install the shar utils :

CMD: sudo apt-get install sharutils

c. fewer occasion it also asks for emac.. Install the same

CMD: sudo apt-get install emacs

creating a solution

1. Open a terminal and issue the command acmkdir with the project name

CMD: acmkdir testSample

2. you will prompted to give few details like the solution name, you email id, date other.. Fill in the formalities.

3. volia!! you have the struction for the project ready.

Configure /customising the packages and otheres deatils

Checking packages

1. customize the configure to check for the package dependance and other global flag. refer sample configure.ac in the sample solution

Adding sources

2. go to src/Makefile.am and add all the details like the include, libs bin program others. (refer sample src/Makefile.am in sample solution)

To compile & Build

go to th root of the project dir and issue

cmd: ./configure followed by make & make install

If you make any change in the makefile.am remember to run the ./reconf this will re-check the depenadance and create the make file afresh.

Building sample solution

Download the sample project from (https://sreenivasprabhu.files.wordpress.com/2009/12/testsample.docx)
rename the file to testSample.tar.gz
untar the project  testSolution.tar.gz issue following command
tar xvf testSample.tar.gz
a. cd test-sample
b. ./reconf
c. ./configure
d. make and finally make install
To run project ./src/testSample
Happy project creation

While building mozilla-headless you might come across this error that the basic X program is not installed to resolve this install X11 toolkit intrinsics library along with the development headers

in ubuntu cmd: sudo apt-get install libxt-dev

Sometimes.. No often (I must admit that ) it is irritating to listen to the Beep when people using Linux system and press tab key to auto complete the commands.

A quick way to disable this is to exec command

cmd: sudo modprobe -r pcspkr

This will temporary solve your problem. And in next restart this it will be restored.

Your could also add a line  towards the end in file “/etc/modprobe.d/blacklist.conf” which will ensure that system doesn’t beep any more

cmd: sudo echo “blacklist pcspkr” >> /etc/modprobe.d/blacklist.conf

To restore

issue cmd: sudo modprobe pcspkr OR remove the line from /etc/modprobe.d/blacklist.conf blacklist pcspkr

Objective:
The aim of this write-up is to show how easy it is to create table in sqlite table in C. The  example below show how you can create/ open a DB file, create multiple table, Insert & retrieve records.

Getting Started:

Libraies you might require
libslqite3-development package
In ubuntu you could install it with the help of apt-get
CMD:    sudo apt-get install libsqlite3-dev

To view the Db file you can use sqlitebrowser
CMD: sudo apt-get install sqlitebrowser

Quick Summary:
a. Line 49 Show how to open/create a DB file
b. Line 65, 76 create new table UserMenu & SettingsMenu
c. Line 80-84 , 86-90 Show how to insert into the database.
d. Line 104-133 : Sow how to reteve the data
f. Line 136: Finaly, show how to close the DB.

Source

  1 /******************************************************************************
  2  *  To Compile:                                                               *
  3  *  !gcc -o sql_multitable_sample sql_multitable_sample.c  -Wall -W           *
  4  *                                 -O2 -Wl,-R/usr/local/lib -lsqlite3         *
  5  *  Create multiple tables in a file and adding new rows to the table.        *
  6  *  Added callback function for the sql exec function to handle the query     *
  7  *  results.                                                                  *
  8  ******************************************************************************/
  9
 10
 11 #include<stdio.h>
 12 #include<sqlite3.h>
 13 #include<stdlib.h>
 14
 15 /* Callback called when the query is exceuted */
 16 static int callback(void *NotUsed, int argc, char **argv, char **azColName)
 17 {
 18 	printf ("\n ******** Inside Callback\n");
 19 	int i;
 20 	int rowpr=argc-1;
 21 	NotUsed=0;
 22 	printf("\n %s ",__FUNCTION__);
 23 	for(i=0; i<rowpr; i++)
 24 		printf("%s ",azColName[i]);
 25
 26 	printf("%s\n",azColName[rowpr]);
 27
 28
 29
 30 	for(i=0; i<rowpr; i++){
 31 		printf("%s ",  argv[i] ? argv[i] : "NULL");
 32
 33 	}
 34 	printf("%s\n",  argv[rowpr] ? argv[rowpr] : "NULL");
 35
 36 	return 0;
 37 }
 38
 39 int main()
 40 {
 41 	//return value
 42 	int retval;
 43
 44 	int q_cnt = 10,q_size = 150,ind = 0;
 45 	char **queries = malloc(sizeof(char) * q_cnt * q_size);
 46 	// Creating statment & opening new DB
 47 	sqlite3_stmt *stmt;
 48 	sqlite3 *handle;
 49 	retval = sqlite3_open("FirstDB.sqlite3",&handle);
 50 	if(retval)
 51 	{
 52 		// If connection failed, handle returns NULL
 53 		printf("Database connection failed\n");
 54 		return -1;
 55 	}
 56 	printf("Connection successful\n");
 57
 58 	// creating a multilple tables
 59 	char create_table[] = "CREATE TABLE IF NOT EXISTS UsersMenu (uname TEXT PRIMARY KEY,pass TEXT NOT NULL,activated INTEGER)";
 60 	char create_table1[] = "CREATE TABLE IF NOT EXISTS SettingsMenu (app_id TEXT PRIMARY KEY,gconf_path TEXT NOT NULL,activated INTEGER)";
 61
 62
 63 	char *errmsg = NULL;
 64 	// Execute the query
 65 	retval = sqlite3_exec(handle,create_table1,callback,handle,&errmsg);
 66 	if(retval != SQLITE_OK)
 67 	{
 68 		if(errmsg != NULL)
 69 		{
 70 			printf("\n@@Exec err:%s\n",errmsg);
 71 			sqlite3_free(errmsg);
 72 		}
 73
 74 	}
 75 	printf ("\n---> create_table1 retvalue %d %s \n",retval, sqlite3_errmsg(handle));
 76 	retval = sqlite3_exec(handle,create_table,callback,0,0);
 77 	retval = 0;
 78 	printf ("\n ---> create_table retvalue %d %s \n",retval, sqlite3_errmsg(handle) );
 79
 80 	// now Insert rows into table UsersMenu
 81 	queries[ind++] = "INSERT INTO UsersMenu VALUES('Speaker','Creative',1)";
 82 	retval = sqlite3_exec(handle,queries[ind-1],callback,0,0);
 83 	queries[ind++] = "INSERT INTO UsersMenu VALUES('Mouse','Logitech',0)";
 84 	retval = sqlite3_exec(handle,queries[ind-1],callback,0,0);
 85
 86 	// now Insert rows into table SettingsMenu
 87 	queries[ind++] = "INSERT INTO SettingsMenu VALUES('media_player','$HOME/media',1)";
 88 	retval = sqlite3_exec(handle,queries[ind-1],callback,0,0);
 89 	queries[ind++] = "INSERT INTO SettingsiMenu VALUES('picture_viewer','$HOME/pic',0)";
 90 	retval = sqlite3_exec(handle,queries[ind-1],callback,0,0);
 91
 92 	// select query from the table
 93 	queries[ind++] = "SELECT * from UsersMenu";
 94 	retval = sqlite3_prepare_v2(handle,queries[ind-1],-1,&stmt,0);
 95 	if(retval)
 96 	{
 97 		printf("Selecting data from DB Failed\n");
 98 		return -1;
 99 	}
100
101 	// Read the number of rows fetched
102 	int cols = sqlite3_column_count(stmt);
103 	int col =0;
104 	while(1)
105 	{
106 		// fetch a row's status
107 		retval = sqlite3_step(stmt);
108
109 		if(retval == SQLITE_ROW)
110 		{
111 			// SQLITE_ROW means fetched a row
112
113 			// sqlite3_column_text returns a const void* , typecast it to const char*
114 			for( col=0 ; col<cols;col++)
115 			{
116 				const char *val = (const char*)sqlite3_column_text(stmt,col);
117 				printf("%s = %s\t",sqlite3_column_name(stmt,col),val);
118 			}
119 			printf("\n");
120 		}
121 		else if(retval == SQLITE_DONE)
122 		{
123 			// All rows finished
124 			printf("All rows fetched\n");
125 			break;
126 		}
127 		else
128 		{
129 			// Some error encountered
130 			printf("Some error encountered\n");
131 			return -1;
132 		}
133 	}
134
135 	// Close the handle to free memory
136 	sqlite3_close(handle);
137 	return 0;
138 }

How to build & run
Issue the command build the source
CMD: gcc -o sql_multitable_sample sql_multitable_sample.c  -Wall -W -O2 -Wl,-R/usr/local/lib -lsqlite3
To run excecute ./sql_multitable_sample.

Output: A DB file FirstDB.sqlite3 will be create in the current directory.

Now, view  the DB file with SqliteBrowser
Issue CMD: sqlitebrowser FirstDB.sqlite3

Enjoy playing around with Sqlite …  it really nice!!

Background
Recent I got a change to update Asus Eeetop ET 1602 (Intel Atom N270 1.60MHz, ram 1G, 15.6 WXGA) to  moblin Ver 2.1.
Problem
While the installation went on with ease I had to struggle to get touch driver to work.
I tried installing Risin driver from http://www.risintech.com.tw/RISINTechdriver.htm but was not successful.  later I found a way to do it.
Resolution
Install the latest moblin Ver 2.1 image on the the Asus Eeetop. Open the terminal  and logged in as root.

sudo su –

Searched & install from the package manager for xorg-x11-drv-evtouch

sudo yum install xorg-x11-drv-evtouch.i586

Cofigure  udev device
Now create a link in the /etc/udev/rules.d/69-touchscreen.rules to read the config content from /dev/input/eventX :

Add folowing line towards the end of the file /etc/udev/rules.d/69-touchscreen.rules

Continue Reading »

G-streamer Installation for Moblin

Introduction
Its is bit complicated  to get  gstreamer set-up along with the varied different decoder from the gstreamer store to work great in the moblin enviroment. This write-up help to get the right combination of codec working great on moblin.
Firstly on moblin repos only the bare minimum codec is suppported. Inorder extend support to play of flv-app (for youtube), httpplaybin for LastFM & the most of the video format. follow the write-up

Step 1 : Install  the core gstreamer libary [gstreamer-0.10.24.tar.bz2]
cmd: ./configure –prefix=/usr/
cmd: make
cmd: sudo make install

Step 2: Install the base plugin
This is required to support all the extend plugin installation & use [gst-plugins-base-0.10.24]
cmd: ./configure –prefix=/usr/
during the configuration it will demand for liboil3-dev
install liboil-dev in /usr/local/lib. & export the LD_LIBRARY_PATH & PKG_CONFIG_PATH accordingly
cmd: make
cmd: sudo make install

Step 3: gst-fluendo-mp3-0.10.10 This is used for the play back of generic mp3 files
get the latest source from http://core.fluendo.com/gstreamer/src/gst-fluendo-mp3/
cmd: ./configure –prefix=/usr/
cmd: make
cmd: sudo make install


Step 4: Instaltion of  FFmpeg library code

gst-ffmpeg-0.10.8.tar.gz
gst-fluendo-mpegdemux-0.10.23
gst-fluendo-mpegmux-0.10.23
libtsmux-0.3.0

cmd: ./configure –prefix=/usr/
cmd: make
cmd: sudo make install

Step 5: Plugin support for generic codec.

gst-plugins-good-0.10.15 : These are the set of good-quality plug-ins under preferred license, LGPL
Resolves following :
– Video data  via network
– Video sink
– ALaw audio conversion routines
– Alpha channel to video conversion & preserving
– APEv1/2 tag reader
– Audio effects plugin
– Auto-detection plugins for video/audio in- and outputs
– AVI stream handling

gst-plugins-ugly-0.10.12  :
These are the set of high good-quality plug-ins that might pose distribution problems
– ASF format
– Audio CD format
– DVD format

gst-plugins-bad-0.10.13: Set of more plugins for advance codec
– Advanced Audio Coding Parser
– ADPCM decoder
– .aiff file into raw audio
– Alsa plugin for S/PDIF output
– Adaptive Multi-Rate Parser
– Adaptive Multi-Rate Wide-Band Encoder
– subtitle renderer
– Compress or decompress streams data
– playback of CD

build procedure for pligins
cmd: ./configure –prefix=/usr/
cmd: make
cmd: sudo make install

Summary

with these codec & plug-ins installed you can be guaranteed that the following formats will play perfectly fine

Referance
1. http://gstreamer.freedesktop.org/modules/
2. http://gstreamer.freedesktop.org/documentation/plugins.html   (Detailes on plugins )
Sources
3.  Gstreamer
http://gstreamer.freedesktop.org/src/
4. FLuendo & FFmpeg
http://core.fluendo.com/gstreamer/src/

How to Enabe hardware acceleration for 82865G (Intel Corporation) Integrated Graphics .
It was a quite a bit struggle to enable hardware acceleration on my desktop PC. I hope to share my learning

The problem:
I had a Intel Corporation 82865G Integrated Graphics Controller & had to enable hardware acceleration for the same. The software acceleration Mesa was sloppy and was not rendering properly..

General FAQ:

a. How do you know that what form of hardware setting is enable in you system?
If the output from the glxinfo program reveals that the OpenGL vendor or the OpenGL renderer is Mesa project the your system has a software acceleration enable. It may be advised to install a better driver for your graphics.
cmd: glxinfo | grep vendor
Or
glxinfo | egrep -A2 “direct rendering|OpenGL vendor”
b. How do you know Hardware acceleration is enabled?
check for the glxinfo | grep vendor if it returns “OpenGL vendor string: Tungsten Graphics, Inc” it is hardware accelearation enabled. Also check for the DRI region in /etc/X11/xorg.conf value will be set to 1.

Resloution :
1. login as root and first take a copy of you xorg.conf (/etc/X11/xorg.conf)  kind of fallback statergy.
2. Now get the hardware details by issue the following command
cmd: lspci | grep VGA
3. if the lspci command returns VGA compatible controller: Intel Corporation 82865G Integrated Graphics Controller you could follow the following steps to enable hardware acceleration
a. Install the package
Add the following lines to your /etc/apt/sources.list:
deb http://ppa.launchpad.net/siretart/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/siretart/ppa/ubuntu jaunty main

Import the appropriate GPG key:
sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xce90d8983e731f79
Install the driver:
$ sudo apt-get update
$ sudo apt-get install xserver-xorg-video-intel-2.4
$ sudo apt-get install xserver-xorg-video-intel
Restart X by running “sudo /etc/init.d/gdm restart” Or better to be on safe ground reboot the system sudo reboot

RollerBack
If in case after the reboot the X.org does not start at all. Then you could revert back to the orginal one by pressing Ctrl+Alt+F2, logging in the shell and replace the xorg.conf file to the original one.

4. Else if it return nvidia and ATI the you might need to install the specific driver.
For Nvidia is simple install nvidia-settings using apt-get
cmd: sudo apt-get install nvidia-settings