gstvideo.video_encoder
Module for [VideoEncoder] class
Types 3
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.
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.
VideoEncoder self()Returns `this`, for use in `with` statements.VideoEncoderGidBuilder builder()Get builder for [gstvideo.video_encoder.VideoEncoder] Returns: New builder objectulong minForceKeyUnitInterval() @propertyGet `minForceKeyUnitInterval` property. Returns: Minimum interval between force-keyunit requests in nanoseconds. See [gstvideo.video_encoder.VideoEncoder.setMinForceKeyUnitInterval] for more details.void minForceKeyUnitInterval(ulong propval) @propertySet `minForceKeyUnitInterval` property. Params: propval = Minimum interval between force-keyunit requests in nanoseconds. See [gstvideo.video_encoder.VideoEncoder.setMinForceKeyUnitInterval] for mo...bool qos() @propertyvoid qos(bool propval) @propertygst.buffer.Buffer allocateOutputBuffer(size_t size)Helper function that allocates a buffer to hold an encoded video frame for encoder's current #GstVideoCodecState.gst.types.FlowReturn allocateOutputFrame(gstvideo.video_codec_frame.VideoCodecFrame frame, size_t size)Helper function that allocates a buffer to hold an encoded video frame for encoder's current #GstVideoCodecState. Subclass should already have configured video state and set src pad caps.gst.types.FlowReturn finishFrame(gstvideo.video_codec_frame.VideoCodecFrame frame)frame must have a valid encoded data buffer, whose metadata fields are then appropriately set according to frame data or no buffer at all if the frame should be dropped. It is subsequently pushed d...gst.types.FlowReturn finishSubframe(gstvideo.video_codec_frame.VideoCodecFrame frame)If multiple subframes are produced for one input frame then use this method for each subframe, except for the last one. Before calling this function, you need to fill frame->output_buffer with the ...void getAllocator(out gst.allocator.Allocator allocator, out gst.allocation_params.AllocationParams params)Lets #GstVideoEncoder sub-classes to know the memory allocator used by the base class and its params.gstvideo.video_codec_frame.VideoCodecFrame getFrame(int frameNumber)Get a pending unfinished #GstVideoCodecFramegstvideo.video_codec_frame.VideoCodecFrame[] getFrames()Get all pending unfinished #GstVideoCodecFrame Returns: pending unfinished #GstVideoCodecFrame.void getLatency(out gst.types.ClockTime minLatency, out gst.types.ClockTime maxLatency)Query the configured encoding latency. Results will be returned via minlatency and maxlatency.gst.types.ClockTimeDiff getMaxEncodeTime(gstvideo.video_codec_frame.VideoCodecFrame frame)Determines maximum possible encoding time for frame that will allow it to encode and arrive in time (as determined by QoS events). In particular, a negative result means encoding in time is no long...gst.types.ClockTime getMinForceKeyUnitInterval()Returns the minimum force-keyunit interval, see [gstvideo.video_encoder.VideoEncoder.setMinForceKeyUnitInterval] for more details. Returns: the minimum force-keyunit intervalgstvideo.video_codec_frame.VideoCodecFrame getOldestFrame()Get the oldest unfinished pending #GstVideoCodecFrame Returns: oldest unfinished pending #GstVideoCodecFramegstvideo.video_codec_state.VideoCodecState getOutputState()Get the current #GstVideoCodecState Returns: #GstVideoCodecState describing format of video data.bool isQosEnabled()Checks if encoder is currently configured to handle Quality-of-Service events from downstream. Returns: true if the encoder is configured to perform Quality-of-Service.void mergeTags(gst.tag_list.TagList tags, gst.types.TagMergeMode mode)Sets the video encoder tags and how they should be merged with any upstream stream tags. This will override any tags previously-set with [gstvideo.video_encoder.VideoEncoder.mergeTags].bool negotiate()Negotiate with downstream elements to currently configured #GstVideoCodecState. Unmark GSTPADFLAGNEEDRECONFIGURE in any case. But mark it again if negotiate fails. Returns: true if the negotiation ...gst.caps.Caps proxyGetcaps(gst.caps.Caps caps = null, gst.caps.Caps filter = null)Returns caps that express caps (or sink template caps if caps == NULL) restricted to resolution/format/... combinations supported by downstream elements (e.g. muxers).void setLatency(gst.types.ClockTime minLatency, gst.types.ClockTime maxLatency)Informs baseclass of encoding latency. If the provided values changed from previously provided ones, this will also post a LATENCY message on the bus so the pipeline can reconfigure its global late...void setMinForceKeyUnitInterval(gst.types.ClockTime interval)Sets the minimum interval for requesting keyframes based on force-keyunit events. Setting this to 0 will allow to handle every event, setting this to [gst.types.CLOCKTIMENONE] causes force-keyunit ...void setMinPts(gst.types.ClockTime minPts)Request minimal value for PTS passed to handle_frame.gstvideo.video_codec_state.VideoCodecState setOutputState(gst.caps.Caps caps, gstvideo.video_codec_state.VideoCodecState reference = null)Creates a new #GstVideoCodecState with the specified caps as the output state for the encoder. Any previously set output state on encoder will be replaced by the newly created one.void setQosEnabled(bool enabled)Configures encoder to handle Quality-of-Service events from downstream.T minForceKeyUnitInterval(ulong propval)Set `minForceKeyUnitInterval` property. Params: propval = Minimum interval between force-keyunit requests in nanoseconds. See [gstvideo.video_encoder.VideoEncoder.setMinForceKeyUnitInterval] for mo...T qos(bool propval)Fluent builder for [gstvideo.video_encoder.VideoEncoder]