15

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?

a7drew
  • 7,801
  • 6
  • 38
  • 39

2 Answers2

15

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
  • 4,041
  • 1
  • 17
  • 19
  • 4
    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! – a7drew Dec 29 '09 at 16:47
  • 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 Dec 29 '09 at 17:16
0

i found this blog usefull.

http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/ This code is based on the answer given by richardolsson.

I tried this code once in my project and also successfull in uploading a 10 sec video to Facebook also. i have written a detail blog about my experience. http://www.logicmanialab.com/2012/10/upload-video-to-facebook-using.html

This code will break or hang up the browser if the video is too lengthy. Anyway it's worth a try.

Besides the best way to save video is to use Flash Media server or RED5 server(My experienece).I never tried ffmpeg as am not best in PHP:).

harilalkm
  • 456
  • 1
  • 4
  • 15