четверг, 25 февраля 2016 г.

Setting up H.264/AVC encoder in PlayClaw

The settings for the various H.264/AVC encoders (AMD, Intel, NVidia) are similar to each other. The only differences are the set of pre-sets and bitrate control methods.



The pre-set is a set encoding parameters that have been pre-defined. NVidia's set is very detailed and it is possible to understand the purpose of each set by its name. For most users NVDefault pre-set will be the best choice. This pre-set is quite fast and efficient.

Bitrate Control

You need to select a bitrate control method for the encoder. All encoders have standard CBR (constant bitrate) and VBR (Variable bitrate) as well as their own.

When choosing a CBR, the encoder will try to adjust the compression quality to fit the specified maximum bitrate. However, it is possible that better quality is achieved using a lower bitrate.

Variable bitrate can be controlled by a QP - Quantization Parameter or in other words the quality parameter. The lower (0 - the lowest) value gives best quality. The higher (51 - max) gives best compression ratio.

For example, NVidia has control method VBR/QP where you can set the minimum and maximum QPs. In this case, the encoder will try to set the compression quality within the defined limits, possibly by increasing the real QP (reducing the size of the data) if the frame allows it.

All encoders have a CQP control method (constrained QP) where the minimum and maximum values are the same (and are called "quality" in the settings). This option can be considered as the fastest VBR encoder because it is not necessary for the encoder to adopt the quality, it is already firmly set.

Frame sequence control

Frames sequence in H.264/AVC consists of three types of frames - the key frame (I-frame) and the normal frames (P-frame, B-frame). I-frame is compressed independently (like MJPEG image), P-frame is compressed using reference to previous I or P frame (encoder tries to compress frames difference, not frame itself). B-frame is compressed using references to previous and subsequent I or P frames.

By setting key frame interval you specify how often the encoder inserts an I-frame. The more dynamic scene, the greater the key frame interval must be. Some streaming services recommend specific key frame intervals. You need to comply with them to get better stream quality.

The P-frames interval option defines the size of the B-frames chain which is contained between two consecutive P-frames. That is, if the interval is equal to 1 (one), the B-frames are all disabled. If the interval is 2, then between P-frames only one B-frame will be inserted. Note that greater P-frames intervals can give higher load on the encoder and decoder.

Group of Pictures (GoP) - is the frames between the two key frames (plus the first I-frame). When the encoder creates a P and B frame, it can reference two frames outside the current GoP. In this case, the group is called open. The compression ratio is increased. Streaming services may require closed GoP. There is special option to enable this.

The constant frame rate (CFR) option helps to avoid potential video and audio desync with some editors (like Adobe Premiere). If there are dropped frame for some reason, PlayClaw will try to simulate it with a duplicate of the previous frame.

Additional settings

The CABAC option is available in the advanced settings. This will allow to get higher compression ratio by using a more advanced algorithm in the encoder.