Twitter Updates for 2011-02-19

2011-02-19 10:00:00 PST

Tags:
  • I <3 Android Wireless tether #

Twitter Updates for 2011-02-17

2011-02-17 10:00:00 PST

Tags:
  • Congrats to IBM and Watson for dominating on Jeopardy. Nice work! #

Twitter Updates for 2011-02-06

2011-02-06 10:00:00 PST

Tags:
  • Avenue Q was hilarious and awesome! #

Job

2011-01-24 21:54:56 PST

Tags: , ,

I’ve finally finished school. It’s been a bit of a journey, about 6 and 1/2 years, but I did it. In a few months a Bachelors of Science, majoring in Computer Science will be given to me by UBC. I’ve had a good go. I took a lot of neat class on a lot of interesting subjects. I’m happy with my education and record. I had time to write some really cool code on my own, like the mindstab Go AI competition, learning Lisp, and Cortex (partly for school) to name a few. And in between all that I also have had the time to travel, to go to some really cool places: Mexico, Guatemala, China, South Korea, Hong Kong, and Colombia. Life has been lucky and good.

Now time for something new, a new phase. And so to kick that off, I’ve landed (luckily) a one month trial contract at a web company downtown, as a PHP (and other assorted opensource technologies) developer. This is an amazing opportunity and I hope it goes well. From the two days I’ve had with them so far I really like it and would be very happy there permanently. Either way, I’m now much busier than I’ve been in a while.

links for 2011-01-19

2011-01-19 00:01:14 PST

Tags: ,

Twitter Updates for 2011-01-18

2011-01-18 10:00:00 PST

Tags:
  • I <3 aspell #
  • You can now finally easily see the video from my 2nd place BCNet presentation on Cortex from 2010 at http://cortex.mindstab.net #

Cortex promo site up

2011-01-18 01:15:27 PST

Tags:

Cortex now has a promotional website with basic info and the presentation material from the BCNet 2010 Broadband innovation Challenge where it won 2nd place. See it at cortex.mindstab.net.

Liberating Flash Video From an RTMP Server

2011-01-17 22:38:23 PST

Tags: , , , ,

Let’s say you did a presentation that was recorded and you’d like to post it to your website. Sadly, let’s now say there are some problems, like that your 5 minute presentation is part of a nearly 2 hour video only available in a flash player that doesn’t even have a time display so you couldn’t even point people to the video and say jump to 1 hour and 15 minutes to see me. It sucks. Technically your presentation is available online, but it’s not really accessible. So here is how you might rescue it!

It turns out there are two ways flash players server videos these days. The first and easiest is that a simple flash player loads in your browser, and uses your browser to make a GET request to the server to load a .flv file (FLash Video). This is relatively easy to intercept, there are lots of tools and plugins for Firefox that do this automatically for you. Even better, on Linux for example, these videos are usually stored in /tmp so your browser does the whole job and gives them to you. No work required.

The other more complicated but more secure option is that the flash player connects to a dedicated rtmp server that streams flash video. The flash plugin does the networking and there is no file to save, it’s a stream.

If you are lucky enough to have a player using the first option, you are done. Assuming you have the second option, then your fun has just begun.

First we need to try and figure out where the server that your flash video is.

My first approach was to use wireshark to sniff the traffic. Through this I discovered the basics, like the address the server and the port, 1935.

Next I installed rtmpdump. RTMP is the Real Time Messaging Protocol and rtmpdump is a program that can connect to an RTMP server, get a stream and save it to a file. Sadly the data I got from wireshark didn’t have all the parameters I needed to get the file. Or I couldn’t read it properly. So while I knew where the server was and could now connect to it, I still didn’t know how to ask for the video I wanted.

Thankfully rtmpdump comes with several other utilities. After reading its README I went the rtmpsuck route. I set local redirecting of all port 1935 requests to localhost with iptables and ran the rtmpsuck proxy server. In theory it was supposed to intercept all calls from the flash player to the rtmp server, decode and spit them out, and then forward them along. Even better, it would try to save the stream on the way back as it passed through it.

# iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner --uid-owner OWNER_UID  -j REDIRECT
$ ./rtmpsuck

Where OWNER_UID is the uid of the user running rtmpsuck. With this running I just reloaded the page with the player (twice, it’s a bit glitchy) and then tried to skip to where my part was so it would save the stream from there.

It was partially successful. It spit out on the console all the pertinent path parameters about the video on the server, but it kept chocking on bad packets of data and stopped recording. Also for some reason the video it did store was very large, space-consuming wise.

Armed with the right parameters though I was able to use rtmpdump to suck down the whole video from the server surprisingly quickly and in a reasonably sized format.

$ ./rtmpdump  -r rtmp://server.net/app_name/blah/event/date/date-1 -o video.flv

Now the video was liberated from its flash interface and in my possession, I just had to cut out my small part and then convert it to a more common format.

$ mencoder -ss 1:15:50  -endpos 0:05:57  -ovc copy -oac copy video.flv -o result.flv
$ ffmpeg -i result.flv result.avi

And volia. I now have just my part of the video and in a common format. I mean you hypothetically do! Yes…

Completely unrelatedly, you can expect to see my presentation on my project Cortex from the BCNet Broadband Innovation Challenge (where I got second place) online soon.

Twitter Updates for 2011-01-12

2011-01-12 10:00:00 PST

Tags:

JavaScript: wrapping functions with closures

2011-01-11 14:58:41 PST

Tags: , ,

So in the course of cleaning Cortex up I’m trying to add some structure and modularity so it can be taken apart and extended more easily in the future. I came across this fun trick with closures for wrapping methods. I <3 JavaScript

function a(x, y) {
	z = x + y;
	document.writeln("fn a: " + x + " + " + y + " = " + z +"<br />");
}
 
document.writeln("a(1, 2)<br />");
a(1, 2);
 
function makeB() {
	fna = a;
	return function (x, y) {
		document.writeln("fn b: inc-ing x:" + x +"  & y:"+y+"<br />");
		x = x + 1;
		y = y + 1;
		fna(x, y);
	};
}
 
b = makeB();
 
document.writeln("b(1, 2)<br />");
b(1, 2)
 
document.writeln("a = b<br />");
a = b;
document.writeln("a(1, 2)<br />");
a(1, 2);

The output is

a(1, 2)
fn a: 1 + 2 = 3
b(1, 2)
fn b: inc-ing x:1 & y:2
fn a: 2 + 3 = 5
a = b
a(1, 2)
fn b: inc-ing x:1 & y:2
fn a: 2 + 3 = 5

As you can see you can use closures in this fashion to override a function and still maintain it’s original functionality. We now have a new “function a” that replaced the old one, but still calls it internally to preform its functionality. I’m trying to find a more streamlined way to do this now, the closest I’ve gotten is

function wrapFN(fn, maker) {
	return maker(fn);
}
 
a = wrapFN(a, function (fn) {
		return function(x, y){ 
			...
			fn(x, y);
                        ...
		}});

Neat huh?

Valid XHTML 1.0!
Valid CSS!
Mindstab.net is proudly powered by WordPress
Entries (RSS) and Comments (RSS).
17 queries. 0.578 seconds.