Posts Tagged ‘video’

Recording High Quality Flash Video Over Slow Internet Connections Part 3

Thursday, April 2nd, 2009

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

Whenever someone is trying to use a flash video recorder to record audio/video at a higher data rate than the connection to the media server (Red5, FMS, Wowza, etc..) allows, Flash Player, in theory, will buffer the audio and video data until it can be properly sent to the video server.

But that is not a quite exact description about what really happens!

What really happens is this: whenever Flash Player detects a low quality connection to the video server, it starts buffering the video data and keeps sending the audio data to the media server. It does that because Flash Player thinks all streams are live (even those specifically destined for being recorded) so it tries to at least keep the audio “live”, if its not possible to keep both audio+video “live”.

What happens now is that the video frames will arrive at the media server:

  1. later than the corresponding audio frame
  2. arrive after the media server has already written the corresponding audio frames to the .flv file
  3. never arrive, because Flash Player has flushed the data in the client buffer that was holding the video data

This can cause several issues in the final .flv file:

  • missing or little video data across some sections
  • sudden increases in video frame rates (the video plays in a “fast forward” way because several video frames finally reach the server as a bundle)
  • flv files with static video, normal audio playback and the rest of the video data grouped at the end
  • flv files with large areas where you can not seek (because there is only audio data in those areas)
  • out of sync audio and video

To solve this issue, media servers are now waiting longer for the video data to come from the client (flash video recording software) before writing the existing audio data to the .flv file. Wowza Media Server and  Flash Media Interactive Server 3.5 both solve this issue out of the box.

Flash Media Interactive Server 3.0 also solves this issue by modifying Server.xml.

Red5 still has this issue and a bug has been submitted which you can follow here here.

This concludes our 3 parts (part 1, part 2) series on recording high quality audio and video files over slow connections.

Next I think we will talk about increasing the audio and video quality for the average user!

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