My first red5 flex video recorder
So this is a bit cooler than adding two numbers together....
Here's my very first bare-bones Flex / red5 video recorder, and a few lessons I learned in creating it.
1) Red5 handles NetSteam's .publish() methods automagically. In other words, your java application does not have to do anything except extend ApplicationAdapter to let you use it from Flex to record video. In fact, if you don't want to tinker with java/red5 at all, you can just use a demo application like oflaDemo as your NetConnection hookup. So if you have red5 running out of the box and do:
private function connect():void
{
nc = new NetConnection();
nc.connect("rtmp://localhost/oflaDemo");
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
}
private function netStatusHandler(e:NetStatusEvent):void {
var code:String = e.info.code;
Alert.show("code = " + code);
if(code == "NetConnection.Connect.Success"){
ns = new NetStream(nc); //plus other stuff if you need.
}
else {
trace(code);
}
} Bingo, you have a NetStream ready for the attachCamera() method. Once you attach your camera, all you need to do is call
ns.publish("my title", 'record');, and red5 will automatically create the FLV for you and store it as "[my title].flv" in the streams/ directory of the red5 webapp you're connecting to. Surprisingly, it will even CREATE the streams directory if it doesn't exist. Fantastic, no???? Here's some sample code to publish the stream:
private function publishCam():void
{
try
{
//Alert.show('publishing');
ns.attachCamera(camera);
mic.rate = 44;
ns.attachAudio(mic);
ns.publish("red5test", 'record');
}
catch(err:Error)
{
Alert.show( err.toString() );
}
}So notice I am using the very same "myapp" application that I created in my last blog post. It provides NO SPECIAL hooks of anykind to let us record video. Everything not done in actionscript is handled by red5 automatically.
Whoa...Amazing, huh? What they say is true- red5 really makes it SIMPLE to make your own video recorders...
2) There is a bug with 64-bit flash on Ubuntu where it borks the camera if I try to access the Camera class from two flex apps simultaneously. I have to restart firefox for video to return to normal. I'm getting really sick of Adobe's lack of support for 64-bit linux (No FP 10 debug player?!?) ...I thought they were trying to court Linux developers...
3) If you're using the microphone to record with red5, make sure to set the rate to 44 so you don't have FLV codec problems. And use Microphone.getMicrophone() instead of Microphone.get() in AS3.
Holy wow, this is some powerful stuff red5 provides us Flex developers with. VERY powerful stuff...
| Attachment | Size |
|---|---|
| myapp.tar_.gz | 147.23 KB |
| red5test.tar_.gz | 301.6 KB |
As consoles are becoming more
As consoles are becoming more like computers, online gameplay is expanding. Once online games started crowding the market, open source networks, such as the Dreamcast, PlayStation 2, Nintendo GameCube and Xbox took advantage of online functionality with its PC game counterpart. Games such as Phantasy Star Online have private servers that function on multiple consoles. Dreamcast, PC, Macintosh and GameCube players are able to share one server. Earlier games, like 4x4 Evolution, Quake III and Need for Speed: Underground also have a similar function with consoles able to interact with PC users using the same server. Usually, a company like Electronic Arts or Sega runs the servers until it becomes inactive, in which private servers with their own DNS number can function. This form of open source networking has a small advantage over the new generation of Sony and Microsoft consoles which customize their servers to the consumer.
giochi gratis, Computer portatile, Che vogliono 500 miliardi, Dragon N, Karaoke Cafe, Calcio,
I forgot to mention I get
I forgot to mention I get error : code = NetConnection.Connect.Failed on localhost
How can I use this file? Do I
How can I use this file? Do I have to re-compile it again at Eclipse?
I am new at Red5 way of thinking...
Same here
It would be most decent of You to explain the subject in mode details for such noobs as some of us coming up for advice here.
Answering myself
http://www.flashextensions.com/freevideo.php?id_art=209
that's look like a fix to me.
Streaming
Hi! Thanks for topic. I am new to Red5. I am trying to create flash radio (ShoutCast stream). Can I do this with Red5?