Search code examples
actionscript-3flashvideovideo-captureh.264

Is it possible for Adobe flash to capture a video stream and store or cache locally?


The following link describes how to build a flash project that captures a video stream from a webcam, encodes to h264 and stream it to a media server over a network connection:

http://www.adobe.com/devnet/adobe-media-server/articles/encoding-live-video-h264.html

My limited experience is that this approach is limited by available bandwidth, namely if the project is configured to record a video at a bitrate exceeding the available bandwidth, then frames are dropped and the final video is lacking.

I'm wondering if there are facilities in flash to either record to local storage or to an in-memory cache, and then upload it to the media server when the recording is complete? This let's a web app spend additional time uploading as the upload is decoupled from the recording, and there's no contention between video bitrate and bandwidth.


Solution

  • Unless you are running an AIR app, no such functionality exists in Flash. With regards to local storage, all you have for a web-based application is the SharedObject, which is generally limited to ~100kb, if I remember correctly. You'd be lucky to record a single frame of video in that space.

    You can try to save directly to memory (i.e. just leave it as a ByteArray), but depending on OS, browser, and plugin being used, your app is likely to be forced to shut down for overusing memory. Even if it didn't, this would be a poor choice since there could be a system with 512MB of RAM in it and you are trying to save a 300MB file in it. You would slow down that system (and even better systems) without even blinking an eye.

    If you are using AIR, you can save the video to memory and then every few seconds, save that to disk using File and FileStream. The only limit there is the size of the drive it is being saved on. You could then upload at the end of the recording, or when the user is satisfied.