Pages

Saturday, November 28, 2009

Convert MTS/M2TS(AVCHD) to AVI

Yesterday, I used a Sony camera to record  some our video demos.  Unfortunately, output videos are in AHCHD format. So, I have to find a way to export them to avi or other format before putting to our R&D press.
Actually, there are many commercial softwares to do this. However, I don't like them. He he, I love things  free and open source. FFMPEG is the best one in the open source world for conversion video/audio format. Anyway, I found some bad things with FFMPEG:
+ Difficult for compilation in Windows. It was developed for best use in Linux world. To compile it in Windows, we need Cygwin or MSYS.

+ Loss documentation in practice. It takes me more than 1 hour to find the best command to convert MTS file to avi.



Finally, I compile FFMPEG successfully in Windows and my Ubuntu. I also run it successfully for my conversion need. However, let me show you some shortest ways to work with FFMPEG for conversion from MTS to AVI.

Install FFMPEG

In Ubuntu, it's very easy. Just open Synaptic package manager to find and install ffmpeg.
In windows, you need to compile ffmpeg before using. However, there a site contains some distribution binary package. You can download the final package to use in http://ffmpeg.arrozcru.org/builds/

Command to convert your MTS file to avi



ffmpeg -i your-mts-file.MTS -vcodec libxvid -b 18000k -acodec libmp3lame -ac 2 -ab 320k -ar 44100 -deinterlace -s 1440x1080 your-output.avi


If you run this in Ubuntu and found the error: Unknown encoder 'libxvid', please install libavcodec-unstripped (you can find this in synaptic package manager).

To understand more about above command, you should read the ffmpeg documentation here

Wednesday, November 25, 2009

Playing augmented reality with my business card

Augmented Reality is one of topics that I am doing research. I choose a simple demo to make this topic more interesting: playing with business card.
The target of the demo is: playing a video after detecting the marker on the business card.

FlarManager is the library that I choose to work because it's very flexible and easy to use. It wraps FlarToolkit and make it works with many Flash 3D engines: Sandy, Papervision3D, Away3D,...
This is the result:






Below is list of step that I did to make this demo run:
Step 1: Download FlarManager. You can get its source code from SVN here.
Step 2: Configure FlexBuilder and setup the project to build the whole source code of FlarManager (just follow steps in this tutorial)
Step 3: Capture my business card and print out the logo of my company.
Step 4: Use this online tool to create marker from the printed logo. After finishing this step, we get the output is a pattern file using in recognizing the marker under camera. You should save the output file with .pat extension (example: mylogo.pat). You must remember the resolution of your pattern for using in configuration of next steps.

Step 5: Open the FlarManager project by FlexBuilder, the FLARManagerTutorial_Collada.as is the default running demo. So, I choose this file to customize the code. I am very lazy and don't want to do any complex thing. He he
Step 6: Configure the marker.
+ Copy our .pat file into resource folder (or any places in your project).
+ Go to \resources\flarConfig.xml, add your pattern file location in the patterns section.

Step 7: Go to the FLARManagerTutorial_Collada.as file and write code to load video and play it on a plane. This is a very simple task for any Flash developer.

Step 8: Play the video when the marker is detected. To do this, you just need to add the Plane as child of this.activeMarker. FlarManager did everything and return to us the activeMarker in correct position. So, we just add our game above the active marker and play.


Do you want to have a special an AR business card with your own logo? He he, try this.

Monday, November 23, 2009

My tech stream Yahoo pipe

I love tech. So, reading tech news is 1 of my habits. I would like to share with you my Yahoo pipe to combine and collect latest technologies (it is not enough to cover all news every day, he he - but these are sources that I often read).

http://pipes.yahoo.com/trandangkhoa/technews
To get run and get data from this pipe as RSS, you can use this link:

http://pipes.yahoo.com/pipes/pipe.run?_id=140fad2e657ef7c3c1b8ce547772be87&_render=rss

Saturday, November 21, 2009

Build iPhone application by Flash CS5

This week, we need to decide whether we should choose putting Flash Professional CS5 into research/training targets of next month. Actually, we already had an iPhone team - with senior developers - has much experience on many projects. However, some Flash developers in our company  want to join to iPhone development. So, we need to consider learning roads to help them to join this interesting domain in shortest time.


How Flash CS5 supports developers to create iPhone application

Adobe creates a very clever solution to enable your Flash content to run on the iPhone. They don't create a Flash Player and run your Flash content inside. The Flash Professional CS5 support a iPhone packaging tool converts your Flash content into a real iPhone application. If you have experience on Unity 3D iPhone, you can imagine this as the same packaging tool.

Advantages of Flash CS5

+ Flash Professional CS5 is the only Windows development environment for iPhone Applications. We don't need to prepare expensive Mac computers for iPhone development.
+ There are more than 2 million Flash designers/developers compared to the 65,000 iPhone developers. The Flash community is so big, so it's easier to find solutions for technical issues in development.
+ There are millions of Flash games begging to be converted to run on the iPhone. => this forces Adobe must find a way to support this. It's not temporary, it's a real trend => Adobe solution must be persistent in a long time.
+ Familiar environment/languages with Flash developers => easy to learn.

Disadvantages

+ Adobe can not catch up with new advanced features in latest iPhone SDK. Flash developers can not use latest technologies from Apple immediately.
+ Currently, some video formats are not supported in the Adobe conversion solution (H264 is an example).
+ You cannot use the cool Flash PixelBender technology released last year in your iPhone Apps at this time.
+ The iPhone itself uses a fraction of the power compared to a PC. Be careful what you program. It may look good on your laptop but barely run on your iPhone.

Final conclusion

Flash CS5 for iPhone development is a great news. However, we can not choose something not stable for production. We need to try more before making decision. This will be a research target in R&D team later. Any new technology always needs time for growing and being proved its strength in the real life.

We're very happy to receive your feedback or any good news from this tech.

Thursday, November 12, 2009

How the iPhone locates you?

This article is for my beloved developers - who always want to know what the truth behind the stage is.

All content in this article is based on  iPhone cookbook - a great book for iPhone developers.




Methods for positioning used in iPhone

The iPhone uses three (or possibly four) methods to locate you.These technologies including:
+ GPS Positioning
+ WiFi Positioning
+ Cell Tower Positioning
+ Internet Provider Positioning

GPS Positioning

GPS system tracks your movement courtesy of a series of medium Earth orbit satellites provided by the U.S. Department of Defense. These satellites emit microwave signals, which your iPhone picks up and uses to triangulate your position to a high level of accuracy. Like any GPS system, this requires a clear path between you and the satellites, so it works best outdoors and away from trees.

WiFi Positioning

Core Location’s preferred pseudo-GPS geopositioning method calls on Wifi-positioning service provided by SkyHook Wireless.

SkyHook offers extremely accurate WiFi placement. When an iPhone knows the WiFi and WiMax routers you are near, it uses their MAC addresses to search SkyHook’s databases, positioning you from that data.

This way provides pretty accurate positioning and can usually locate you within a few hundred feet of your actual location

Cell Tower Positioning

Currently, iPhone use cell tower positioning service through:
+ Google Maps cell tower positioning.
+ SkyHook cell tower positioning (not sure 100%).

By this way, the iPhone uses its antenna to find the nearest four or five cell towers (of the service providers) and then triangulates your position based on the cell tower signal strength. You’ve probably seen cell tower location in action; it’s the kind that shows you about a half mile away from where you are standing—assuming you’re not standing right next to an actual cell tower.

Internet Provider Positioning

This approach uses an Internet provider location to find the nearest mapped Internet provider’s central office. The returned data is typically up to several miles off your actual location—unless you happen to be visiting your Internet provider.
SkyHook actually offers a third positioning approach, but it is never seen the iPhone use.

Hybridizing the Approaches

So, what iPhone acutally works with 4 above methods?

The iPhone approaches location in stages. Based on the accuracy level you request, it uses a fallback method. If it cannot accurately locate you with GPS or SkyHook WiFi mapping, it falls back to the cell tower location of Google Maps. If that doesn’t work, it presumably falls back further to SkyHook Internet provider location. And if that doesn’t work, it finally fails. The latest releases of the SDK actually provide multiple (asynchronous!) success callbacks for each of these fallback methods. You may receive three or four results at any time.

Wednesday, November 4, 2009

Programming language community index 2009

This is the index from Tiobe website of top programming languages until 2009


Position
Oct 2009
Position
Oct 2008
Delta in Position
Programming Language
Ratings
Oct 2009
1
1

Java
18.718%
2
2

C
16.891%
3
5

PHP
10.390%
4
3

C++
9.911%
5
4

(Visual) Basic
8.729%
6
8

C#
4.433%
7
6

Python
3.914%
8
7

Perl
3.776%
9
11

JavaScript
3.033%
10
10

Ruby
2.458%
11
9

Delphi
2.140%
12
13

PL/SQL
1.020%
13
49

Objective-C
0.902%
14
14

SAS
0.805%
15
16

Pascal
0.669%
16
20

ABAP
0.661%
17
19

Lisp/Scheme
0.605%
18
22

MATLAB
0.577%
19
12

D
0.570%
20
15

Lua
0.527%



The long term trends for the top 10 programming languages can be found in the line diagram below.

Predicting trends from this information
+ Some traditional languages as Java, C is down (not too much). These languages will not die (at least in 10 years later) because of the need to develop/maintain enterprise application/ embedded systems.
+ Scripting languages like Ruby, Python are trends at this time.
+ PHP still keeps its position. There are many open source from PHP community with great features. It can offer the cheapest solutions to develop application for small/medium organizations.
+ Objective C is still new but a hot trend because of the need to develop applications on Mac and iPhone.