You bought a brand new phone with S40 OS and it promised all things like video playback for a dozen of formats like 3GPP formats (H.263), H.264/AVC, MPEG-4, WMV, ABC, blah blah…. great! So, you copy an MPEG-4 format video file and play it… Wham! “Video Not Supported”… What the… Your shiny new phone doesn’t look that shiny anymore right?

You are not alone! At least you have my company… MPEG-4/H.264 encoding is a bit complicated format with so many variations because of its different profiles & levels.  Unfortunately many entry and mid segment devices (Example: Nokia Asha series phones) does not add support for all the variants…

So are we left to rot with our S40 phones without videos? No! Definitely not! So, we wear our explorer gear and stop not till we find the solution… searching… searching… resting…. searching…. scratching head…. searching… aaaahhhh…. here it is….  “Handbrake” our saviour… So lets go ahead and apply the hand brake to zip forward our hurdle…  weird!

Mac users, you have one more hurdle to pass. Handbrake dmg version for mac does not have controls to tweak the MPEG-4 to match S40, So you should install HandbrakeCLI (command line interface)

I am going to explain here the command I used for command line interface, I think GUI version for windows has provision to pass these parameters in advanced tab 

Here are the things I did to get the videos work in Nokia Asha 200 (Note this really cool site maintained by Nokia with complete specs for ALL its phones)

  1. Install HandbrakeCLI
  2. Open terminal and run the following command:
      HandBrakeCLI -e x264 --x264-profile baseline -X 176 --keep-display-aspect -r 15 -q 20 -B 64 -i input_file_path -o output_file_path

Where,

-e x264 –> Encoding format (x264 stands for MPEG-4)
–x264-profile baseline –> x264 profile (could also try ‘main’ profile)
-X 176 –> Maximum width of the video (I chose 176px)
–Keep-display-aspect –> Maintains the aspect ratio of the input video
-r 15 –> frame rate (check your phone specs for supported video playback frame rate. I chose 15 frames per second)
-q 20 –> Video quality (0 to 51 where 0 is for high quality and 51 for lowest. 20 is standard definition)
-B 64 –> Audio quality in bitrate (64 stands for 64kbps)

Play around with different values that suits your phone… Have fun!

Somethings in the world are not expected to work seamlessly and needs a blog post tutorial. Installing RSA SecureID key into your iPhone is one of them…

RSA has this app for iPhone to generate keys that is needed to login to corporate VPNs enabled through RSA. Installing it is easy. But, getting the key into it is not very straightforward. Well, No more… because you folks have this tutorial ;)

Install the RSA app (linked above) into iPhone and get your RSA login key .sdtid file before doing the instructions below…

  1. Download the RSA’s TokenConverter tool (It will ask you for a valid email id and accept license agreement terms)
  2. Open your command prompt and run the following command from the folder where you have extracted TokenConverter tool
    TokenConverter <.sdtid file path> -mobile -p <password if any>
    some corporations will create your .sdtid file with a unique password. Type it in if you got your .sdtid file with a password 
  3. The above command when executed successfully should print a generated ctf string in the console. Copy it. It will look something like
    com.rsa.securid://ctf?ctfData=2000119722625607285525965262252517630605010534242616025667355410
  4. Compose a mail with a hyperlink pointing to the above copied url and send it to an account accessible from your iPhone. Sample:
    <a href=”com.rsa.securid://ctf?ctfData=2000119722625607285525965262252517630605010534242616025667355410″> Click here to install the key</a>
  5. Open this mail in your iPhone and click on the link to automatically load RSA SecurID application. It will start installing the token.
  6. Goyala!!! It is done! You should be able to generate login tokens on the move from now.

Indian Festivals 2011

Posted: January 26, 2011 in Social

Want to know all the possible Indian festivals of 2011? Just download India Festivals.ics file and open it any supported phone (Android, iPhone)/PC (Mac, Linux or Windows) to add it into your calendar.

Note: I tried by best to add all the possible festivals into it (as far as I could google). So, Beware and don’t hold me responsible for your god’s fury! :-)

As you might have heard Zylog Wi5 is a wireless broadband service available in many Indian cities. Even though it is wireless, they will install a small signal receiver (modem+router) in the home roof tops for better signal reception. If you already have a home router to connect all your internet hungry devices, you might be perplexed as how to make them work together. Here is how the situation looks…

Wi5 to local router connection

The following instructions will help you to make it happen. What we are trying to do is connecting a router to another router…

Wi5 WLAN Router:

  1. Make sure you are able to connect to the internet directly without your router in the picture
  2. Open the Wi5 router’s admin page (192.168.1.254 by default)
  3. Go to the LAN Interface under TCP/IP settings and make sure DHCP server is set in server mode
  4. Updated DHCP client range wide enough based on how many devices you want to connect to your home router

Home Wireless Router:

Almost all the routers will have atleast 4 LAN ports to connect other devices to the network and a separate LAN port for connecting the ISP’s modem. Since Wi5 does not actually have a separate modem but instead is a modem+router, how you connect the both is bit different…

  1. Connect the Wi5 router to your home router in one of the 4 LAN sockets
  2. Login to your home router and disable its DHCP server. There can be only one DHCP server in a network and since we have enabled Wi5 router’s DHCP server, this is not needed.
  3. Restart the router if needed/prompted

This should do.

eval() in java?

Posted: November 3, 2010 in Programming
Tags: , , ,

Here is the question from my friend (ex-colleague):

“I have a mathematical expression say (45 + ((4 – 25) + 2)) as a string. How can you evaluate it to find the result using JAVA programming language?”

Well, this is very easy with javascript as it has the powerful eval() function. But java is static, strongly typed, not-that-fexible language. So, this cannot be provided as a language feature which leads me to either search for some available libraries or, write my won little library. If you are reading this post, you know by now what my decision was:) Come on, what’s fun in searching for someone’s work ;) (Well, not always)

So, here it is… This would have been much simpler with dynamic language like Groovy… But, the requirement clearly said JAVA :(

Logic is quite simple. The given input is an infix expression. Use stack and keep pushing all the elements (including braces) till you encounter a closed brace. Now, popping from the stack till you encounter an open brace will get you an operator and 2 operands. Evaluate it and push back the result to continue the same logic till the end of the input string.

 1 package com.rs.utils;
 2
 3 import java.util.ArrayList;
 4 import java.util.Stack;
 5 import java.util.regex.Matcher;
 6 import java.util.regex.Pattern;
 7
 8 public class Evaluator {
 9
10 	public static int eval(String infixExpression) {
11 		Stack<String> stack = new Stack<String>();
12 		String trimmedExp = infixExpression.replaceAll(" ", "");
13 		for (String c : split(trimmedExp)) {
14 			if (")".equals(c)) {
15 				if (!"(".equals(stack.peek())) {
16 					String result = performOperation(stack.pop(), stack.pop(),
17 							stack.pop()) + "";
18 					stack.pop(); // remove also the open bracket
19 					stack.push(result);
20 				}
21 			} else {
22 				stack.push(c);
23 			}
24 		}
25 		return Integer.parseInt(stack.pop());
26 	}
27
28 	private static int performOperation(String operand2, String operator,
29 			String operand1) {
30 		int op1 = Integer.parseInt(operand1);
31 		int op2 = Integer.parseInt(operand2);
32 		switch (operator.toCharArray()[0]) {
33 			case '+': return op1 + op2;
34 			case '-': return op1 - op2;
35 			case '*': return op1 * op2;
36 			case '/': return op1 / op2;
37 			default: return 0;
38 		}
39 	}
40
41 	static String[] split(String exp) {
42 		ArrayList<String> parts = new ArrayList<String>();
43 		Pattern pat = Pattern.compile("\\d++|\\+|\\-|\\*|/|\\(|\\)");
44 		Matcher matcher = pat.matcher(exp);
45 		while (matcher.find()) {
46 			parts.add(matcher.group());
47 		}
48 		return parts.toArray(new String[0]);
49 	}
50 }
Thanks to code2HTML

LG TV… misleading…

Posted: October 17, 2010 in Gadgets

I recently brought this LG 42″ plasma tv which comes with an USB port. The product manual said it supports DivX format videos but only after getting it to home, I found it plays more formats than it advertises… :-S

It actually plays all DivX, Xvid & VOB files. But fails to recognize mp4 videos. Well, you might ask why should I be concerned if it plays more than it mentions right? If I had known this before, I might not have ordered AppleTV. :-) (Out of the box even it does not play all the formats but you can install Boxee into it)

I guess all the latest LG TVs does the same. Better check it in the store with a flash drive before buying… I got mine for 36,500Rs in Girias.

Spot Fine!!!

Posted: April 4, 2010 in Social

Next time you get caught for a traffic violation, use the below information to your advantage :)

Offence Code Name of the offence Penal Section Fine Amount
RR 01 Failue to renew registration U/s 177 Rs. 100
GP 02 Stop line violation U/s 177 Rs. 50
GP 03 Lane jumping U/s 177 Rs. 50
GP 04 Yellow line cutting U/s 177 Rs. 50
GP 05 No entry U/s 177 Rs. 50
GP 06 Signal violation U/s 177 Rs. 50
GP 07 No ‘U’ turn U/s 177 Rs. 50
GP 08 Closed to lorry traffic U/s 177 Rs. 50
GP 09 No parking U/s 177 Rs. 50
GP 10 Triple riding U/s 177 Rs. 50
GP 11 Improper uniform & other cases U/s 177 Rs. 50
GP 12 Refusal to ply U/s 177 Rs. 50
GP 13 Demanding excess fare U/s 177 Rs. 50
GP 14 Over height U/s 177 Rs. 50
GP 15 Two persons in drivers seat U/s 177 Rs. 50
GP 16 Tampered meter seal U/s 177 Rs. 50
GP 17 Protruding in front/rear of vehicle without red flag/light TNMV Rule 396 U/s 177 Rs. 50
GP 18 Dazzling head light U/s 177 Rs. 50
GP 19 Defective number plate U/s 177 Rs. 50
DO 20 Disobdience of orders-obstruction and refusal to give information U/s 179 Rs. 50
UP 21 Allowing unauthorized persons to drive U/s 180 Rs. 50
WL 22 Driving vehicle in contravention of Section 3 or 4 without D.L. or below the age of 18 U/s 181 Rs. 500
DP 23 Driving vehicle by a person who is disqualified U/s 182(1) Rs. 500
LO 24 Offense relating to licenses (Disqualified for holding or obtaining conductors license) U/s 183(2) Rs. 100
OS 25 Driving at Excessive speed limits U/s 183(1) Rs. 400
CE 26 Driving at excessive speeds etc U/s 183(2) Rs. 300
RD 27 Driving / Riding dangerously including talking on cell phone while on driving / riding U/s 184
U/s 177
Rs. 1000
Rs. 100
DD 28 Drunken Driving U/s 185 Court
UD 29 Driving when mentally or physically unfit to drive U/s 186 Rs. 200
RT 30 Racing and Trails of speed U/s 189 Rs. 500
EE 31 Emitting Excess Smoke U/s 190(2) Rs. 50
TS 32 Tampered Silencer U/s 190(2) Rs. 50
HC 33 Musical / Air Horn cases U/s 190(2) Rs. 50
WR 34 Using the vehicle without registration U/s 192 Rs. 500
WP 35 Using the vehicle without valid permit or permit violation U/s 192 Rs. 500
EW 36 Driving vehicle exceeding permissible weight U/s 194 Rs. 100
UI 37 Driving uninsured vehicle U/s 196 Rs. 1000
IV 38 Unauthorized interface with vehicle U/s 198 Rs. 100
OT 39 Obstruction U/s 201 Rs. 50
ID 40 Power of officer to impound document U/s 206
DV 41 Power of officer to detail vehicle U/s 297