Message Bundle Translator for Google Gadgets

November 25th, 2009 No comments

A few days ago I wrote a simple application which helps with internationalization of Google Gadgets. There is a special format of dictionary files for gadgets – “message bundle” – shown in the picture below.

My application translates these files automatically (with the help of Google Translator of course).

Message Bundle Translator for Google Gadgets is an open source application written in Adobe FLEX AIR.

Categories: Uncategorized Tags:

Password generation

October 21st, 2009 No comments

This summer, I wrote some useful java classes for generating random passwords.

Creating random password can be useful in situations such as the following:

  • A user forgot his password for our application. Our application sends an email with a new temporary password.
  • We want to verify, if a mobile phone number submitted by user is correct. Our application sends an SMS with the new temporary password.
  • A user of our application creates a new account for his colleague or family member. Our application creates a temporary password for that account.
  • For our own purposes. We want to create a good password for our personal usage.

Creating a random password is not so easy as might by thought. There are two commons errors with this:

  1. The password generated is an inelegant word, for example: “1something2″. We doesn’t want to send such a password to our potential clients.
  2. The password generated contains problematic characters, for example: “1″ and “l” or “O” and “0″. There is a problem, when the user rewrites the password from one device to another, e.g.: from a mobile phone to a web application running on a laptop.

That’s why in my application I create password in the form: 2 letters followed by 1 digit followed by 2 letters followed by 1 digit and so on. For example: ab2cd3ef4. Of course, the randomly – generated password contains only safe characters.

I decided to publish this classes to the open source community. You can use my library in your application on LGPL terms. Here is an example of usage:

// create a new one time password for sending via sms or email
// (4 chars - about 1e5 unique combination)
String password = new PasswordGenerator().generate();
// create a new strong password
// (8 chars - about 1e10 combination)
String strongPassword = new StrongPasswordGenerator().generate()

Using this library is simply for maven2 fans. If you are not already a fan of maven2, I advise you to become one. In your maven2 application in pom.xml file add a dependency:


You have to download and build the source by typing:

svn checkout jakubiak-generators-read-only
cd jakubiak-generators-read-only/jakubiak-generators/
mvn clean install

You should see the success message. Now the installation is completed and you can use this library.

By the way, I also wrote classes for creating a random MD5 number and for creating a random key. MD5 is obvious. The random MD5 numbers are commonly used in web applications, for example as a session cookie. In such a scenario a KeyGenerator class is an improved replacement for the random MD5. The KeyGenerator class create a huge random number bigger than the MD5. (“Bigger” in this case means a potentially larger number is possible). This number is encoded using 62 safe for URLs chars: a-z, A-Z, 0-9. Thanks to that its string representation is shorter and more safe than a hexadecimal encoded MD5.

// create a statistically unique key
// (22 chars safely for URLS - about 2e39 unique combination)
String key = new KeyGenerator().generate();
// create a random MD5 and encode it hexadecimal
// (32chars - 2^128 combination)
String md5 = new Md5HexGenerator().generate();

You can also write your own generator, by implementing IGenerator interface.

Categories: Java Tags: , ,

RTMP – how it make YouTube?

October 7th, 2009 2 comments

There is a problem with RTMP. It works on 1935 port. In fact it’s not a problem with RTMP but with ISP. ISP like filtering internet traffic and like packets queuing. That’s why connections on port 1935 – which is not wheel – known in Internet – work worse than connection on port 80. Adobe know that and have introduced RTMPT, which is an encapsulation of RTMP in HTTP, which works on port 80.

YouTube does something else. You see, You Tube allows recording from web cam. It uses RTMP to do that, but RTMP works on HTTP (80) port. I noticed it by using NetLimiter.

I decided to check it carefully. Is it RTMP on its unusual port or is it usual RTMPT? Using Wireshark as my oxygen supply, I dove deep in the hidden depths of the system. Wireshark allows me to sniff internet traffic. I was wondering what exactly my laptop send to YouTube. I would have expected many POST requests for RTMPT. There weren’t. It was something like

instead. rtmp:/… – 99% YouTube use RTMP on port 80.

It’s an interesting idea. I can check it out to give me an idea of how to write similar routines.


Categories: Uncategorized Tags: ,

Red5 and JPA with Maven2

May 27th, 2009 7 comments
This article tells you how to build an application for Red5 server with Maven2. We are going to use Spring, JPA, Hibernate and PostgreSQL database. We aren’t going to use any IDE, instead we are going to use only Bash commands. I will run it on the FreeBSD server. The task of the application is not important. It’s very simple. It’s going to be a Hello World program. The application is going to check if a user has a permission to publish a video on Red5 server. The permission is granted based on sender’s IP address. Accepted IPs are stored in a PostgreSQL database. And, the best thing is that I have already written and published the app, so I’m going to write about a ready product. Let’s get started. My server has already installed:
  • Java 1.6 (Diablo JDK)
  • Maven 2.0.9
  • PostgreSQL 8.3
You have to get the application sources from SVN:  
svn checkout jakubiak-red5-read-only
    This way, you get sources of jakubiak-red5 project, which include our example application. jakubiak-red5 project is linked to Red5 sources using svn:externals. This mean, Red5 sources are downloaded together with my project. Now it’s time for the first compilation. Thanks to a Marcello Teodorii’s contribution the application is built without any problems.  
cd jakubiak-red5-read-only/jakubiak-red5-pom/
mvn clean install
    Now, maven starts getting dependencies for the application from the Internet. It can take some time. After downloading, we have to wait for compilation of about 700 Java classes. At the end, we will see a success message. (As you can see, I have been waiting 16 minutes, however it’s built much faster for second time.) Now, you have to create PostgreSQL a database and a user. As a password type demojpa.  
createuser -h localhost -U pgsql -S -D -R -P demojpa
createdb -h localhost -U pgsql -O demojpa demojpa
    You have to create the database now, because it’s necessary for compiling and testing the application.  
cd ../jakubiak-red5-demo-jpa/
mvn clean install
    You have to wait few minutes. You have just built the application. The result of maven tasks is a war file. You have to deploy the war file on Apache Tomcat. I prefer 6.0.18 version.  
cd ../..
wget ""
tar xvfz apache-tomcat-6.0.18.tar.gz
cp jakubiak-red5-read-only/jakubiak-red5-demo-jpa/target/tomcat/webapps/jakubiak-red5-demo-jpa-war.war apache-tomcat-6.0.18/webapps/
    You make Tom cat do it’s job. Mrrrau :)  
cd apache-tomcat-6.0.18/
tail -f logs/catalina.out
    In Tomcat log we are looking for a success. It’s time for testing. You have to start a web browser:  
    It loads a standard application distributed with Red5 – publisher. In “Location” field type:  
    RTMP is a protocol used by Flash applications. “demojpa” is an accessible name of our application. Press “Connect” button. On the “Settings” tab you have to select a web camera and a microphone. You have to test publishing. It shouldn’t work, because your IP address doesn’t have permission for the application. We can find a warning message in Apache Tomcat logs. You have to put your IP address in the database.  
psql -h localhost -U demojpa
INSERT INTO hostallow VALUES ( '' );
    Let’s go back to the web browser. Now, you can publish the video and admire the results. Now you have a working application. It’s time for you to learn.  
find . -type f | egrep -v .svn
    From the beginning, StreamPublishSecurityTest – is a Java class for testing sensitive code in your application. HostAllow is a JPA entity class defining a table in the database. DemojpaApplicationAdapter defines a starting point for Red5 application, where I have placed a code enabling the security rules. StreamPublishSecurity is a real worker class – it checks the security rules against the database. Next: persistence.xml is a file for JPA, you put entity classes there. red5-services.xml is a very important file, where we you configure Spring beans used by your application. There are also definitions of the database connection. Also, you can put Red5 remote services there. logback.xml is a log system configuration. red5-core.xml, red5-common.xml, beanRefContext.xml and defaultContext.xml are configuration files for Spring beans used by Red5. If you want to improve Red5 this is the place to hack. red5-web.xml is a file where you can change RTMP name of your application – “demojpa”. is a file with database properties. demojpa-servlet.xml is a file for defining MVC controllers of your web application. web.xml is the most important file for war archive, it defines web application components. We have dealt with publisher.swf earlier. pom.xml is a magic Maven file, which describes how maven has to build the application. Cool, isn’t it?
Categories: Java Tags: , , , ,

jakubiak-red5 modularization

April 22nd, 2009 6 comments

Recently a new programmer Marcello Teodori has joined to jakubiak-red5 project and he has done very good job. He has split jakubiak-red5 project into new modules. He has extracted tomcat, jetty and scripting from the core module. Thanks to that the core module is lighter and it has less irritating dependencies. It was extremely important to remove to Groovy dependencies from core, because it was a lot of jars.

Jakubiak-Red5 it’s a project whose aim is standardization of building Red5 server using maven2. By using jakubiak-red5 it’s easier to build enterprise application which use Red5. This project provides maven pom files. Red5 sources remain intact, they are linked with svn:externals.

In future I would really like to make it possible to run a reduced to minimum version of Red5 using Java Web Start. Thanks to that, it would be possible to record a video from a webcam in a high quality. However, as for now, I still can’t do it.

In its beginnings Jakubiak-Red5 was my experimental project, and that’s why it’s called this way. Soon, the prefix “Jakubiak” will have to be removed, because it’s no longer only my project and new programmers contribute a lot to it. Thanks Marcello!!!

Categories: Java Tags: , ,

Maven2 + Red5 + Xuggle

February 26th, 2009 6 comments


This time I would like to invite you to my project jakubiak-red5, the purpose of which is the combination of the following technologies : Red5, Xuggle and Maven2. Xuggle is a tool for the conversion of video images in real-time. Red5 is a server of multimedia applications. Maven2 is the most efficient tool for organizing the process of building applications. My goal is to combine them all together.


My project is ,in fact it is a building script. It is supposed to be an instruction for Maven2 on how to build server Red5 and a (Java) part of Xuggle library. Let’s have a look on how it works. In SVN repository there is a structure of the Maven project, along with the files pom.xml. The source code of Red5 and Xuggle libraries does not change because it is connected to the source code of the original projects using svn:externals. All you need to do in order to build a project is to write mvn clean install. I assume that each Java programmer is already a fan of Maven or will become such in a future, so there is no need to dwell on it any more.

The results of work are the dependencies that can be used in a new project – a new Red5 based application (or Red5 and Xuggle based).

Welcome to a battle-field!

What we need is Xuggle. The installation of Xuggle Instalacja Xuggle jest prosta seems to be suprisingly simple, compared to the capability of this library (at least for Windows) Setup.exe.

The next installation is Red5. I recommend you to try wersje 0.8RC2 version. Again, follow the procedure setup.exe. For Windows you will need a 32-bit Java.

One more thing – a binary Maven2. Download, unzip and try out.

Finally, you need to download the sources of my project:

svn checkout jakubiak-red5-read-only


This command is supposed to download the sources of my project as well as the sources of Red5 server, and partly the sources of Xuggle project. Now it’s time for a testing compilation:

cd jakubiak-red5-pom/
mvn clean install
cd ../jakubiak-xuggle-pom/
mvn clean install


Yet, before we can finally see this long expected message, we need to use the Internet to download a few dependencies which, for a couple of reasons, might not be found in depositories and they are not downloaded automatically.

It’s a testing time now. You need to publish on the Red5 server the examples build by my script ; in other words, just copy the directories:

cp -r jakubiak-red5-oflaDemo/target/jakubiak-red5-oflaDemo-0.8-SNAPSHOT/ ../../Program Files (x86)/Red5/webapps/
cp -r jakubiak-xuggle-xuggler-red5-videotranscoder/target/jakubiak-xuggle-xuggler-red5-videotranscoder-1.0-SNAPSHOT/ ../../Program Files (x86)/Red5/webapps/
net start Red5


Once we start up the internet browser, we can try out a few examples:

If we want to see Xuggle “in action”, we need to connect to the application videotranscoder: rtmp://localhost/videotranscoder using the Publisher program. The name of the stream should be preceded by a prefix “xuggle_“.

My library Jakubiak-red5 to some extend replaces the usual building process. Red5 and Xuggle are built by means of Apache Ant and Ivy (I am genuinely thrilled hearing these names). I, on the other hand, prefer building them using Maven2. It is quite a complex and time-consuming process, yet it is definitely worth the shot, because it enables me to create applications combining lots of fascinating technologies, for example: JPA, Spring. I can also create the WAR application including Red5 and Xuggle, which will then be started up on Apache Tomcat 6. Moreover, I can enjoy working with Eclipse IDE. To sum up, it offers lots of opportunities.

However, the most significant fact is that my library does not modify the sources of Xuggle and Red5 projects.

One of the alternatives to my building script would be to add the libraries of JAR, Red5 and Xuggle straight to the Maven repository. But, this method will not be sufficient in building WAR version of Red5 application. WAR version is extremely useful, but I will return to this issue next time.

Categories: Java Tags: , , ,

Task Calculator Google Gadget

February 19th, 2009 10 comments

July 26, 2007

Some time ago I decided to keep track of my daily activities and schedules using Google Calendar. What I need today is an overview – to check how much time I actually spent on a particular activity. I would like to check out how much time it took me to work on my client’s project, or how many enjoyable hours were assigned to playing basketball.

Recently I have come up with a few code lines which demonstrate how to start an integration of Google Calendar and Zend Framework. Today I decided to proceed with it and get down to the project again. I started working on Google Gadget, – a tool which is supposed to perform this kind of integration. Right now the gadget is capable of downloading the tasks from an average-size calendar, calculate the total work time for all the records in a calendar, as well as for the records whose titles correspond to a given phrase. It is possible to define several phrases. All in all, it seems to be a quite promising herald of a project that a wide group of net surfers might find very useful. The project is available at: To find the gadget you need to go here: Speaking from my experience, this gadget has already proved its usefulness and sufficiency. I can easily calculate the time devoted to work vice versa the blissful hours spent on entertainment. Such “searching for lost time” makes me think about getting down to work and trying to finish this project… Anyone willing to join me and pay his tribute to the internet? You are more than welcome, the project is open, the license you need is GPLv3. Its temporary name is Task Calculator but, as I have doubts about that, it seems to me that Task Report would sound better. I am not sure yet.


September 27, 2007

Some time ago I began working on a new project – Task Calculator. Its function is to create a report which would sum up the total work time – I need such data for invoicing my client. The work time data are recorded in Google Calendar. The Project is still only a proof of concept – the concept itself proved right, the calculator does all the counting – however, there are still a couple of issues to be improved.

In order to start the calendar you obviously need to have your account in Google. The Task Calculator works as a gadget embedded on Google Home Page. First you have to search for the private address of XML calendar in calendar settings.

Next you need to install the gadget Taks Calculator – click here. Then you copy the URL address from Google Calendar and place it the gadget settings. There is a possibility of adding the key words, which will appear in a report.

If everything works fine, you will see the following report on a monitor.

Now you can view the summary, the monthly report or the listing of all tasks. You are welcome to use the calculator!


Categories: Uncategorized Tags: , ,

Multimedia Conversion Server

February 14th, 2009 5 comments

This time I would like to introduce you to a new project designed by my friend Łukasz Krajewski. Its main task is the convertion of the multimedia formats, however, it can actually do much more than that

When designing a new website we often wish to provide its potential users with the possibility to upload their own videos. The video uploading (as well as image uploading) requires performance of certain tasks by the server; these tasks mainly involve the conversion of a video into the appropriate internet format, such as FLV or H264. Unfortunately, the conversion process is often complicated. First of all, it is quite time-consuming – its total approximate time depends of the size of the video, and it can take a couple of seconds or last even several hours. Secondly, the server requires the installation of a special software which is capable of decoding as many video formats as possible, and transforming them into internet formats. The installation of this kind of software is quite complicated and it often requires a dedicated server or, at least, VPS. This is the main reason why it is difficult to design applications which enable users to upload multimedia. The Multimedia Conversion project is definitely going to make it easier.

The Multimedia Conversion (MC) project is free and available for the users of GPL license. It uses the techniques of PHP, Zend Framework and FFmpeg. Multimedia Conversion is a net web service. In brief, it works as follows: the application which is supposed to convert videos needs to call a server method. Next the MC server sends the application all the information about the status of conversion. Here I suggest you to go project Wiki for details..

What is available right now is the video conversion for FLV, H264 and 3GP, and conversion of music to the MP3 format. Moreover, during the conversion to the video format a so called “miniature” is being created – that is, a frame (a single image) from the given moment in the film. It’s a piece of cake to add new formats.

The aim of a project is to isolate a complicated process of a video conversion and place it on a separate server. Such server would be then much easier to administrate. It might be a particularly useful solution for companies, where a great amount of applications are being created, and many of them need an automatic conversion of video materials. Due to the MC server its implementation will be less expensive. The multimedia applications will no longer require the installation of a quite complex software for a video conversion. The complex process of a video conversion will be carried out on a separate server – MC. The multimedia applications served by MC can then be launched on the usual, inexpensive hosting.

If you are interested in testing the project, feel welcome to contact me and you will be provided with the access to MC server for testing purposes.

I happen to know a little about the next steps to be taken in the further advancement of MC application. The prognosis is the following: the MC application is not only supposed to be a tool for the conversion of a video format, but it will also serve as an application for film-editing. Thus we will be able to create a brand new movie using the shots cut out of existing movies. I am keeping my fingers crossed! Good luck Łukasz!!!




Categories: MCS Tags: , , , , , ,

How to start Xuggle at Red5

February 2nd, 2009 12 comments
A big breakthrough today – I finally managed to start a Xuggle demo on the server Red5. I am really proud of this, because this kind of technologies will have a tremendous impact on further advancement in the Internet world. I have already given the details of the functioning of the tandem Xuggle and Red5. Now it is time to present how I have activated Xuggle and Red5 on my computer with Windows Vista64bit. I began with downloading and installing the latest version of the server Red5 – 0.8RC2. Of course I also installed the Xuggle. All the Widnows versions are really easy to install – by using the command: Setup.exe and restarting a computer. What I did next was to create an web application archive, consisting of the following files:

All the useful files can be found here:
I then saved my application in the folder webapps in the server Red5. Using the 32bit version of Java I started the server Red5. I also set the environment variables:  
$ export | grep HOME
declare -x JAVA_HOME="C:\Program Files\Java\jdk1.6.0_10"
declare -x RED5_HOME="C:\Program Files (x86)\Red5"
declare -x XUGGLE_HOME="C:\Program Files (x86)\Xuggle"
    I started red5: red5.bat. For testing I used the demo application from the server Red5 – Publisher. http://localhost:5080/demos/publisher.html. It is important to remember to connect to the videotranscoder application rather than oflaDemo. All other settings do not require any changes. I just turn on the camera and the microphone and begin a video session. The name of the stream is antek. In order to see the results of Xuggle operations I start the option “View”. The name is xuggle_antek. After severals hours of trials and errors and using Art Clarke I got it! I’ve finally seen my “second nature” – my second faceJ Thanks a lot, Art! In the next chapter I’m going to explain how to programme Xuggle using Eclipse and Maven 2. However, first I have to learn how to do it and, most importantly, EAT SOMETHING!
Categories: Java Tags: , ,

Xuggle + Red5 = Hello World

February 2nd, 2009 5 comments

I finally got it ! I managed to activate an example of the class Hello Word in tandem with Xuggle and Red5.

Now, how does it work? In the internet browser I start the application which publishes the image from the digital camera of my laptop. This image is then being converted (processed?) on the server by means of Xuggle. In this way the net surfers are able to see in their browsers the target image that has been processed by a server. Welcome to the new era in the multimedia web applications!

It seems to me that this application opens a window of new, amazing opportunities. For example, we can image a video conference which allows the participants to see each other’s if they were actually sitting together at one table:). Another possibility might be the server recognizing the users face and, as a result, greeting him with his name, nickname or some other familiar phrase. Or, for example, let’s say we visit the tourist agency website. We start our laptop’s web cam and, after a while, we could see the blissful image of ourselves resting in a hammock hanging between trees on the beautiful beach far away.

There is no doubt that the image of lying in a hammock is far more tempting than sitting at the computer desk. But let’s go back to details. What is actually going on in the server area? The server – Red5 – receives the video from the user. This video is in the form of a data stream. It might contain an image, music or other data. The video stream is, of course, compressed. The server’s is now required to decompress it so that we receive the successive shots (and this is the task performed by Xuggle and FFmpeg). In fact it reminds of the old-fashioned film tape, which has still been in use for movie-making in Hollywood.

As a result of a video’s decompression we receive a sequence of pictures. What the server does next depends entirely of the imagination and goals of the web-site designers. Then the server compresses the sequence of pictures, thus creating a brand new video – a new data stream. The server can save the results of its operation, or create and access enabling an online transfer.

Obviously this method can be also used for the processing of sound. For instance, we can introduce some changes in popular communicators, such as Skype by adding the users’ favourite music to the background, or creating other sounds typical for cafe, pub or other popular meeting places.

As you can see, the server, which is supposed to perform so many tasks, may be overloaded: it is responsible for decompression and compression of the audio / video stream, as well as processing images or sounds. During the system testing , the overload of my laptop went up to 10%. However, we should keep in mind that the server is performing a new operation, something that has never been done before . Something that might actually become a key to success. Personally I am convinced that the expected results are worth its costs, and it pays off to risk an occasional overload.

In my next article I am going to explain how to start and application Xuggle Hello World on the server Red5.

Categories: Java Tags: , ,