mpeg2enc

This element encodes raw video into an MPEG-1/2 elementary stream using the mjpegtools library.

Documentation on MPEG encoding in general can be found in the MJPEG Howto and on the various available parameters in the documentation of the mpeg2enc tool in particular, which shares options with this element.

Example pipeline

 gst-launch-1.0 videotestsrc num-buffers=1000 ! mpeg2enc ! filesink location=videotestsrc.m1v

This example pipeline will encode a test video source to a an MPEG1 elementary stream (with Generic MPEG1 profile).

Likely, the format property is most important, as it selects the type of MPEG stream that is produced. In particular, default property values are dependent on the format, and can even be forcibly restrained to certain pre-sets (and thereby ignored). Note that the (S)VCD profiles also restrict the image size, so some scaling may be needed to accommodate this. The so-called generic profiles (as used in the example above) allow most parameters to be adjusted.

 gst-launch-1.0 videotestsrc num-buffers=1000 ! videoscale ! mpeg2enc format=1 norm=p ! filesink location=videotestsrc.m1v

This will produce an MPEG1 profile stream according to VCD2.0 specifications for PAL norm (as the image height is dependent on video norm).

Hierarchy

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──GstVideoEncoder
                    ╰──mpeg2enc

Implemented interfaces

Factory details

Authors: – Andrew Stevens , Ronald Bultje

Classification:Codec/Encoder/Video

Rank – marginal

Plugin – mpeg2enc

Package – GStreamer Bad Plug-ins

Pad Templates

sink

video/x-raw:
         format: I420
          width: [ 16, 4096 ]
         height: [ 16, 4096 ]
      framerate: { (fraction)24000/1001, (fraction)24/1, (fraction)25/1, (fraction)30000/1001, (fraction)30/1, (fraction)50/1, (fraction)60000/1001 }

Presencealways

Directionsink

Object typeGstPad


src

video/mpeg:
   systemstream: false
    mpegversion: { (int)1, (int)2 }
          width: [ 16, 4096 ]
         height: [ 16, 4096 ]
      framerate: { (fraction)24000/1001, (fraction)24/1, (fraction)25/1, (fraction)30000/1001, (fraction)30/1, (fraction)50/1, (fraction)60000/1001 }

Presencealways

Directionsrc

Object typeGstPad


Properties

altscan-mpeg2

“altscan-mpeg2” gboolean

Alternate MPEG-2 block scanning. Disabling this might make buggy players play SVCD streams

Flags : Read / Write

Default value : true


aspect

“aspect” GstMpeg2encAspect *

Display aspect ratio

Flags : Read / Write

Default value : 0 (0)


b-per-refframe

“b-per-refframe” gint

Number of B frames between each I/P frame

Flags : Read / Write

Default value : 0


bitrate

“bitrate” gint

Compressed video bitrate (kbps)

Flags : Read / Write

Default value : 1125


bufsize

“bufsize” gint

Target decoders video buffer size (kB) (default depends on format)

Flags : Read / Write

Default value : 0


closed-gop

“closed-gop” gboolean

All Group-of-Pictures are closed (for multi-angle DVDs)

Flags : Read / Write

Default value : false


constraints

“constraints” gboolean

Use strict video resolution and bitrate checks

Flags : Read / Write

Default value : true


correct-svcd-hds

“correct-svcd-hds” gboolean

Force SVCD width to 480 instead of 540/720

Flags : Read / Write

Default value : false


disable-encode-retries

“disable-encode-retries” gboolean

Prevent the encoder from reencoding pictures in a second pass.

This can vastly improve performance, but potentially affect reaching bitrate targets.

See https://sourceforge.net/p/mjpeg/bugs/141/ for some background.

Flags : Read / Write

Default value : false

Since : 1.18


dualprime

“dualprime” gboolean

Dual Prime Motion Estimation Mode for MPEG-2 I/P-frame only streams. Quite some players do not support this.

Flags : Read / Write

Default value : false


dummy-svcd-sof

“dummy-svcd-sof” gboolean

Generate dummy SVCD scan-data (for vcdimager)

Flags : Read / Write

Default value : true


force-b-b-p

“force-b-b-p” gboolean

Force two B frames between I/P frames when closing GOP boundaries

Flags : Read / Write

Default value : false


format

“format” GstMpeg2encFormat *

Encoding profile format

Flags : Read / Write

Default value : 0 (0)


framerate

“framerate” GstMpeg2encFramerate *

Output framerate

Flags : Read / Write

Default value : 0 (0)


interlace-mode

“interlace-mode” GstMpeg2encInterlaceMode *

MPEG-2 motion estimation and encoding modes

Flags : Read / Write

Default value : -1 (-1)


intra-dc-prec

“intra-dc-prec” gint

Number of bits precision for DC (base colour) in MPEG-2 blocks

Flags : Read / Write

Default value : 9


keep-hf

“keep-hf” gboolean

Maximize high-frequency resolution (for high-quality sources)

Flags : Read / Write

Default value : false


max-gop-size

“max-gop-size” gint

Maximal size per Group-of-Pictures (-1=default)

Flags : Read / Write

Default value : -1


min-gop-size

“min-gop-size” gint

Minimal size per Group-of-Pictures (-1=default)

Flags : Read / Write

Default value : -1


motion-search-radius

“motion-search-radius” gint

Motion compensation search radius

Flags : Read / Write

Default value : 0


non-video-bitrate

“non-video-bitrate” gint

Assumed bitrate of non-video for sequence splitting (kbps)

Flags : Read / Write

Default value : 0


norm

“norm” GstMpeg2encVideoNorm *

Tag output for specific video norm

Flags : Read / Write

Default value : 0 (0)


playback-field-order

“playback-field-order” GstMpeg2encPlaybackFieldOrders *

Force specific playback field order

Flags : Read / Write

Default value : 0 (-1)


pulldown-3-2

“pulldown-3-2” gboolean

Generate header flags for 3-2 pull down 24fps movies

Flags : Read / Write

Default value : false


quant-matrix

“quant-matrix” GstMpeg2encQuantisationMatrix *

Quantisation matrix to use for encoding

Flags : Read / Write

Default value : 9 (0)


quant-reduction-max-var

“quant-reduction-max-var” gfloat

Maximal luma variance below which quantisation boost is used

Flags : Read / Write

Default value : 100


quantisation

“quantisation” gint

Quantisation factor (-1=cbr, 0=default, 1=best, 31=worst)

Flags : Read / Write

Default value : 0


quantisation-reduction

“quantisation-reduction” gfloat

Max. quantisation reduction for highly active blocks

Flags : Read / Write

Default value : 0


reduce-hf

“reduce-hf” gfloat

How much to reduce high-frequency resolution (by increasing quantisation)

Flags : Read / Write

Default value : 0


reduction-2x2

“reduction-2x2” gint

Reduction factor for 2x2 subsampled candidate motion estimates (1=max. quality, 4=max. speed)

Flags : Read / Write

Default value : 3


reduction-4x4

“reduction-4x4” gint

Reduction factor for 4x4 subsampled candidate motion estimates (1=max. quality, 4=max. speed)

Flags : Read / Write

Default value : 2


sequence-header-every-gop

“sequence-header-every-gop” gboolean

Include a sequence header in every GOP

Flags : Read / Write

Default value : false


sequence-length

“sequence-length” gint

Place a sequence boundary after each MB (0=disable)

Flags : Read / Write

Default value : 0


unit-coeff-elim

“unit-coeff-elim” gint

How aggressively small-unit picture blocks should be skipped

Flags : Read / Write

Default value : 0


vcd-still-size

“vcd-still-size” gint

Size of VCD stills (in KB)

Flags : Read / Write

Default value : 0


Named constants

GstMpeg2encAspect

Members

0 (0) – Deduce from input
1 (1) – 1:1
2 (2) – 4:3
3 (3) – 16:9
4 (4) – 2.21:1

GstMpeg2encFormat

Members

0 (0) – Generic MPEG-1
1 (1) – Standard VCD
2 (2) – User VCD
3 (3) – Generic MPEG-2
4 (4) – Standard SVCD
5 (5) – User SVCD
6 (6) – VCD Stills sequences
7 (7) – SVCD Stills sequences
8 (8) – DVD MPEG-2 for dvdauthor
9 (9) – DVD MPEG-2
10 (10) – ATSC 480i
11 (11) – ATSC 480p
12 (12) – ATSC 720p
13 (13) – ATSC 1080i

GstMpeg2encFramerate

Members

0 (0) – Same as input
1 (1) – 24/1.001 (NTSC 3:2 pulldown converted film)
2 (2) – 24 (native film)
3 (3) – 25 (PAL/SECAM video)
4 (4) – 30/1.001 (NTSC video)
5 (5) – 30
6 (6) – 50 (PAL/SECAM fields)
7 (7) – 60/1.001 (NTSC fields)
8 (8) – 60

GstMpeg2encInterlaceMode

Members

-1 (-1) – Format default mode
0 (0) – Progressive
1 (1) – Interlaced, per-frame encoding
2 (2) – Interlaced, per-field-encoding

GstMpeg2encPlaybackFieldOrders

Members

0 (-1) – Unspecified
1 (1) – Top-field first
2 (2) – Bottom-field first

GstMpeg2encQuantisationMatrix

Members

9 (0) – Default
1 (1) – High resolution
2 (2) – KVCD
3 (3) – TMPGEnc

GstMpeg2encVideoNorm

Members

0 (0) – Unspecified
p (112) – PAL
n (110) – NTSC
s (115) – SECAM

The results of the search are