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!!