GstVideoEncoder

This base class is for video encoders turning raw video into encoded video data.

GstVideoEncoder and subclass should cooperate as follows.

Configuration

  • Initially, GstVideoEncoder calls @start when the encoder element is activated, which allows subclass to perform any global setup.
  • GstVideoEncoder calls @set_format to inform subclass of the format of input video data that it is about to receive. Subclass should setup for encoding and configure base class as appropriate (e.g. latency). While unlikely, it might be called more than once, if changing input parameters require reconfiguration. Baseclass will ensure that processing of current configuration is finished.
  • GstVideoEncoder calls @stop at end of all processing.

Data processing

  • Base class collects input data and metadata into a frame and hands this to subclass' @handle_frame.
  • If codec processing results in encoded data, subclass should call @gst_video_encoder_finish_frame to have encoded data pushed downstream.
  • If implemented, baseclass calls subclass @pre_push just prior to pushing to allow subclasses to modify some metadata on the buffer. If it returns GST_FLOW_OK, the buffer is pushed downstream.
  • GstVideoEncoderClass will handle both srcpad and sinkpad events. Sink events will be passed to subclass if @event callback has been provided.

Shutdown phase

  • GstVideoEncoder class calls @stop to inform the subclass that data parsing will be stopped.

Subclass is responsible for providing pad template caps for source and sink pads. The pads need to be named "sink" and "src". It should also be able to provide fixed src pad caps in @getcaps by the time it calls @gst_video_encoder_finish_frame.

Things that subclass need to take care of:

  • Provide pad templates
  • Provide source pad caps before pushing the first buffer
  • Accept data in @handle_frame and provide encoded results to @gst_video_encoder_finish_frame.

Members

Variables

element
GstElement element;
inputSegment
GstSegment inputSegment;
outputSegment
GstSegment outputSegment;
padding
void*[20] padding;
priv
GstVideoEncoderPrivate* priv;
sinkpad
GstPad* sinkpad;
srcpad
GstPad* srcpad;
streamLock
GRecMutex streamLock;

Detailed Description

The #GstVideoEncoder:qos property will enable the Quality-of-Service features of the encoder which gather statistics about the real-time performance of the downstream elements. If enabled, subclasses can use gstvideo.video_encoder.VideoEncoder.getMaxEncodeTime to check if input frames are already late and drop them right away to give a chance to the pipeline to catch up.