views:

1637

answers:

2

I'd like to use Flash to capure video from the user's webcam and then save it on the same server that hosts the Flash file. The web server will be running ASP.Net technology. Seems easy, right?

Lot of searches yielded the same lines of code to start a webcam capture using Flash. I can't find anything that sends that captured video back to a server.

I can find lots of blog and forum posts that imply 3rd party software or Flash Communication Server is required to collect it on the server, but I don't understand why.

It seems like Flash ought to be able to capture some video and send it as an HTTP post to the same server that hosts the Flash file. That's pretty basic Flash/webcam functionality, right? It seems like we don't need to introduce 3rd party dependencies just yet.

Does anyone know where these extra lines of sample ActionScript code might be hiding?

+2  A: 

You do need a Flash Media Server (or an open-source alternative such as Red5) to be able to stream video from the client to the server, which is essentially what you want to do here. There is no way to do that using HTTP POST.

You can, however, draw your Video display object to a bitmap each frame, and upload those bitmaps on the fly using regular HTTP file uploads. Although as you can imagine, that's not exactly ideal from a performance point of view. You'll also bump into problems because the Flash Player security model does not allow you to upload files without the operation being user-initiated (i.e. a mouse click event is in the stack trace.) There are way to work around this though, e.g. sending the file as an AMF ByteArray through an AMF service, but it might not be future proof.

In the end though, for any type of professional-grade application, you'll definitely want to incorporate a Flash Media Server (or Red5.) There are companies from which you can hire such services, one example being Influxis. Going down that route, you won't have to host the server (which is Java) yourself.

richardolsson
Ok, so what I'm learning is that Flash cannot create a 10 second video clip from the web cam and then post that video file to a server. So the webcam data source is like a firehose and flash cannot bottle a snippet of it; Flash can only redirect the stream to your screen or to a special stream recipient like Flash Media Server of Red5. Thanks for the info!
AndrewDotHay
That's correct! Unless of course you use the workaround where you store all frames as bitmaps in memory (using the BitmapData class, and it's draw() method) and then upload those bitmaps sequentially to a server, where they can be encoded using ffmpeg for instance.
richardolsson
A: 

Indeed, using FMS will allow you to save the streamed video to a FLV file. To do this using Adobe FMS, you need to use the Interactive version, which is quite costly (US$4500). You can get a Developer version which is the same, but limited to 10 connections and can be used only for development purpose. There are also the open-source alternative, but I haven't used those. As for FMS, if you can get to install and setup it, writing very basic recording code is quite quick.

However, recording streams of webcam is quite a job and there are a lot of things to consider like video encoding, audio, user's bandwidth, buffering, etc.

Depending on how much work you want to put on this project, going toward a third-party solution might not be a bad idea. If you want to allow users to record a video and then get the FLV file for storing locally on your server, then I would recommend checking the Nimbb API.

Nimbb has a player that both record and playback a webcam video, which generate a private and unique GUID. The player exposes methods that can be used with JavaScript. A Web Service allows to download FLV files and JPG image thumbnail. This might be interesting for quick development.

Neb
Cool, thanks! I checked out Nimbb and it looks interesting but the video quality wasn't quite as good as I expected. If they turn that dial up a bit, this would rock!
AndrewDotHay
You're right with the free account. If you subscribe to the service, you will get better quality (check this page http://nimbb.com/Help/Subscriptions.aspx). The Platinum package has full quality and up to 3 minutes of recording time per video. Some third party sites use it already, like sendshots.com.
Neb