Thursday, November 29, 2012

AMS Adobe Media Server: Getting Great RTMFP Quality

If you're new to working with Adobe Media Server (previously Flash Media Server) you may find that your video quality is not looking so great. But why?

There are several key factors involved when trying to reach the maximum video stream quality between users. By analyzing how these are implemented in your system, you will be able to tweak settings until you reach the best stream quality possible.

Before this protocol, Flash was only able to stream video using RTMP. This protocol is TCP based which means overhead for packet delivery. RTMFP uses UDP which allows for dropped packets without adverse effects. Another major improvement is that video streams are able to be streamed directly between users (P2P) and aren't relayed by the media server. This can reduce your hardware requirements possibly saving money while improving the user experience.

2. Bandwidth:
This is one of the fastest ways to kill your video quality and a factor you will have little to no control over. User's transferring video streams between each other using RTMFP bypass the server which means you only need the computing power to store their unique fingerprints and lightweight socket connections (a story for another time). This also means that the quality the user transmits is completely up to the bandwidth available to that user. If they have a shoddy internet connection or overloaded / slow internet equipment, this will quickly hamper the experience for the other user. Keep in mind that the user is uploading video data (which is typically much less available bandwidth for users than download speeds).

3. Camera Settings:
When setting up the Camera singleton to transmit data to the media server, you have a couple different options.

  • Camera Size: (Default: 160x120)
    • Try to match the same dimensions as the player showing the stream. Having this set low with a large playing area will cause gross pixelation. Likewise, having the player be smaller than the dimensions of the video feed will cause sharpness in the picture to occur. (Note: Some cameras will only output up to a certain size, after this point, Flash scales the feed causing pixelation.) Set this using setMode method.
  • Camera FPS: (Default: 15)
    • The FPS will of course determine the ideal rate as which frames in the stream are sent to the other user(s). This is only recommended as the recipients will determine if this rate is achievable with the given bandwidth and quality. Set this using setMode method.
  • Camera Quality: (Default: 50)
    • This will determine the compression applied to the frames transmitted to the other clients. Setting this to zero will prioritize bandwidth property below adjusting the quality as needed to maintain bandwidth settings. Set this using the setQuality method.
  • Camera Bandwidth: (Default: 16384)
    • The bandwidth property allows you to limit the usage of bandwidth while trying to maintain the FPS and quality settings you have determined or that exist by default. Setting this to 0 will prioritize the quality of the frames while reducing FPS to maintain constant streaming. Set this using the setQuality method.

By tweaking these settings and using your existing user analytics (and your preferences), you should be able to calculate the best values for each of these settings.

While there is no way to 100% ensure perfect picture and high quality streaming between users, tweaking the settings above will help you get the most out of it and give your users the best possible experience.

No comments: