x264enc

x264enc — H264 Encoder

Synopsis

                    GstX264Enc;

Object Hierarchy

  GObject
   +----GstObject
         +----GstElement
               +----GstX264Enc

Implemented Interfaces

GstX264Enc implements GstPreset.

Properties

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

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.

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. No 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.

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.

Note

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.

Example pipeline

1
2
gst-launch -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.
1
2
gst-launch -v videotestsrc num-buffers=1000 ! x264enc pass=quant ! \
  matroskamux ! filesink location=videotestsrc.avi
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 -v videotestsrc num-buffers=1000 ! x264enc pass=5 quantizer=25 speed-preset=6 profile=1 ! \
  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 -v videotestsrc num-buffers=1000 ! tee name=t ! queue ! xvimagesink \
  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.

Details

GstX264Enc

typedef struct _GstX264Enc GstX264Enc;

Property Details

The "analyse" property

  "analyse"                  GstX264EncAnalyse     : Read / Write

Partitions to consider.


The "aud" property

  "aud"                      gboolean              : Read / Write

Use AU (Access Unit) delimiter.

Default value: TRUE


The "b-adapt" property

  "b-adapt"                  gboolean              : Read / Write

Automatically decide how many B-frames to use.

Default value: TRUE


The "b-pyramid" property

  "b-pyramid"                gboolean              : Read / Write

Keep some B-frames as references.

Default value: FALSE


The "bframes" property

  "bframes"                  guint                 : Read / Write

Number of B-frames between I and P.

Allowed values: <= 4

Default value: 0


The "bitrate" property

  "bitrate"                  guint                 : Read / Write

Bitrate in kbit/sec.

Allowed values: [1,102400]

Default value: 2048


The "byte-stream" property

  "byte-stream"              gboolean              : Read / Write

Generate byte stream format of NALU.

Default value: FALSE


The "cabac" property

  "cabac"                    gboolean              : Read / Write

Enable CABAC entropy coding.

Default value: TRUE


The "dct8x8" property

  "dct8x8"                   gboolean              : Read / Write

Adaptive spatial transform size.

Default value: FALSE


The "interlaced" property

  "interlaced"               gboolean              : Read / Write

Interlaced material.

Default value: FALSE


The "ip-factor" property

  "ip-factor"                gfloat                : Read / Write

Quantizer factor between I- and P-frames.

Allowed values: [0,2]

Default value: 1.4


The "key-int-max" property

  "key-int-max"              guint                 : Read / Write

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

Allowed values: <= G_MAXINT

Default value: 0


The "me" property

  "me"                       GstX264EncMe          : Read / Write

Integer pixel motion estimation method.

Default value: hex


The "multipass-cache-file" property

  "multipass-cache-file"     gchar*                : Read / Write

Filename for multipass cache file.

Default value: "x264.log"


The "noise-reduction" property

  "noise-reduction"          guint                 : Read / Write

Noise reduction strength.

Allowed values: <= 100000

Default value: 0


The "pass" property

  "pass"                     GstX264EncPass        : Read / Write

Encoding pass/type.

Default value: Constant Bitrate Encoding


The "pb-factor" property

  "pb-factor"                gfloat                : Read / Write

Quantizer factor between P- and B-frames.

Allowed values: [0,2]

Default value: 1.3


The "qp-max" property

  "qp-max"                   guint                 : Read / Write

Maximum quantizer.

Allowed values: [1,51]

Default value: 51


The "qp-min" property

  "qp-min"                   guint                 : Read / Write

Minimum quantizer.

Allowed values: [1,51]

Default value: 10


The "qp-step" property

  "qp-step"                  guint                 : Read / Write

Maximum quantizer difference between frames.

Allowed values: [1,50]

Default value: 4


The "quantizer" property

  "quantizer"                guint                 : Read / Write

Constant quantizer or quality to apply.

Allowed values: [1,50]

Default value: 21


The "ref" property

  "ref"                      guint                 : Read / Write

Number of reference frames.

Allowed values: [1,12]

Default value: 1


The "sps-id" property

  "sps-id"                   guint                 : Read / Write

SPS and PPS ID number.

Allowed values: <= 31

Default value: 0


The "stats-file" property

  "stats-file"               gchar*                : Read / Write

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

Default value: "x264.log"


The "subme" property

  "subme"                    guint                 : Read / Write

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

Allowed values: [1,6]

Default value: 1


The "threads" property

  "threads"                  guint                 : Read / Write

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

Allowed values: <= 4

Default value: 0


The "trellis" property

  "trellis"                  gboolean              : Read / Write

Enable trellis searched quantization.

Default value: TRUE


The "vbv-buf-capacity" property

  "vbv-buf-capacity"         guint                 : Read / Write

Size of the VBV buffer in milliseconds.

Allowed values: <= 10000

Default value: 600


The "weightb" property

  "weightb"                  gboolean              : Read / Write

Weighted prediction for B-frames.

Default value: FALSE


The "intra-refresh" property

  "intra-refresh"            gboolean              : Read / Write

Use Periodic Intra Refresh instead of IDR frames.

Default value: FALSE


The "mb-tree" property

  "mb-tree"                  gboolean              : Read / Write

Macroblock-Tree ratecontrol.

Default value: TRUE


The "rc-lookahead" property

  "rc-lookahead"             gint                  : Read / Write

Number of frames for frametype lookahead.

Allowed values: [0,250]

Default value: 40


The "sliced-threads" property

  "sliced-threads"           gboolean              : Read / Write

Low latency but lower efficiency threading.

Default value: FALSE


The "sync-lookahead" property

  "sync-lookahead"           gint                  : Read / Write

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

Allowed values: [G_MAXULONG,250]

Default value: -1


The "option-string" property

  "option-string"            gchar*                : Read / Write

String of x264 options (overridden by element properties).

Default value: ""


The "profile" property

  "profile"                  GstX264EncProfile     : Read / Write

Apply restrictions to meet H.264 Profile constraints. This will override other properties if necessary.

Default value: main


The "psy-tune" property

  "psy-tune"                 GstX264EncPsyTune     : Read / Write

Preset name for psychovisual tuning options.

Default value: No tuning


The "speed-preset" property

  "speed-preset"             GstX264EncPreset      : Read / Write

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

Default value: medium


The "tune" property

  "tune"                     GstX264EncTune        : Read / Write

Preset name for non-psychovisual tuning options.

See Also

faac