The Art of Encoding Flash Video: About the FLV Format


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

The Art of Encoding Flash Video: About the FLV Format

  1. 1. CICE, Escuela Profesional de Nuevas Tecnologías [] The Art of Encoding Flash Video: About the FLV Format By: Derrick Ypenburg The process of encoding quality streaming video for Flash (or for any video streaming playback delivery for that matter) is the most important process in creating video streaming applications. Any slick-looking video player that you build will only be as good as the quality of the video streaming through it. This article provides a comprehensive overview of FLV encoding by the encoding software. Understanding this article will help you create higher quality FLV files when it comes to applying settings in an encoder and creating video for encoding. About Flash Video Video for Flash basically comes in one flavor: the FLV format. Flash will only stream a video that has been encoded into this format. Videos using the FLV format, however, do come in a couple of different versions. These versions are defined by the CODEC (method of compression/decompression) that was used to encode a video to and FLV. The two different CODECs used to encode video to FLV are: Sorenson Spark (developed by Sorenson Media ( ) On2VP6 (developed by On2 Technologies ( ) The above CODECs are not necessarily just an "option" when deciding what CODEC you should use to encode a video, they are Flash Player version specific CODECs. The Sorenson Spark CODEC was around for Flash player 6 and 7. The On2VP6 CODEC is new to Flash Player 8 (although Flash player 8 will stream Sorenson Spark encoded videos). For more information on how to choose a CODEC for streaming delivery, you can find more details in Rob Reinhardt's article Choosing a Video Codec for Your Flash 8 Movie ( . For a long definition of what a CODEC is, you find it in the Wikipedia here ( . About Compression for Flash Video Both the Sorenson Spark and On2VP6 CODECs use interframe and intraframe encoding methods. These methods result in a lower bandwidth for high-quality video. These methods are also known as Spatial/Temporal compression. CICE, Escuela Profesional de Nuevas Tecnologías [] 1 of 6
  2. 2. CICE, Escuela Profesional de Nuevas Tecnologías [] Spatial Compression: Reducing data within one frame Image representing one frame can be compressed using lossless or lossy type compression A spatially compressed frame is referred to as an intraframe or a keyframe Temporal Compression: Frames that only store the difference between one or more frames Video data stored in the succeeding frame is the difference between frames Keyframes are frames that act as a frame for comparison The difference between frames are called interframes Flash encoders use both spatial and temporal compression. In a nutshell, an intraframe takes a high quality snapshot of what is currently in a frame. An interframe only encodes any differences that occur between the preceding intraframe and the current frame being encoded. This results in only encoding differences that are happening in the video from frame-to-frame and not compressing redundant images across a video. This frees up file space to focus on more complicated sequences, or, it just frees up file space and it is not used (making parts of the video faster to download and result in a less congested stream delivery). Keyframes When I discussed intraframes previously, I also referred to them as keyframes. Keyframes are a terminology you might be familiar with. Not the keyframes you use on the timeline in Flash though. The keyframes I'm talking about are a setting in any Flash video encoder. Keyframes (or intraframes) are baseline frames that subsequent frames (interframes) are compared against (only the differences between keyframes and interframes are encoded). The keyframe interval settings in any Flash encoder provides the option to specify how often you'd like keyframes to occur in the video. Keyframes intervals are defined by frames. For example, a keyframe interval of 60 for a 30fps video will insert a keyframe every 60 frames (or 2 seconds). Increasing the number of keyframes (smaller frame interval) will: increase quality of video produce a larger file size and can exceed desired data rate create possible performance issues on less powerful systems Decreasing the number of keyframes will: decrease the quality of video result in a smaller file size result in lower data rates So how do you choose a data rate? Higher motion, color, edits video should have a more frequent keyframe rate. CICE, Escuela Profesional de Nuevas Tecnologías [] 2 of 6
  3. 3. CICE, Escuela Profesional de Nuevas Tecnologías [] Slower video, talking head shots can have less keyframes (less frequent keyframe interval). Other Things to Know About Keyframes Keyframes affect seeking of a video. Flash video will only pause, and seek to, a keyframe. If the user pauses at, or seeks to a frame that is not a keyframe, Flash will jump to the next keyframe and pause there or start playing from it. If accurate pausing and seeking is important for your video, a more frequent keyframe interval will be required. Cue points encoded into a video are inserted as keyframes. These keyframes also have embedded data that was entered when the cue point was created in the encoding software. If you want to have a video that has chapters, and you want to have navigation that seeks the video to exact times for each chapter, insert an empty cue point at the precise times to ensure each chapter starts in the exact spot you want it start at when seeked to. A Review of Data Rates A data rate is a measure of bandwidth, i.e. how much can be delivered through a medium. Data rates are measured in: Kilobits per second (Kbps) ~ 1000 bits/sec Megabits per second (Mbps) ~ 1,000,000 bits/sec A bit is 8x smaller than a byte (don't mistake the two) How to Choose Target Data Rates When choosing the best data rates for your streaming applications, you ned to know your audience. You basically have broadband users, dial-up users and connection speeds in between such as ISDN. A good reference chart with the connection speeds (in order) as well as clocking your bandwidth and see where you fit in, check out this great app at InternetFrog ( .com. I find a lot of developers are dropping the dial-up market completely. I'm not kidding. I have to convince some clients to re-consider the dial-up market. Especially with the new On2VP6 CODEC, Flash video for dial-up connections looks better than ever. It's not only the dial-up market that gets data rates of 56Kbps and less. I've clocked my connection slower than that when I was hooked-up to a slow WiFi connection at O'Hare airport in Chicago. There is a growing wireless market out there that gets a full range of low-to-high data rates. In other words, consider all users and demographics. They are also purchasers of products and viewers of adverting $$$. When encoding Flash video for different data rates, you have to encode a separate file for each data rate. You can then give the user an option of which data rate they want to play, or, you can program some bandwidth detection (I will write an article on bandwidth detection later this fall). CICE, Escuela Profesional de Nuevas Tecnologías [] 3 of 6
  4. 4. CICE, Escuela Profesional de Nuevas Tecnologías [] Below is a list of common data rates for different connection speeds (The ones bolded are my preferred rates. I'll explain why after): Encoded at 1 Mbps - 1024 Kbps connections Encoded at 700 Kbps - 768 connections Encoded at 450 Kbps - 512 Kbps connections (any connection fast enough) Encoded at 350 Kbps - 384 Kbps connections (Satellite, slow high-speed connections) Encoded at 208 Kbps - 256 Kbps connections Encoded at 80 Kbps - 128 Kbps connections (ISDN) Encoded at 48 Kbps - 46 Kbps connections (Dial-up) So if all the data rates listed above are the most common ranges, why not encode a video and detect the data rate to cover all of them? Why not make one higher than 450 Kbps? I'm definitively a proponent of accommodating dial-up/mobile-connected users still so I encode down at 48 Kbps. The 80 Kbps range takes care of the not-quite high-speed crowd and the 350Kbps takes care of the users that have high-speed but not very fast high-speed. The 450 Kbps data rate takes care of everything else above 450 Kbps. In most cases, the common video I encode is 320 x 240 in display size. I can pretty much get any video at that size looking terrific at 450 Kbps. If the video is not going to be blown-up full screen, there is no reason to encode at a higher data rate. You are just delivery unnecessary bandwidth from your streaming server that is not needed as the video won't look much better at the cost of higher bandwidth. Note: Overall data rates listed above include both audio and video data rates combined. Video Properties That Affect Encoding We now have a better understanding of what goes into encoding an FLV, now let's look at other factors that affect the encoding process. There are many video properties that affect the quality of encoded video. I'll break a list down into two categories: Properties that affect encoding quality, and, properties that are affected by encoding. Properties that Affect Encoding Quality (during encoding) Color and movement - The more color and movement a video has, the more information that needs to be stored to represent all the changes and color ranges. Edits, Transitions, Pans and Zooms - All of these make changes in the video. Not only a change, but a gradual change over time. This kind of stuff drives the encoder nuts. Although we might not see everything that is changing, the computer sees everything. Frame rate - The more frames that are encoded, the more information that needs to be stored and less data rate to share over time. Display size - The larger the display size, the more pixels and colors that need to be encoded. Sound ranges - Encoding unnecessary sound ranges (deep vibrating bass's that are not heard and very high pitches) take up file size and are not really heard unless the volume is cranked. Some encoding software offers a range selector for omitting high and low audio frequencies. Interlacing - Video that was intended for television or that was filmed without a progressive scan camera is CICE, Escuela Profesional de Nuevas Tecnologías [] 4 of 6
  5. 5. CICE, Escuela Profesional de Nuevas Tecnologías [] interlaced video. Interlacing is the method of 2 fields of lines that are combined to create a single frame. Frames of interlaced video appear with a "combing" effect at times are when paused. This is one of the most important things you need to take care of when encoding video. Properties That are Affected By Encoding (during playback) Image quality Smoothness of playback Audio quality Transitions and effects Text and images in video Methods of Improving Quality of Video Aside from above-mentioned considerations, there are a lot of ways to improve encoded video quality. Below is a list of different methods of improving video quality that go above and beyond playing with data rates and keyframes. The Flash 8 Video Encoder that ships with Flash 8 Professional does not perform all of the items mentioned below. I will mention which ones the Flash 8 Video Encoder does not do. I will also discuss software that will do all of these things afterwards. 2-Pass vs. single pass encoding - Single pass encoding analyses a video and encodes it in the same pass. 2-pass encoding has a first pass just for analyzing a video and a second pass just for the encoding process. Single pass encoding is faster, but is less in quality as where 2-pass is higher quality but takes longer to encode. 2-pass encoding in other words, increases encoded video quality. (The Flash 8 Video Encoder is single pass only). Pre-processing filters - Other encoding software (sorry, not the Flash 8 Video Encoder) ships with pre-processing filters. Pre-processing filters allow you to make adjustments to a video that will increase encoding quality. One example is a filter called Black Restore. This filter corrects all blacks in a video that have become shades of gray when it was digitized. Multiple values of gray instead of black affect image quality as well as consume more file size. restoring all dark grays to blacks improves the quality of black images and requires less file size. De-interlacing - Video that is interlaced can give a "combing" effect when played back digitally. De-interlacing interlaced video will combine to two fields of lines together to make a solid image for each frame. This is one of the most important factors in getting good quality video for digital playback. This method is not included with the Flash 8 Video Encoder. Keyframes - As mentioned before, analyzing movement and edits and transitions in a video will help you determine lower or higher keyframe intervals for better quality video vs. data rate. You can adjust keyframe intervals in the Flash 8 Video Encoder. Smaller display size - Reducing the frame size of a video to 320 x 240 for higher bandwidths and smaller for lower bandwidths will result in a higher quality image. Frame sizes can be adjusted in the Flash 8 Video Encoder. Reducing Frame Rates - Reducing the frame rate of a 30 fps video to 15 fps will result in higher quality images. The downside however is that the video can appear to be choppy for high motion video. When you drop the frame rate of a video, it is best to reduce the frame rate using good math. Reduce frames rates by half or quarters. Arbitrary frame rate reduction can result in audio synchronization problems and choppy playback. As I mentioned, the free Flash 8 Video Encoder does not perform much of the methods above, and more methods that are offered by 3rd party encoding applications such as Sorensen Squeeze ( and the On2 Flix encoder ( . By Adobe's own admittance, the free Flash 8 Video Encoder was included with Flash 8 Professional to get people going CICE, Escuela Profesional de Nuevas Tecnologías [] 5 of 6
  6. 6. CICE, Escuela Profesional de Nuevas Tecnologías [] on flash video, but recommends going with Sorenson or On2 for higher end encoding. Conclusion Now that you are experts in what happens behind the scenes for encoding video to the FLV format, some of the settings that you see in your encoders will make more sense and we can make better decisions on what settings to adjust to achieve higher quality encoded video. Part 2 of this article will cover the encoding process using the Flash 8 Video Encoder vs. Sorenson Squeeze 4.3 (and all of its added features). I will demonstrate side-by-side comparisons with videos encoded in both the Flash 8 Video Encoder and Sorenson Squeeze using the exact same settings (but with the extra features offered in Squeeze) and see the differences in quality. Keywords flv, encoding, sorenson, video, audio CICE, Escuela Profesional de Nuevas Tecnologías [] 6 of 6
  7. 7. CICE, Escuela Profesional de Nuevas Tecnologías [] The Art of Encoding Flash Video: Sorenson Squeeze By: Derrick Ypenburg If you want to dramatically increase the quality of encoded video, you need to go beyond the free Flash 8 Video Encoder that ships with Flash 8 Professional. Third-party software such as On2 Flix Exporter for Flash ( and Sorenson Squeeze 4.5 ( are the best options for encoding video with superior quality. Third-party encoding software also has many additional options and settings that the standard Flash encoder does not include: de-interlacing options, pre-processing filters and greater control of audio/video data rate and compression settings. These are all enhanced options that any encoding professional needs to make the best video they can for streaming delivery. If you want to shake your "money-maker" with top-notch video, then this article is for you. This article will go into detail of all the advanced settings of Sorenson Squeeze and make quality comparisons to video encoded with the Flash 8 Video Encoder. If you'd like to educate yourself more about Flash video encoding,, please read part 1 of this series, The Art of Encoding Flash Video: About the FLV Format ( . You may also want to take a look at Tom Green's article, FLV Creation in Flash Professional 8 ( . The article will use Sorenson Squeeze 4.5 for encoding Flash video. If you'd like to know more about Sorenson Squeeze,you can visit the Sorenson Squeeze info page ( . You can also download a free limited trial here ( . About Sorenson Squeeze Sorenson Media ( has been in the encoding business for a long time now. Squeeze has always been the standard in 3rd-party video encoding applications for Flash and other streaming formats. Before the advent of the On2VP6 codec (created by On2 Technologies ( ) for Flash 8 Video, the Sorenson Spark codec was used for encoding video into FLV format. Sorenson supports the On2VP6 codec in its Squeeze applications version 4.2 and up. The current release of Sorenson Squeeze is version 4.5. If any of the terminologies above seem new to you, please read part 1 of this series, The Art of Encoding Flash Video: About the FLV Format ( before you move on. CICE, Escuela Profesional de Nuevas Tecnologías [] 1 of 13
  8. 8. CICE, Escuela Profesional de Nuevas Tecnologías [] Sorenson Squeeze vs Flash 8 Video Encoder There are 2 main advantages of using Sorenson Squeeze over the free Flash 8 Video Encoder: Constant vs. Variable bitrates: A video can be encoded utilizing the data rate in two (2) ways: ! " # !"$ Single-pass vs. 2-pass encoding: " % & ' ' ' & ( ) ) & * "& % + , % , - - . , / Even though a video might look fine to the eye, the encoder notices everything. The smallest pixel of color that moves differently from the rest can cause extra encoding work and loss of quality. Think about how gradients in images compress when they are saved as GIFs and JPEGs. The pixel difference throughout the gradient starts banding and the quality of the gradient suffers. This is the same when video frames are encoded. Advanced Encoding Practices Now that you are familiar with Sorenson Squeeze, we are going to create some high-quality encoded video. To show the immediate difference between Squeeze and the Flash 8 Video Encoder, preview the two example videos below (Comparison 1). Both have the exact same settings but they are encoded with different software. The first time you may not see a difference but a few comparisons should show you that the colors in the video on the right are better. CICE, Escuela Profesional de Nuevas Tecnologías [] 2 of 13
  9. 9. CICE, Escuela Profesional de Nuevas Tecnologías [] 01 2 " "& % 3 , , 4-. 3 , , 4-. 50 # $ 50 # $ 3 6 #' 3 6 #' $ $ Video Comparison 1 - Comparison between Flash 8 Video Encoder and Sorenson To achieve a much more profound difference between the two videos, the full power of Squeeze must be used. If you have Flash 8 installed, and you'd like to use the same video employed in this article, you can find it in the Flash 8 install directory. Use the following directory path (PC) to find the QuickTime version of the video: C: Program files > Macromedia > Flash 8 > Samples and Tutorials > Tutorial Assets > Cafe Townsend > 7 "& % ! ! # $ A frame preview of the video and the job setting for the video will appear in the 2 right large panels in the interface (Figure 1). CICE, Escuela Profesional de Nuevas Tecnologías [] 3 of 13
  10. 10. CICE, Escuela Profesional de Nuevas Tecnologías [] Figure 1 - Overview of Squeeze 4.5 interface ' * "# $ % * 0 " " # 68$ Although presets provide good guidelines for encoding settings, all videos are different, and a single preset may not achieve sufficient encoding quality on all types of videos. Trial and error is one of the best ways of learning how to encode different types of videos. In most cases, presets are a good starting point. 3 7 %&'()* "# $ 4 $ 5 %&'()* + ' % # '$ Figure 2 - Preset applied to video 9 % # $ CICE, Escuela Profesional de Nuevas Tecnologías [] 4 of 13
  11. 11. CICE, Escuela Profesional de Nuevas Tecnologías [] # 3$ Figure 3 - Audio/Video Compression Settings panel 6 , Audio Settings Codec: Fraunhofer MP3 option is the only one Data Rate: 48Kbps Sample Size: 16 Sample Rate: 22050 Channels: Stereo Video Settings Codec: On2VP6 Pro (Flash 8+) Method: 2-Pass CBR (2-pass encoding with a constant bitrate) Date Rate: 350Kbps Frame Size: 320 x 240 (reducing frame size to 320 x 240 for streaming is a big factor in encoding quality) Display Aspect Ratio Policy: Maintain Aspect Ratio (will scale the video proportionately) Frame Rate: 15 (dropping the frame rate will increase the quality of encoded video frames) Keyframe Every: 30 (will insert a keyframe every 2 seconds) Many of these options are available in the Flash 8 Video Encoder with exception to the following: 2-pass VBR, 2-pass CBR (Flash 8 Video Encoder is only single-pass) Display Aspect Ratio Policy Less control over the audio settings data rates The above settings go a long way to getting good looking video : 4 - 0 . " " + - CICE, Escuela Profesional de Nuevas Tecnologías [] 5 of 13
  12. 12. CICE, Escuela Profesional de Nuevas Tecnologías [] * ; + - ... * < 4 $/ 0 Below is a new side-by-side (Comparison 2) example with the new settings and the original Flash encoded video from the start of this article. Encoder: Flash 8 Video Encoder Encoder: Sorenson Squeeze Data-rate: Data-rate: Video: 350Kbps, 1-pass, CBR Video: 350Kbps, 2-pass, CBR Audio: 48Kbps (stereo) Audio: 48Kbps (stereo) Frame-rate: 30fps Keyframe rate: 60 (2 secs) Frame-rate: 15fps Keyframe rate: 30 (2 secs) Video Comparison 2 - Comparison between Flash 8 Video Encoder and new Sorenson settings The colors are definitely better on the right this time around and the brightness of the video is better overall. This may seem minor but it's a good start for such simple, extra settings. The next part is the real money-maker. Squeeze's filters make a world of difference. I have even made some videos look better color-and-brightness-wise than the original version, and that's encoding and compressing for Flash. Pre-processing Filters , # 5$ CICE, Escuela Profesional de Nuevas Tecnologías [] 6 of 13
  13. 13. CICE, Escuela Profesional de Nuevas Tecnologías [] Figure 4 - Filters panel ' " # $ = > Figure 5 - Filter applied to video settings 3 9 $ # 6$ CICE, Escuela Profesional de Nuevas Tecnologías [] 7 of 13
  14. 14. CICE, Escuela Profesional de Nuevas Tecnologías [] Figure 6 - Filter settings panel Below is a list of pre-processing filters available in Squeeze. This article won't go into complete detail on all of them, but it will point out some of the key filters and their settings. Contrast Brightness Gamma White Restore Black Restore De-interlace Video Noise Reduction Cropping Video / Audio fade in and out Normalize audio Key filter settings: De-interlace - if the video you are encoding is in NTSC format (or was not shot on a progressive scan camera), de-interlacing a video is a MUST. When a non-progressive scan camera shoots video , it shoots at 30 frames per second (fps). Each frame is composed of 2 intermixed fields. These fields are basically images that are "combed" together to create the image for the frame. Have you ever paused a digital video on your computer and the video appears as a series of intermixed lines? This is interlacing in action. You are basically pausing on the video where the 2 fields are being merged together to create the frame. See Figure 6 below for an example of interlacing. De-interlacing works by removing one of the fields from a frame of video and converting the remaining field into CICE, Escuela Profesional de Nuevas Tecnologías [] 8 of 13
  15. 15. CICE, Escuela Profesional de Nuevas Tecnologías [] a full frame. There are 5 methods of de-interlacing: - 1) Auto remove interlacing, 2) Remove interlacing odd, 3) Remove interlacing even are the most common methods of de-interlacing. Auto remove interlacing leaves de-interlacing up to Squeeze's best judgment (removes odd or even fields depending on which one is better). If Auto remove does not provide a good result, try the odd or even methods (removes odd fields or even fields only). - 4) Remove telecine odd, 5) Remove telecine even work similar to the above 3 methods but you use these methods in the case of up-sampling the frame rate of a video. If the source video was shot for motion picture film (or at 24 fps), telecine will de-interlace as well as adding frames where they most make sense to up-sample the frame rate of the video to 30fps. This is also used when converting PAL formatted video (25fps) to 30fps video. These methods are mostly used when encoding video for DVD playback and such. Figure 7 - Interlacing artifacts Black restore / White Restore - These filters makes your blacks more consistent and your whites whiter. Visually the video will look nicer, but it will also encode better as there are less shades blacks and whites to deal with during encoding. Contrast, Brightness and Gamma are common filters in any software that handles images and video. These can be used to correct an associated imperfections in the video that need tweaking. Video Noise Reduction - Use this filter when you see noise that occurred during the capture process. When video is captured, not all the data is easily understood by the capture process and noise will occur. Capturing video from a VHS tape would cause the worst case of video noise. use the settings depending on the quality of the video capture. The above list is a summary of the most important filters to use in Squeeze. The rest of the filters can be searched from the Help menu for further definitions. As you adjust the filter settings, Squeeze allows you to preview the results of the settings you are applying to the video. The preview panel allows you to do a side-by-side comparison with the view of the source video and the view of the video after it's encoded. Follow the steps in the list below to apply and preview filters in your video. ! # 0$ CICE, Escuela Profesional de Nuevas Tecnologías [] 9 of 13
  16. 16. CICE, Escuela Profesional de Nuevas Tecnologías [] ' , 1$ 2 # 0$ , # 0$ 3 , # 0$ 5 ; % , % , # 0$ , , , , , # 0$ 6 % , * ( ( + 9 - # $ ( Figure 8 - Previewing filter settings with brightness setting adjusted Filters that are applied to a video are applied to the entire video. You can not apply a filter to a specific range of a video. As you apply filters, use the scrub bar at the bottom of the video preview panel to see the filter's effect on the rest of the video. Although a filter might make one part of a video look better, it might adversely affect another part of a video. Figure 9 below shows a preview of the de-interlacing filter applied to a standard NTSC video. De-interlacing is a fundamental filter that should be applied to all videos that were not shot with a progressive scan camera. CICE, Escuela Profesional de Nuevas Tecnologías [] 10 of 13
  17. 17. CICE, Escuela Profesional de Nuevas Tecnologías [] Figure 9 - Live preview of de-interlacing set to Auto remove interlacing : ? = , )"& % @) - ,. #(4$ / 4 #! $ " + - * 0 + , $34 5 !67 " Previewing and Comparing Videos Below is a comparison of the final video complete with filter settings and the video that was encoded with the Flash 8 Video Encoder. There wasn't anything more that could be done to the video on the left as the Flash 8 Video Encoder and its settings had reach it's limitations. A thousand words later and a lot of info, Sorenson Squeeze is still be explored. To someone who doesn't work with video too much, the comparison below might not look like much. To notice the differences, a video has to be looked at beyond the main subject of a sequence or frame. Look at the backgrounds (much more clear and better contrast eh?). The plate for the salad and near the end of the video looks much better. You can see the chefs face more clearly. CICE, Escuela Profesional de Nuevas Tecnologías [] 11 of 13
  18. 18. CICE, Escuela Profesional de Nuevas Tecnologías [] 01 2 Encoder: Sorenson Squeeze Data-rate: 3 , , 4-. Video: 350Kbps, 2-pass, CBR 50 # $ Audio: 48Kbps (stereo) 3 6 #' $ Frame-rate: 15fps Keyframe rate: 60 (2 secs) Comparison 3 - Comparison of Flash 8 Video Encoder video and the final Squeeze encoded video. Filter settings used for final Sorenson Squeeze video: Figure 10 - Final filter settings applied to Cafe Townsend video CICE, Escuela Profesional de Nuevas Tecnologías [] 12 of 13
  19. 19. CICE, Escuela Profesional de Nuevas Tecnologías [] Conclusion At the end of the day, all the settings above are great, but, its an eye for detail, experience, and experimentation with settings that provide the great result of well encoded video. Create a table of different settings, create a web page full of Flash video for side-by-side-by-side-etc. comparisons. Group types of video into groups (high-movement, talking head, medium motion, etc) and determine ideal settings that can create good encoding quality for each video that falls within a certain category. Settings, filters and Squeeze are great, but encoding video is more of a learned skill and an art form! Approximate download size: 390k Keywords Sorenson squeeze, On2, On2VP6, video, flash, FLV, deinterlace, filters, encoding, data rate, bit rate, compression, streaming, progressive download A4 !B ' ' ' 6 CICE, Escuela Profesional de Nuevas Tecnologías [] 13 of 13
  20. 20. CICE, Escuela Profesional de Nuevas Tecnologías [] The Art of Encoding Flash Video - Part 3: Advanced Compression Settings with Sorenson Squeeze By: Derrick Ypenburg In the first two installments of the Art of Encoding Series, I covered the basics of the FLV Format (The Art of Encoding Flash Video: About the FLV Format ( ) and introduced everyone to encoding video using Sorenson Squeeze (The Art of Encoding Flash Video: Sorenson Squeeze ( ). This installment will go further into the compression settings of Sorenson Squeeze 4.5 by using its advanced compression settings. Getting familiar with and using these advanced settings will result in higher encoded video quality and better playback performance of Flash video. If you are not familiar with Sorenson Squeeze 4.5, please read the introduction article to Sorenson Squeeze, The Art of Encoding Flash Video: Sorenson Squeeze ( . The article will use Sorenson Squeeze 4.5 for encoding Flash video. If you'd like to know more about Sorenson Squeeze,you can visit the Sorenson Squeeze info page ( . You can also download a free limited trial here ( . CICE, Escuela Profesional de Nuevas Tecnologías [] 1 of 7
  21. 21. CICE, Escuela Profesional de Nuevas Tecnologías [] Sorenson Squeeze 4.5 Advanced Compression Settings Figure 1 - Squeeze interface with advanced compression options menu To start exploring the advanced settings as I describe each setting in detail, you first must import a file and apply a Flash Video setting to it. & ! " # " " $ " " % " * ! " ' ( "$ ! ) % " / + ( " , ( - # . " " " Overview of Advanced Video Compression Settings Below is a list and description of all the advanced compression settings you can apply to your video. Depending on the CODEC chosen and the encoding method you choose, not all of the settings will be available. I will notify you of what settings are available only for certain compression methods and CODECs. To make the first notification easy, select the Sorenson Spark Pro codec from the Codec drop-down menu and you'll see you get maybe 20% of the advanced settings compared to using the On2 VP6 Pro codec. I will be focusing on the available settings for the On2 VP6 Pro codec. CICE, Escuela Profesional de Nuevas Tecnologías [] 2 of 7
  22. 22. CICE, Escuela Profesional de Nuevas Tecnologías [] Codec: - This is where you select the codec used to compress your Flash video. I will be using the On2 VP6 pro codec. The following describes the two available codecs and what version of Flash player supports each for playback. On2VP6 Pro: Available in Flash Player 8+. Encodes alpha channels More advanced compression settings Sorenson Spark Pro Flash Player 6+ Method - The method setting has four (4) different options for how the video is encoded. The setting is a combination of 2-pass vs 1-pass encoding, and CBR (Constant bit rate) vs VBR (Variable bit rate). 1-pass vs 2-pass encoding are methods of analyzing and encoding the video in a single pass (1-pass), or analyzing the video on the first pass and encoding the video based on the analysis of the first pass and then applying it to the compressing that happens in the second pass (2-pass). 2-pass encoding always results in higher quality video compression as the tasks of analyzing the video and compressing it are separate. This allows the encoder more time to focus and essentially do a better job. 2-pass encoding does take longer to encode a video, but the end result is worth the wait. CBR (constant bit rate) and VBR (variable bit rate) are methods of how the target data rate for the video is applied. A Constant Bit Rate takes the target data rate for the video and applies the specified data rate precisely to each second of video. i.e. A target video data rate of 276Kbps applies exactly 276Kb to each second of video regardless if that much data is needed to encode a second of video. A Variable Bit Rate on uses as much data as needed to encode a second of video. If a section of video is relatively easy to encode such as a still moment in the video, the encoder uses only as much data as needed to make the section look good. If only 100Kb is needed to make the section look good, it will only use 100Kb. This helps save room in the pipeline for the rest of the video to stream/load faster, thus keeping your buffer full and smoother playback results. This also helps save unnecessary output of data from your server. The general rule of thumb is to use a Constant Bit Rate for streamed videos under 80Kbps. For streaming video above 80Kbps, variable bit rates are applied. Using a CBR method for low data rates is necessary as all bandwidth needs to be consumed for making the best quality video as possible. Data Rate - To apply a data rate to your video, you can choose a preset from the drop-down menu or you can type your own target video data rate in. The presets have common target data rate settings based on the average connection speeds of internet users, but you can get into typing in your own custom data rates as well to tweak your video quality, as well as trying to get the lowest data rate as possible while still maintaining quality. Note that the data rate for the video is separate from the audio data rate. This means that the selected video data rate is added to the audio data rate. Frame Size - This is used to re-size your video. I generally use 320 x 240 (depending on the aspect ratio of the video) for general streaming. Adjusting the size of the video allows higher quality video when you go smaller than the original display size of the video. This is because there are fewer pixels to compress and fewer pixels means more data rate to go around to make smaller images look good. Display Aspect Ratio Policy - This setting affects how your video is re-sized. If you select Unconstrained, your video will be stretched or squashed on re-sizing. If you select Maintain Aspect Ratio, the video will be re-sized proportionately. Using the Letter Box or Pillar setting will maintain the aspect ratio of the video but the video will be cropped by the width and height setting applied in the Frame Size option. Frame Rate - Dropping the frame rate of streaming video is a given. The less frames that are encoded, the higher the overall image quality will be. I generally cut my frame rates in half. i.e. 30fps gets cut to 15fps. For talking head shots, you can go as low as 10fps as there is not much movement going on. CICE, Escuela Profesional de Nuevas Tecnologías [] 3 of 7
  23. 23. CICE, Escuela Profesional de Nuevas Tecnologías [] Less frames frees up data rate for image quality but results in more choppy motion More frames provides smoother playback but results in more blurry/pixilated images Use evenly divisible frame rates to reduce frame rates i.e. halves, thirds, quarters (this avoids synchronization issues) Key Frame Every - Keyframes for video are very different from the keyframes you use in Flash. Keyframes in video are "snapshots" taken over time of what is going on in the video. When a keyframe is placed, all encoded frames after a keyframe are compared to what is going on the the last keyframe. This method encodes only what has changed in a current frame compared to the last keyframe. Say if the background in a frame is the same as the last keyframe and only part of a person talking has changed, only the person talking is encoded and the information stored for the background in the keyframe is re-used for that frame. This helps free up data rate and applies it to only things that have changed. This results in higher quality images throughout the video. To apply a keyframe rate, you can choose from the preset values in the drop down menu or you can type your own values in. The values represent the number of frames between keyframes. If your frame rate is 15fps and the keyframe rate is 30, a keyframe will be placed in the video every 2 seconds (or 30 frames). Use lower values (more keyframes) for complex material (i.e. Sports, lots of effects and transitions). Use higher value (less keyframes) for less complex material (i.e. talking head shot) A high frequency of keyframes can result in the target data rate of the video being exceeded Compress Alpha Data: - Checking this option encodes alpha channel channels Alpha Data Rate: - Percentage of target data rate allocated to compression of alpha channel. This would depend on complexity of edges of alpha channels. Auto Key Frames Enabled: - Squeeze will automatically determine the frequency of keyframes needed for sections of video. If two frames are drastically different, the encoder inserts a keyframe. The Auto Key Frame Threshold determines how different the frames have to be before a keyframe is thrown. A higher number means fewer keyframes. This option works in conjunction with the keyframe rate you may have previously set. Minimum Distance to Key Frame: Minimum number of frames allowed between keyframes Low value can result in increase to overall data rate Higher value for less complex material (i.e. talking head shot) Compression Speed: - This setting adjusts the speed at which the video encodes at. I only use Best for my encoding speed. The Best settings is marginally slower than the other settings. I'm not in that much of a hurry that I want to compromise encoding quality to save seconds or a few minutes. For high-production environments, you could invest in dedicated encoding machine and then encoding time will not matter that much. Speed: - If Compression Speed is set to Fastest, the encoder attempts to use percentage of processor cycles based on value set in slider Minimum Quality: Worst allowed frame quality Higher numbers mean you won't get bad looking frames May interfere with compressor to maintain target data rate without dropping frames Maximum Quality: The best allowed frame quality Higher is better Helps manage achievement of target data rate without dropping frames Quality: Only available for 1-Pass VBR method Uses a constant frame quality as specified in slide (0 – 100) CICE, Escuela Profesional de Nuevas Tecnologías [] 4 of 7
  24. 24. CICE, Escuela Profesional de Nuevas Tecnologías [] Data rate is controlled by dropping frames or resizing frames if selected VBR Variability Used to control variability of bit rate of VBR method 0 creates a constant bitrate Higher values create higher variability The compressor uses data rate proportionate to complexity of section that is being encoded Drop Frames to Maintain Data Rate: - Allows compressor to drop frames in order to hit target rate in difficult sections. Drop Frames Watermark: - Sets a data rate threshold in which the encoder is allowed to start dropping frames to maintain target data rate Sharpness: - If your source video is blurry or muddy, the sharpness setting can help sharpen your video. The setting values are between 0 and 10 (smoothest and sharpest, respectively). Lower value results in fewer visible artifacts but can result in blurring Higher value will provide a sharper image but with more visible artifacts Can help with blurry text and graphics Noise Pre-processing Level: - Helps reduce noise artifacts that result from video signal during video capture. Will not remove existing noise in source video. 0 is no noise removal, 6 is highest. Start Buffer Level: Applies to CBR methods only Amount of video data that is pre-loaded into client player in seconds Compensates for consistent datarate Minimizes playback interruption but results in slower initial video playback Minimum 2-Pass VBR Data Rate: The lowest percentage of target data rate the encoder will allow for any section Does not matter how easy section is Prevents more difficult sections from stealing too much data rate from easy sections Setting is based on selected percentage of overall data rate Maximum 2-Pass VBR Data Rate: - The highest percentage of target data rate that can be streamed no matter how difficult section is. Data Rate Undershoot: - Averages a slightly lower overall data rate (based on target data rate) to allow more available bits in buffer for more difficult sections. Overview of Audio Compression Settings Figure 2 - Audio compression settings Audio compression settings are pretty straight forward once you know what all the settings mean. Codec: - The options are Uncompressed or Fraunhofer MP3. To achieve good sound quality within a specified data rate. the MP3 option is mandatory. Data Rate: - Select a target data rate for the audio from the drop-down menu. You cannot free-type in your own CICE, Escuela Profesional de Nuevas Tecnologías [] 5 of 7
  25. 25. CICE, Escuela Profesional de Nuevas Tecnologías [] data rate here. For high data rates I generally choose 48Kbps and never exceed 96Kbps. Audio sounds great at low data rates for streaming. Anything over 96Kbps is getting close to the range of CD quality audio which for streaming over the web is getting frivolous. Remember what I mentioned earlier, the audio and video data rates are separate and they are added together as the overall data rate so high audio data rates make you take away data rate for video quality. As audio and video data rates are compounded, below is a rule of thumb for data rates of combined audio/video data rates for dial-up connection speeds. Anything above that you can test for the best combination of combined audio and video data rates. Dial-up connections: Overall data rate: 48Kbps (you need to consume basically all of the bandwidth for this connection speed) Audio data rate: 16Kbps Video data rate: 32Kbp Sample Size: - The Sample Size is the number of bits used to store every second of audio information. The setting for Flash video is stuck at 16 bits. Sample Rate: - The sample rate is how many times per second audio information is lifted out of the bit storage of the audio. A sample rate of 44100 means that 16 bits of audio information is sample 44,100 times per second. This results in higher quality but it can compromise the overall target data rate for the audio. The Sample Rate values are limited depending on the audio Data Rate selected. Channels: - There are 2 channels options. Mono or stereo. This option varies on the selected target data rate. Whenever present, I select the stereo option. That means the audio is spread out over left and right speaker channels. A Couple of Final Settings Figure 3 - Final Squeeze settings The last few settings that I'll cover are pretty simple. At the top of the Compression Settings panel are 3 settings options. Total Data Rate: - This is a read-only value that displays the combined audio and video data rates. After you apply your settings, have a look at this value to make sure you have not exceeded any target data rate you are setting out to achieve. Constrain File Size: - This displays some math that multiplies the video in length (in seconds) by the applied target data rate. If selected, you are guaranteeing the final file size of the video jives with the overall target rate applied to the video. This prevents any overshots in data rate that may occur depending on the settings you have applied. Name: - Re-type in a name for your settings and press the Export button at the bottom of the panel to export the settings as a custom preset. This custom preset will appear in the compression settings panel. You can also send the settings file (you will see where is gets saved to when you export the settings) to colleagues or anyone who needs the same settings and they can import the settings file into Squeeze. Summarizing the Audio and Video Settings As you may have found in the audio compression settings section, the audio settings are pretty straight forward because of the limitations in place. Any audio settings over 48Kbps is going to sound pretty good. I always start with 48Kbps, test for quality and bump the data rate up if need be. I tend to focus more on the video quality. I usually start with an overall data rate of 350Kbps for video and go from CICE, Escuela Profesional de Nuevas Tecnologías [] 6 of 7
  26. 26. CICE, Escuela Profesional de Nuevas Tecnologías [] there. If the video looks great at 350Kbps, I'll lower the video data rate and test again. The goal is not to have a standard data rate for different connection speeds but try to get the lowest data rate you can for all of your connection speeds while maintaining good quality video within compromise. Just because you have a high-speed audience, it does not mean a video requires high data rates. Some videos still look good at lower data rates. Remember, you have a responsibility at your end to manage the amount of information that streams from your server. Tweaking data rates to as low as they can go means money in your pocket if you pay your service provider by the amount of data that gets pulled from your server. Further, if you have a large amount of users streaming from your server at one time, lower data rates are less taxing on your server if you are streaming a lot of videos at once. For 56Kbps users, you will pretty much have to consume all of their bandwidth if you hope to have any kind of quality stream. Using a constant bit rate will also help achieve the best quality you can for low bandwidth users. Once you test and get familiar with what data rates and settings satisfy certain categories of video i.e. high motion, talking heads, medium motion, you can create custom settings to apply in batch processes for specified video categories so you do not need to hand-tweak each video. Not all videos are the same and you cannot satisfy every video with the same settings so there will be exceptions. But for a large encoding environment, compromises need to be made in order to be efficient. Keywords Soresnon Squeeze, video, FLV, compression, data rates, frame rates, codecs, On2 VP6, encoding, audio - 01 23 &44&(&445 - " CICE, Escuela Profesional de Nuevas Tecnologías [] 7 of 7