# vaapih264enc

Encodes raw video streams into H.264 bitstreams.

The rate-control property controls the type of encoding. In case of Constant Bitrate Encoding (CBR), the bitrate will determine the quality of the encoding. Alternatively, one may choose to perform Constant Quantizer or Variable Bitrate Encoding (VBR), in which case the bitrate is the maximum bitrate.

The H264 profile that is eventually used depends on a few settings. If dct8x8 is enabled, then High profile is used. Otherwise, if cabac entropy coding is enabled or max-bframes are allowed, then Main Profile is in effect. The element will alway go with the maximal profile available in the caps negotation and otherwise Baseline profile applies. But in some cases (e.g. hardware platforms) a more restrictedprofile/level may be necessary. The recommended way to set a profile is to set it in the downstream caps.

You can also set parameters to adjust the latency of encoding: quality-level is a number between 1-7, in the case of the Intel VAAPI driver, where a lower value will produce a higher quality output but with more latency; meanwhile a hihg number will produce a lower quality output with less latency. Also you can set tune, if your backend supports it, for low-power mode or high compression.

## Example launch line

      gst-launch-1.0 -ev videotestsrc num-buffers=60 ! timeoverlay ! vaapih264enc ! h264parse ! mp4mux ! filesink location=test.mp4

## Hierarchy

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstElement
                    ╰──GstVideoEncoder
                        ╰──GstVaapiEncode
                            ╰──vaapih264enc

## Implemented interfaces

    GstPreset

## Factory details

Authors: – Wind Yuan

Classification: – `Codec/Encoder/Video/Hardware`

Rank – primary

Plugin – vaapi

Package – gstreamer-vaapi

## Pad Templates

### `sink`

    video/x-raw:
             format: { NV12, YV12, I420 }
              width: [ 1, 2147483647 ]
             height: [ 1, 2147483647 ]
          framerate: [ 0/1, 2147483647/1 ]
     interlace-mode: progressive

    video/x-raw(memory:VASurface):
             format: { NV12, YV12, I420 }
              width: [ 1, 2147483647 ]
             height: [ 1, 2147483647 ]
          framerate: [ 0/1, 2147483647/1 ]
     interlace-mode: progressive

Presence – always

Direction – sink

Object type – GstPad

### `src`

    video/x-h264:
      stream-format: { (string)avc, (string)byte-stream }
          alignment: au
            profile: { (string)constrained-baseline, (string)baseline, (string)main, (string)high, (string)multiview-high, (string)stereo-high }

Presence – always

Direction – src

Object type – GstPad

## Properties

### bitrate

    “bitrate” guint

The desired bitrate expressed in kbps (0: auto-calculate)

Flags : Read / Write

Default value : 0

### cabac

    “cabac” gboolean

Enable CABAC entropy coding mode

Flags : Read / Write

Default value : false

### compliance-mode

    “compliance-mode” Vaapi-encoder-h264compliance-mode *

Tune Encode quality/performance by relaxing specification compliance restrictions

Flags : Read / Write

Default value : strict (0)

### cpb-length

    “cpb-length” guint

Length of the CPB buffer in milliseconds

Flags : Read / Write

Default value : 1500

### dct8x8

    “dct8x8” gboolean

Enable adaptive use of 8x8 transforms in I-frames

Flags : Read / Write

Default value : false

### default-roi-delta-qp

    “default-roi-delta-qp” gint

The default delta-qp to apply to each Region of Interest(lower value means higher-quality, higher value means lower-quality)

Flags : Read / Write

Default value : -10

### init-qp

    “init-qp” guint

Initial quantizer value

Flags : Read / Write

Default value : 26

### keyframe-period

    “keyframe-period” guint

Maximal distance between two keyframes (0: auto-calculate)

Flags : Read / Write

Default value : 30

### max-bframes

    “max-bframes” guint

Number of B-frames between I and P

Flags : Read / Write

Default value : 0

### max-qp

    “max-qp” guint

Maximum quantizer value

Flags : Read / Write

Default value : 51

### mbbrc

    “mbbrc” GstVaapiEncoderMbbrc *

Macroblock level Bitrate Control

Flags : Read / Write

Default value : auto (0)

### min-qp

    “min-qp” guint

Minimum quantizer value

Flags : Read / Write

Default value : 1

### num-slices

    “num-slices” guint

Number of slices per frame

Flags : Read / Write

Default value : 1

### num-views

    “num-views” guint

Number of Views for MVC encoding

Flags : Read / Write

Default value : 1

### prediction-type

    “prediction-type” Vaapi-encoder-h264prediction-type *

Reference Picture Selection Modes

Flags : Read / Write

Default value : default (0)

### qp-ib

    “qp-ib” gint

Difference of QP between I and B frame (available only on CQP)

Flags : Read / Write

Default value : 0

### qp-ip

    “qp-ip” gint

Difference of QP between I and P frame (available only on CQP)

Flags : Read / Write

Default value : 0

### quality-factor

    “quality-factor” guint

quality factor for ICQ/QVBR bitrate control mode(low value means higher-quality, higher value means lower-quality)

Flags : Read / Write

Default value : 26

### quality-level

    “quality-level” guint

Encoding Quality Level (lower value means higher-quality/slow-encode, higher value means lower-quality/fast-encode)

Flags : Read / Write

Default value : 4

### rate-control

    “rate-control” Vaapi-rate-control-h264 *

Rate control mode

Flags : Read / Write

Default value : cqp (1)

### refs

    “refs” guint

Number of reference frames

Flags : Read / Write

Default value : 1

### target-percentage

    “target-percentage” guint

The desired target percentage of bitrate for variable rate controls.

Flags : Read / Write

Default value : 70

### temporal-levels

    “temporal-levels” guint

Number of temporal levels in the encoded stream

Flags : Read / Write

Default value : 1

### trellis

    “trellis” gboolean

The Trellis Quantization Method of Encoder

Flags : Read / Write

Default value : false

### tune

    “tune” Vaapi-encoder-tune-h264 *

Encoder tuning option

Flags : Read / Write

Default value : none (0)

### view-ids

    “view-ids” GstValueArray *

Set of View Ids used for MVC encoding

Flags : Read / Write

## Named constants

### Vaapi-encoder-h264compliance-mode

#### Members

`strict` (0) – Strict compliance to the H264 Specification
`restrict-buf-alloc` (1) – Restrict the allocation size of coded-buffer

### Vaapi-encoder-h264prediction-type

#### Members

`default` (0) – Default encode, prev/next frame as ref
`hierarchical-p` (1) – Hierarchical P frame encode
`hierarchical-b` (2) – Hierarchical B frame encode

### Vaapi-encoder-tune-h264

#### Members

`none` (0) – None
`high-compression` (1) – High compression
`low-power` (3) – Low power mode

### Vaapi-rate-control-h264

#### Members

`cqp` (1) – Constant QP
`cbr` (2) – Constant bitrate
`vbr` (4) – Variable bitrate
`vbr_constrained` (5) – Variable bitrate - Constrained
`icq` (7) – Constant QP - Intelligent
`qvbr` (8) – Variable bitrate - Quality defined

The results of the search are