Archive for February, 2009

Recording High Quality Flash Video Over Slow Internet Connections Part 2

Monday, February 23rd, 2009

This is part 2 of our 3 part series on recording high quality Flash video over slow connections.

As explained in the first part, a big buffer should be used in the recorder flash app so that the video and audio data has where to wait before its turn comes to travel to the media server.

When the user stops the recording (by pressing a STOP button for example) most probably there still is some audio & video data in the buffer, data that has not been sent yet to the media server.

Part 2: wait for the audio and video data to reach the media server before we display any SUCCESS message to the user

Otherwise you will most probably end up with videos with missing endings and frustrated users.

Heres how stopping a recording unfolds in our flash video recorder:

  1. STOP button is pressed (or recording time limit is reached)
  2. we stop capturing data from the cam and mic
  3. we display a SAVING VIDEO message until the buffer is empty (all the data in the buffer is sent to the server)
  4. when the buffer reaches 0 we finally display the recording saved properly success message.

In code (as2) Step 2 translates in ns.attachAudio(null) followed by ns.attachVideo(null).

Step 3 and 4 (detecting when all the data has reached the media server ) can be done in several ways but we listen for a NetStream.Buffer.Empty or NetStream.Record.Stop net status event fired while ns.bufferLength == 0 .

In as3 the procedure should be similar.

In part 1 we’ve talked about using a big buffer on the client side.

In part 3 we will talk about getting the media server to properly save the video and audio data to the HDD.

Recording High Quality Flash Video Over Slow Internet Connections Part 1

Monday, February 9th, 2009

This post is the first part out of a 3 part series on how to record high quality flash video over the Internet. We’ve learned a lot while doing video recorders for our clients and while developing the AVRecorder bundle and we would like to share some of that knowledge with the community!

At the end of this 3 part series you will be able to record DVD like videos over the Internet using a simple audio video recorder made in Flash or Flex Builder (as2 or as3).

So, Part 1: In the client swf application use a big buffer on the outgoing stream.

All flash video recording applications are made out of 2 parts: the client side application, (a swf file embedded in a HTML page) and the media server application which can be Flash Media Server, Red5 or Wowza.

By the client application I mean the swf that gets embedded in the website, the actual recording application developed in Flash or Flex Builder that people will see and use.

The buffer is where the audio and video data are stored before they are sent to the media server, and it needs to be as big as possible to ensure that all the data captured from the web cam and mic are sent to the media server instead of being dumped (which is what happens over slow connections if you’ve got a small buffer)!

On a high-speed connection, the buffer size is not  a concern because data is sent almost as quickly as Flash Player can capture it.

When recording video over slow connections the buffer behaves just like a funnel! If a user is trying to record a 500Kbits/s video over a 300Kbits/s connection with the media server, the data that can not be sent as soon as it is captured and some of it (about 200kb every second in this case) is stored in the buffer until its time comes to travel to the media server. The bigger the buffer, the more data can be stored in it! As soon as the buffer fills, all the data in it will be dumped by the Flash Player, so you want to be sure you have a big buffer.

I typically use buffers about 60 or more seconds for recording applications, you can go even higher if the recording application might be used for recording long movies!

To set a big buffer on the publishing/outgoing stream in the client swf you use:

This is it! The next part will cover waiting for all the audio and video data to be sent to the media server before you display any success/ok message to the user!

Update: Part 2 can be accessed here: http://www.avchat.net/blog/?p=33
Even later update: Part 3 is now available: http://www.avchat.net/blog/?p=27