2

This may or may not even be possible, but here's the situation: I want to use the ActionScript 3 Camera class to capture a video from a local camera (webcam, built-in camera, etc) and then play that video back within the flash application.

I'm considering the possibility of sending it to a Flash Media Server and then streaming it back as an on-demand video, but I would ideally like to keep the whole thing client-side for best performance.

I'm open to the idea of using a different platform (Java was one consideration) as long as it can be embedded in a web page, but I would like to keep development as straightforward as possible and make the process of accessing the application as easy as possible for the end user, which is why I chose Flash initially.

If anyone knows of a way to do this I welcome any input.

Tristan Shelton
  • 327
  • 1
  • 3
  • 15
  • I haven't used it myself, but think FMS's http streaming api allows you to get data on client as ByteArray...and then Video class in flash allows to push that data stream...I guess that should help – catholicon Feb 25 '12 at 20:54

2 Answers2

3

Okay, here's an update for anyone else who might be up against the same hurdle I was. I was able to accomplish what I wanted — to record a video, allow the user to preview it, then upload it from one flash application — by utilizing a utility written by Lee Felarca (zeropointnine — http://www.zeropointnine.com/ ) called flvEncoder.

The concept is as such:

  1. Record audio and video data to raw format (much like Valentin Simonov suggested)
  2. Pass the data to flvEncoder for encoding in Flash FLV format and get a ByteArray back. I know it seems redundant to say Flash FLV, but I word it that way because Flash and Adobe Media Player appear to be the only things capable of interpreting the result.
  3. Create a NetStream instance and put it in Data Generation Mode, use the appendBytes() method to pass the encoded data to a Video object linked to an input NetStream.
  4. Use FileReference.upload() to send the data to the server in an HTTP request.

It could potentially eat a lot of memory, but I only needed to record short videos anyway. I won't post the code here because it's messy and tied to a proprietary project, but I hope this information is helpful to someone. Thanks for the responses!

Tristan Shelton
  • 327
  • 1
  • 3
  • 15
0

The easiest way would be to use FMS, Wowza or Red5 media servers. You just use NetStream to send data to your server, save movies there and stream back.

Also I suppose it is the only reliable way of doing it. Camera, Video or NetStream objects don't have access to actual video bytes. What you could do is to add an instance of Video to your Camera and draw it into a bitmap every 1/24th a second. After that you will still have to encode data or you'll run out ouf memory very fast. Here I'm not sure if there are any flv/h264 codecs made with as3 available. But anyway I bet it will be slow.

Valentin Simonov
  • 1,768
  • 10
  • 14
  • I wanted to be able to let the user preview the video BEFORE uploading it to a FMS, but I will just have to work with uploading the video and streaming it back. Thank you! – Tristan Shelton Feb 27 '12 at 05:08