Streaming media -> youtube style

Wouldn’t it be nice to create your own youtube movies and host them on your own private server? Why you ask, well maybe it’s content you don’t want others to view. Prolly this can be done using youtube, but hey I have my own servers and I want it where I have full access! (as do many companies actually).

So how do you do this using opensource tools? Actually very, very simple

I started from this blog entry. But as I’m using ubuntu dapper, I have the nice debian apt tool ๐Ÿ™‚

So in short here is what you do:


apt-get install mencoder
apt-get install ruby
apt-get install flvtool2

And I had my tools install (maybe you need some extra depencies here) don’t know actually.
Then the commands like in the previous posts


mencoder \
orig_file.ext \
-ofps 25 \
-o dest_file.flv \
-of lavf \
-oac mp3lame \
-lameopts abr:br=64 \
-srate 22050 \
-ovc lavc \
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \
-lavcopts vcodec=flv:keyint=50:vbitrate=300:mbd=2:mv0:trell:\
v4mv:cbp:last_pred=3 -vop scale=320:240

and


flvtool2 -UP dest_file.flv

And you have your indexed flash movie. And may I note the importance of the indexed in the sentence once more. In the past I tried this with a long avi and believe me its no fun if you can’t forward or rewind!!

So then you put the flv file on your server. Now all you need is a flash movie player for playing your content. And I like the flowplayer. You download it, setup a small page like this


<object type="application/x-shockwave-flash" data="FlowPlayer.swf"
width="320" height="263" id="FlowPlayer">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="FlowPlayer.swf" />
<param name="quality" value="high" />
<param name="scale" value="noScale" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="videoFile=dest_file.flv"/>
</object>

Et voila, you have your own streaming video. Now put it into a web application and you have your own streaming media center!!

OSS == SWEET

Dojo patch rejected :(

I’m using the dojo dropdowndatepicker in a lot of my projects. Problem with this widget is that it only really supports the yyyy-mm-dd notation (as the standard is). But all the applications I develop the people want our local notation (dd-mm-yyyy). So I wrote a small fix that helps. Too bad it got rejected as it doesn’t fit in the idea of the project and the new widget set they are building.

For now it’ll be a patch I have to apply on all my dojo downloads to get the functionality I need from it. And let’s hope in the future we will migrate our code to the iso standards, right?

DWR

In one of my projects the user has to select a customer from a dropdown list. Problem is that the number of customers they have is much to big to prefill. So I used dwr to build a solution. The user has a dropdown from which he can choose the field he wants to query (let’s say street), he than fills in a streetname, presses the button and the list gets prefilled with the list of customers who match.

How does it work. Wel really simple ๐Ÿ™‚

In my backend I have a simple POJO Search with a method getCustomers(String searchField,String searchValue). This calls a service layer, who in turn calls a dao layer,… you know the drill. In the end the method will return a List of Customer objects. I exposed these objects in the dwr.xml configuration file. (that’s it for the java backend stuff) (nice isn’t it ๐Ÿ™‚ )

Now the javascript part is also small and handy. I had to include the dwr engine and my exposed object as javascript objects. When the user presses the button this small piece of code gets executed


Search.getCustomers(searchField,searchValue,CustomerCallBackHandler);

When the javascript gets a response back, the CustomerCallBackHandler will be executed. That looks like this


function CustomerCallBackHandler(data){

Where data is an array of Customer JSON objects. This means that in my java Customer object I have the getter/setter getId(),getName(). In javascript I can simply do data[0].id and data[0].name.

Now isn’t that nifty?! ๐Ÿ˜›

/me like

Opensource security monitor

In my always continuing search for nice opensource tools I sometimes stumble upon some real jems. And I found one (again) ๐Ÿ™‚

I have a webcam and I wanted to keep track of what was happening in my appartment when I’m not there. First I tried motion. You start it from the command line, it starts a small web server and there you can configure it. I set it up that on every image that was taken I got notified. After one day I had +2000 mails in my mailbox. ๐Ÿ™ Hmmm, I need to tweak it a bit. But then I came a cross zoneminder, it really is a nice application. I grabbed the ubuntu debs and installed them with the dependencies and had it up and running in notime!! Only thing I had to do was grant the www-data user access to video hardware. (took me quit some time to figure that one out!!)

Now if something happens I get alerted and a nice movie gets recorded. For anybody who wants some security stuff, really check this out. For a home user this is more than enough imho!!

Setting up a nas

A couple a weeks ago I bought some spare harddisk (2 500 Gig ATA). I had a spare computer lying around and wanted to build myself an small nas. I already knew 2 distros who’s idea it is to become an easy to use nas solution. Openfiler (Linux based) and FreeNas (BSD based), so I gave them a go. One of them crashed during gui installation when choosing the timezone. So I had to finish it in text mode. But that’s not a big problem only a shame you have to restart the installation.

But after installing it seems that OpenFiler doesn’t support a local user db. You have to setup an LDAP or AD, but for me on my own a LDAP or AD is a small overhead imho. So openfiler was a no go. Then FreeNas, this supported a local user db but after setting up and publishing an SMB share it seems that the security is isn’t that great. I can’t make a share private for my user. So if I wanted someone to copy something to my nas he would have access to my whole share. So FreeNas was no go as well.

Finally I installed the ubuntu server, apt-getted smb,ssh,… I created a software raid using the raid tools and made some shares on this raid folder. Now I have my own small NAS of 500 gig on the network.

So people who want a nas and are looking for a solution. Maybe just go with a normal distro and set it up like me. It only took 30 minutes max extra than using the formerly mentioned distros.

Most important setting when using Dojo

In our current application we use dojo. Only for a small amount of the application at this moment, but for the new version we are planning to include a lot more functionality using the dojo toolkit. I was testing this on an older machine (p3 1Gig) and the application took really long to display the page. So I asked around on irc #dojo and they pointed me to this really nice setting:

<script type="text/javascript">
	djConfig = {
		parseWidgets: false
	};
</script>

Dojo waits until page has loaded and then starts scanning for the dojoType attributes, you can imagine if you have a lot of data this will take a while. With this simple setting you tell dojo don’t do this.
Then for every dojo widget you want to use, just add

<script> dojo.hostenv.searchIds.push(id)</script>

Dojo keeps all the ids and only tries to create a widget out of the ones you push out. So no page analysis afterwards.

Sweet 2

Radeon Xinerama

Yesterday I put a new graphics card into my desktop machine (a CGA-P1652 RADEON X1650PRO 512MB) . I hooked my 2 big screens on it and rebooted. My ubuntu dapper couldn’t start gdm (ffcourse). So I apt-getted the ATI drivers and did a dpkg-reconfigure xserver-org, still couldn’t boot. So I started searching, after a while I found the aticonfig tool, one word sweet. I ran it witht he option for dual screen setup and he made a template xorg.conf file.

After adding the Xinerama option and setting the resolutions, I now have a nice widescreen view of my desktop and I can drag my windows over both of them. Life is great! I really believe that multiple screens do increase performance. I also liked the fact that my dapper box now has the ability to modify my screen resolutions using the gnome tool. The last time I did the dual screen setup with ubuntu, the app crashed, guess it wasn’t ready for dual screens. Now it works like a charm!

So people out there with radeon setup problems, one tool : aticonfig

Another thing I never thought off

A while ago a made a post on web standards saving money (ie for google). Today I was listening to another podcast, they had an interview with Chris Dibona He works over at google. He was talking about how google has its own team of kernel hackers. He explained how some small improvements in the linux kernel of this team could save google millions of dollars.
My first reaction was offcourse, your site will run faster you need a couple of computers less and that’s where your savings come from. Well he explained it somewhat different. Let’s say you have 100.000 computers (prolly google has much much more), your computers will stay a little bit cooler maybe even consume less power. So your airco could run a little bit slower. So a code optimization could result in a cut back in power usage. You would maybe even save some trees!

It shows how in each and every sector of the it you have to worry about different things. I have to admit, when I’m doing java development and I’m not sure if I should choose an int or a long, I’ll be choosing a long because memory is no problem for us and it’s only running on 2 or 3 severs. These guys will check,recheck and then check again if they instead of the int maybe even could use a smaller datatype.

Xsd nillable

In one of my current projects we are sending data to another company. Because xml is somewhat the standard for exchanging data these days I wrote a small java app using velocity to generate the xml files. Sure I could have used Oracle’s features to create an xml file but if you use that feature you could just as well give them an ASCII file imho.

So I started by creating the xml schema (xsd). Because some fields can be empty I some nullable fields. And that’s where the issues started. We have some dateTime fields that can be null so I thought spitting out a <date /> tag or <date></date> would do the trick!!! Biep error, after some googling and reading a lot I came to the conclussion that I had to output this : <date xsi:nil=”true”/> . Stupid if you ask me, but hey it now works.

I wrote a small velocity macro that I called:

#macro( xmlempty $value $tag $cdata)
#if ($!value == "" || !$value)
< $tag xsi:nil="true"/>
#elseif ($cdata == "true")
< $tag>< ![CDATA[$!value]]>
#else
< $tag>$!value
#end
#end

Works nice I have to say. The program was straight forward, a file that contains key value pairs. The key was the velocity template, the value was the query. I ran the query, retrieved the ResultSet cursor and while iterating it for every iteration I called upon the template that merged with my UTF-8 filewriter.

What kinde surprised me was the lack of good xsd/xml editors in the opensource. I tried the ones that were bundled with our myeclipse environment but they were more a pain than a gain. (omg lame!) So in the end I installed xmlspy and asked for a testing license. I have to say they have a really good product, but who wants to pay 600 รขโ€šยฌ for an xml editor. People come on, even ms visual studio .net 2005 pro only costs 750. They also have xml support built in, for that I’m willing to pay because of the added value but not for an xml editor. There are only a couple of things I need from an xml editor.

  • xsd code completion
  • Is my xsd valid
  • Why not, with linenumber error
  • Xml code completion using the provided xsd
  • Is my xml valid
  • Why not, with linenumber error
  • Maybe an xpath,xquery and xsl features

That should be sufficient. Hmm looks like a project for the future ๐Ÿ™‚

Python Commandline

Mostly when I code, I use java,c# or sometimes php. But now and then I use python. Today I wanted to download some podcasts that I hadn’t listen to in a while. (Read the other posts to know why) So I wanted to do a bulk download, the mp3z were named like xxx010.mp and I wanted to download up to 30 or so.
I gave the pyhton commandline an go (been a while). How could I forget such a nice feature.

i=10
for x range(20):
	print "xxx0"+str(i+x)+".mp3"

copy paste it into a textfile and wget -i thefile.txt

Sweet