## x264enc x264enc |

## Properties

GstX264EncAnalyse | analyse | Read / Write
gboolean | aud | Read / Write
gboolean | b-adapt | Read / Write
gboolean | b-pyramid | Read / Write
guint | bframes | Read / Write
guint | bitrate | Read / Write
gboolean | byte-stream | Read / Write
gboolean | cabac | Read / Write
gboolean | dct8x8 | Read / Write
gboolean | interlaced | Read / Write
gfloat | ip-factor | Read / Write
guint | key-int-max | Read / Write
GstX264EncMe | me | Read / Write
gchar * | multipass-cache-file | Read / Write
guint | noise-reduction | Read / Write
GstX264EncPass | pass | Read / Write
gfloat | pb-factor | Read / Write
guint | qp-max | Read / Write
guint | qp-min | Read / Write
guint | qp-step | Read / Write
guint | quantizer | Read / Write
guint | ref | Read / Write
guint | sps-id | Read / Write
gchar * | stats-file | Read / Write
guint | subme | Read / Write
guint | threads | Read / Write
gboolean | trellis | Read / Write
guint | vbv-buf-capacity | Read / Write
gboolean | weightb | Read / Write
gboolean | intra-refresh | Read / Write
gboolean | mb-tree | Read / Write
gint | rc-lookahead | Read / Write
gboolean | sliced-threads | Read / Write
gint | sync-lookahead | Read / Write
gchar * | option-string | Read / Write
GstX264EncProfile | profile | Read / Write
GstX264EncPsyTune | psy-tune | Read / Write
GstX264EncPreset | speed-preset | Read / Write
GstX264EncTune | tune | Read / Write
GstX264EncFramePacking | frame-packing | Read / Write
gboolean | insert-vui | Read / Write

## Types and Values

struct | GstX264Enc

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GstObject
                ╰── GstElement
                    ╰── GstVideoEncoder
                        ╰── GstX264Enc

## Implemented Interfaces

GstX264Enc implements GstPreset.

## Description

This element encodes raw video into H264 compressed data, also otherwise known as MPEG-4 AVC (Advanced Video Codec).

The “pass” property controls the type of encoding. In case of Constant Bitrate Encoding (actually ABR), the “bitrate” will determine the quality of the encoding. This will similarly be the case if this target bitrate is to obtained in multiple (2 or 3) pass encoding. Alternatively, one may choose to perform Constant Quantizer or Quality encoding, in which case the “quantizer” property controls much of the outcome, in that case “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 “bframes” are allowed, then Main Profile is in effect, and otherwise Baseline profile applies. The high profile is imposed by default, which is fine for most software players and settings, but in some cases (e.g. hardware platforms) a more restricted profile/level may be necessary. The recommended way to set a profile is to set it in the downstream caps.

If a preset/tuning are specified then these will define the default values and the property defaults will be ignored. After this the option-string property is applied, followed by the user-set properties, fast first pass restrictions and finally the profile restrictions.

Some settings, including the default settings, may lead to quite some latency (i.e. frame buffering) in the encoder. This may cause problems with pipeline stalling in non-trivial pipelines, because the encoder latency is often considerably higher than the default size of a simple queue element. Such problems are caused by one of the queues in the other non-x264enc streams/branches filling up and blocking upstream. They can be fixed by relaxing the default time/size/buffer limits on the queue elements in the non-x264 branches, or using a (single) multiqueue element for all branches. Also see the last example below. You can also work around this problem by setting the tune=zerolatency property, but this will affect overall encoding quality so may not be appropriate for your use case.

### Example pipeline

    1
    2
    gst-launch-1.0 -v videotestsrc num-buffers=1000 ! x264enc qp-min=18 ! \
      avimux ! filesink location=videotestsrc.avi

This example pipeline will encode a test video source to H264 muxed in an AVI container, while ensuring a sane minimum quantization factor to avoid some (excessive) waste. You should ideally never put H264 into an AVI container (or really anything else, for that matter) - use Matroska or MP4/QuickTime or MPEG-TS instead.

    1
    2
    gst-launch-1.0 -v videotestsrc num-buffers=1000 ! x264enc pass=quant ! \
      matroskamux ! filesink location=videotestsrc.mkv

This example pipeline will encode a test video source to H264 using fixed quantization, and muxes it in a Matroska container.

    1
    2
    gst-launch-1.0 -v videotestsrc num-buffers=1000 ! x264enc pass=5 quantizer=25 speed-preset=6 ! video/x-h264, profile=baseline ! \
      qtmux ! filesink location=videotestsrc.mov

This example pipeline will encode a test video source to H264 using constant quality at around Q25 using the 'medium' speed/quality preset and restricting the options used so that the output is H.264 Baseline Profile compliant and finally multiplexing the output in Quicktime mov format.

    1
    2
    gst-launch-1.0 -v videotestsrc num-buffers=1000 ! tee name=t ! queue ! videoconvert ! autovideosink \
      t. ! queue ! x264enc rc-lookahead=5 ! fakesink

This example pipeline will encode a test video source to H264 while displaying the input material at the same time. As mentioned above, specific settings are needed in this case to avoid pipeline stalling. Depending on goals and context, other approaches are possible, e.g. tune=zerolatency might be configured, or queue sizes increased.

## Synopsis

### Element Information

plugin | x264
author | Josef Zlomek <josef.zlomek@itonis.tv>, Mark Nauwelaerts <mnauw@users.sf.net>
class | Codec/Encoder/Video

### Element Pads

name | sink
direction | sink
presence | always
details | video/x-raw, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 16, 2147483647 ], height=(int)[ 16, 2147483647 ], format=(string){ Y444, Y42B, I420, YV12, NV12 }

name | src
direction | source
presence | always
details | video/x-h264, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], stream-format=(string){ avc, byte-stream }, alignment=(string)au, profile=(string){ high-4:4:4, high-4:2:2, high-10, high, main, baseline, constrained-baseline, high-4:4:4-intra, high-4:2:2-intra, high-10-intra }

## Functions

## Types and Values

### struct GstX264Enc

    struct GstX264Enc;

## Property Details

### The `“analyse”` property

      “analyse”                  GstX264EncAnalyse

Partitions to consider.

Flags: Read / Write

### The `“aud”` property

      “aud”                      gboolean

Use AU (Access Unit) delimiter.

Flags: Read / Write

Default value: TRUE

### The `“b-adapt”` property

      “b-adapt”                  gboolean

Automatically decide how many B-frames to use.

Flags: Read / Write

Default value: TRUE

### The `“b-pyramid”` property

      “b-pyramid”                gboolean

Keep some B-frames as references.

Flags: Read / Write

Default value: FALSE

### The `“bframes”` property

      “bframes”                  guint

Number of B-frames between I and P.

Flags: Read / Write

Allowed values: <= 16

Default value: 0

### The `“bitrate”` property

      “bitrate”                  guint

Bitrate in kbit/sec.

Flags: Read / Write

Allowed values: [1,2048000]

Default value: 2048

### The `“byte-stream”` property

      “byte-stream”              gboolean

Generate byte stream format of NALU.

Flags: Read / Write

Default value: FALSE

### The `“cabac”` property

      “cabac”                    gboolean

Enable CABAC entropy coding.

Flags: Read / Write

Default value: TRUE

### The `“dct8x8”` property

      “dct8x8”                   gboolean

Adaptive spatial transform size.

Flags: Read / Write

Default value: FALSE

### The `“interlaced”` property

      “interlaced”               gboolean

Interlaced material.

Flags: Read / Write

Default value: FALSE

### The `“ip-factor”` property

      “ip-factor”                gfloat

Quantizer factor between I- and P-frames.

Flags: Read / Write

Allowed values: [0,2]

Default value: 1.4

### The `“key-int-max”` property

      “key-int-max”              guint

Maximal distance between two key-frames (0 for automatic).

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 0

### The `“me”` property

      “me”                       GstX264EncMe

Integer pixel motion estimation method.

Flags: Read / Write

Default value: hex

### The `“multipass-cache-file”` property

      “multipass-cache-file”     gchar *

Filename for multipass cache file.

Flags: Read / Write

Default value: "x264.log"

### The `“noise-reduction”` property

      “noise-reduction”          guint

Noise reduction strength.

Flags: Read / Write

Allowed values: <= 100000

Default value: 0

### The `“pass”` property

      “pass”                     GstX264EncPass

Encoding pass/type.

Flags: Read / Write

Default value: Constant Bitrate Encoding

### The `“pb-factor”` property

      “pb-factor”                gfloat

Quantizer factor between P- and B-frames.

Flags: Read / Write

Allowed values: [0,2]

Default value: 1.3

### The `“qp-max”` property

      “qp-max”                   guint

Maximum quantizer.

Flags: Read / Write

Allowed values: <= 51

Default value: 51

### The `“qp-min”` property

      “qp-min”                   guint

Minimum quantizer.

Flags: Read / Write

Allowed values: <= 51

Default value: 10

### The `“qp-step”` property

      “qp-step”                  guint

Maximum quantizer difference between frames.

Flags: Read / Write

Allowed values: <= 50

Default value: 4

### The `“quantizer”` property

      “quantizer”                guint

Constant quantizer or quality to apply.

Flags: Read / Write

Allowed values: <= 50

Default value: 21

### The `“ref”` property

      “ref”                      guint

Number of reference frames.

Flags: Read / Write

Allowed values: [1,12]

Default value: 1

### The `“sps-id”` property

      “sps-id”                   guint

SPS and PPS ID number.

Flags: Read / Write

Allowed values: <= 31

Default value: 0

### The `“stats-file”` property

      “stats-file”               gchar *

Filename for multipass statistics (deprecated, use multipass-cache-file).

Flags: Read / Write

Default value: "x264.log"

### The `“subme”` property

      “subme”                    guint

Subpixel motion estimation and partition decision quality: 1=fast, 10=best.

Flags: Read / Write

Allowed values: [1,10]

Default value: 1

### The `“threads”` property

      “threads”                  guint

Number of threads used by the codec (0 for automatic).

Flags: Read / Write

Allowed values: <= G_MAXINT

Default value: 0

### The `“trellis”` property

      “trellis”                  gboolean

Enable trellis searched quantization.

Flags: Read / Write

Default value: TRUE

### The `“vbv-buf-capacity”` property

      “vbv-buf-capacity”         guint

Size of the VBV buffer in milliseconds.

Flags: Read / Write

Allowed values: <= 10000

Default value: 600

### The `“weightb”` property

      “weightb”                  gboolean

Weighted prediction for B-frames.

Flags: Read / Write

Default value: FALSE

### The `“intra-refresh”` property

      “intra-refresh”            gboolean

Use Periodic Intra Refresh instead of IDR frames.

Flags: Read / Write

Default value: FALSE

### The `“mb-tree”` property

      “mb-tree”                  gboolean

Macroblock-Tree ratecontrol.

Flags: Read / Write

Default value: TRUE

### The `“rc-lookahead”` property

      “rc-lookahead”             gint

Number of frames for frametype lookahead.

Flags: Read / Write

Allowed values: [0,250]

Default value: 40

### The `“sliced-threads”` property

      “sliced-threads”           gboolean

Low latency but lower efficiency threading.

Flags: Read / Write

Default value: FALSE

### The `“sync-lookahead”` property

      “sync-lookahead”           gint

Number of buffer frames for threaded lookahead (-1 for automatic).

Flags: Read / Write

Allowed values: [G_MAXULONG,250]

Default value: -1

### The `“option-string”` property

      “option-string”            gchar *

String of x264 options (overridden by element properties) in the format "key1=value1:key2=value2".

Flags: Read / Write

Default value: ""

### The `“profile”` property

      “profile”                  GstX264EncProfile

Apply restrictions to meet H.264 Profile constraints. This will override other properties if necessary. This will only be used if downstream elements do not specify a profile in their caps (DEPRECATED).

Flags: Read / Write

Default value: main

### The `“psy-tune”` property

      “psy-tune”                 GstX264EncPsyTune

Preset name for psychovisual tuning options.

Flags: Read / Write

Default value: No tuning

### The `“speed-preset”` property

      “speed-preset”             GstX264EncPreset

Preset name for speed/quality tradeoff options (can affect decode compatibility - impose restrictions separately for your target decoder).

Flags: Read / Write

Default value: medium

### The `“tune”` property

      “tune”                     GstX264EncTune

Preset name for non-psychovisual tuning options.

Flags: Read / Write

### The `“frame-packing”` property

      “frame-packing”            GstX264EncFramePacking

Set frame packing mode for Stereoscopic content.

Flags: Read / Write

Default value: Automatic (use incoming video information)

### The `“insert-vui”` property

      “insert-vui”               gboolean

Insert VUI NAL in stream.

Flags: Read / Write

Default value: TRUE

## See Also

faac