Class VideoEncoder

java.lang.Object
All Implemented Interfaces:
Proxy, Preset
Direct Known Subclasses:
VideoEncoder.VideoEncoderImpl

@Generated("io.github.jwharm.JavaGI") public abstract class VideoEncoder extends Element implements Preset
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 setFormat 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' handleFrame.
  • If codec processing results in encoded data, subclass should call gstVideoEncoderFinishFrame to have encoded data pushed downstream.
  • If implemented, baseclass calls subclass prePush 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 gstVideoEncoderFinishFrame.

Things that subclass need to take care of:

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

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 gst_video_encoder_get_max_encode_time() to check if input frames are already late and drop them right away to give a chance to the pipeline to catch up.