The question: How can I record a stream from Flash Media Encoder on Flash Media Server 2?
The answer:
I actually get a lot of questions concerning FME but since I don't use it much myself (it crashes on my main computer and won't start) I usually don't have much of an answer. This also tells me two things about this piece of software that Adobe has pushed out, that is that it's getting attention because it encodes video with on2's vp6 codec and people like that because the quality is better. The second is that if I'm getting so many questions, there must be a lack of docs out there. Oh well, gives me something to write I guess.
Anyways, the deal here is that a lot of people want to record on FMS2 instead of just saving the FLV locally and then uploading some huge honking file to their server.
The way to do that is actually relatively simple. Surprisingly enough.
In this case we need to have the server side of the application watch for when a certain stream is published. The only drawback with this is that we have to actually hard code in the stream name on the server side. I suppose that isn't so bad though.
First up is writing the server side code. We have to get the stream that we want to record to. This can be anything really, for the time being I'll just call it "recordvid". Notice it's all in lower case, this is a best practice in the case that you ever have to move to a unix server from windows because unix servers are case sensitive and it's easy to not play the file based on incorrect case.
So we start the application as so:
application.onAppStart = function(){
//get the stream to record to here
this.recordStream = Stream.get("recordvid");
//keep an eye on the status of the stream, we'll need this to see what's happening with the stream
this.recordStream.onStatus = function(info){
for(var i in info){
trace("i: " + i + " info[i] " + info[i]);
}
}
this.recordStream.play("vid", -1, -1);
this.recordingStream = false;
}
That's it for now. Now just publish a stream from FME that is called "vid". It should show you the following in the FMS2 admin panel:
i: level info[i] status
i: code info[i] NetStream.Play.PublishNotify
i: description info[i] vid is now published.
i: details info[i]
As you can see, you can capture the event of when the video file is being published. From this point, you just call the record function:
application.recordStream.record();
When you stop publishing to the server, you'll get this trace of the information object:
: level info[i] status
i: code info[i] NetStream.Play.UnpublishNotify
i: description info[i] vid is now unpublished.
i: details info[i]
So you can see when you should stop recording. Which is done like this:
application.recordStream.record(false);
That's about it.
After taking a break of just generally slacking off surfing the net I ended up on fullasagoog going over some stuff that may be new to me. I came across a couple of posts on "friday joke" and thought that I've got a great one to add.
If you're Canadian you'll appreciate this more than others I think :D
Sitting together on a train, traveling through the Canadian Rockies were an American guy, a Canadian guy, a little old Greek lady, and a young blonde girl with large breasts. The train goes into a dark tunnel and a few seconds later there is the sound of a loud slap.
When the train emerges from the tunnel, the American has a bright red hand print on his cheek. No one speaks.
The old Greek lady thinks: The American guy must have groped the blonde in the dark and she slapped his cheek.
The blonde girl thinks: That American guy must have tried to grope me in the dark, but missed and fondled the old lady and she slapped his cheek.
The American thinks: The Canadian guy must have groped the blonde in the dark. She tried to slap him but missed and got me instead.
The Canadian thinks: I can't wait for another tunnel, just so I can smack the American again.