Tuesday, August 14, 2007

How can I increase encoding quality?

Encoding quality can best be improved by increasing the encoding bit-rate. The higher the bit-rate, the less image data that the encoder has to throw away, and the better the quality.

Increasing the bit-rate is often not an option due to bandwidth limitations of the transmission path or the decoder. The following additional encoding and analysis approaches can be tried to increase the encoding quality. These approaches are not applicable for all encoding situations (check into your encoding requirements specification).

Match Motion Estimation to that of the video content

At a specific bit-rate, high motion images will usually encode with better quality by setting the Encode Configure | Precision | options to the Large settings. In video scenes with minimal motion, a lower motion estimation setting will actually produce better quality. This is because the shorter motion vectors have better resolution and will to a better job of motion compensation. It is possible to vary the motion estimation scene by scene using the EDL file commands.

Increase the vbv_buffer size
The larger the vbv_buffer size set in Encode Configure | Parameters dialog, the more “head room” the encoder has in allocating more bits to frames that have more motion and fewer bits to frames that have less motion. The vbv_buffer size is dictated by the MPEG decoder’s internal memory. It us usually listed in the system encoding specifications. MPEG-2 standard definition buffer size is often specified at 118; HD is usually 488. The vbv number is the number of 16K bit blocks of data.

Increase the GOP size
The larger the Encode Configure | Parameters | N value, the large the GOP size. Increasing N provides more separation between I blocks which may allow more efficient encoding as I blocks consume the most bits. A GOP value of 60 or 90 often increases encoding quality over the default value of 15. Note that N needs to be easily divisible by M. Some systems, such as DVD, limit the N to 15.

Use Open GOPs
UnChecking the Encode Configure |Parameters | Closed GOPs will utilize the more efficient Open GOPs. Open GOPs can reference past and future GOPs for motion compensation and therefore provide better quality encoding. In closed GOPs the starting and encoding B (bi-directional) frames essentially become less efficient P (unidirectional frames).

Use Auto Scene Change Detection
Set the Encode Configure | Precision | Scene Change Detection to Auto to enable the encoder to detect and automatically start a new scene with an I frame. I frames utilize the most bits and are best at the start of a new scene. But the main advantage is that the next I frame is N frames away from this I frame.

Filter Frames before encoding to remove sharp edges

Encoding artifacts often occur around sharp edges (such as text). The encoder tends to discard higher frequencies as they carry less information. This sometimes results in ringing around those regions. You can apply softening filters on the images just prior to encoding by selecting a filter in Encode PreProcess | Filter dialog. This should decrease the ringing caused by the high frequencies at the expense of softer images. You can also filter just selected segments of a movie or just selected regions from within a frame using the FILTER command in the EDL file.

Incremental Approach to High Encoding Quality
There are lots of experiments that you can do on your image sequences with MPEGRepairHD to improve image quality. One basic test on a problem video would be to re-encode the bad sequence using virtually loss-less MPEG compression. Set the Encode Configure | Rate Control | Rate Control Strategy to Constant MQuant and enter a 1 in the adjacent Constant MQuant edit box. The resultant MPEG clip may not play properly on many MPEG decoders, but you can look at the result on MPEGRepairHD’s decode section. Any artifacts or problems with this video are most likely the result of something other than the MPEG compression itself.

Once you are satisfied with the encoding quality in this mode (at a very high output bit-rate), you can re-encode with a high constant bit rate and gradually reduce the bit-rate to your desired value … carefully monitoring the decoded video for artifacts. Problem areas (artifacts) can be addressed using the Preprocessing frame filters or other approaches as detailed above. Try the smooth filter to remove the rough edges from you video as sharp edges cause the most artifacts. The frame filters can be applied to all frames being encoded by setting the Preprocessing | Filter option. Or you can apply the filter to a specific scene or set of frames using the EDL FILTER commands. Or you can apply the filter within or without of a region on a selected frame sequence using the EDL REGIONFILTER commands.

In addition, you can suggest to the encoder to add more (or less) bits to a specific region within a specific set of frames using the MODIFYMQUANT EDL commands. You can combine the above EDL commands to enhance a region of interest in the encoded frames and apply a softening filter outside of the region of interest. You can also interactively enhance region quality and filter outside that region by selecting a region of interest using the right mouse button on any encoding window during encoding. Refer to the EDL command section and the Regional Enhancing section of you product documentation for additional details.

Analytical Quality Reports
While the only true judge of video quality is the human eye, you can have MPEGRepairHD print out Signal to Noise reports frame by frame and across the encode sequence. This provides rapid feedback on whether the parameter changes you have made have increased or decreased the quality. Before starting the encoding, depress the right hand St (Statistics window) and select the menu item View | SNR. The SNR and Mean Square Error are calculated and printed out in this window and in the encode log file for each frame. Also, the average SNR for the entire encode sequence is displayed in the closing pop-up message box. This is an excellent way to scope out the quality differences when applying multiple parameter change enhancements.�

No comments: