Transcoder

The Transcoder class provides functionality for audio and video encoding, decoding, and transforming.

Classes

Transcoder

class avblocks.Transcoder

Bases: Block

Provides functionality for audio and video encoding, decoding and transforming.

property allow_demo_mode: bool

Specifies whether the Transcoder allows demo mode (unlicensed transcoding).

If True a demo watermark is applied when a required feature (codec/format) is not licensed. If False the Transcoder returns an error instead of applying the demo watermark.

property auto_connect: bool

Specifies whether the Transcoder automatically connects input to output pins when opened.

Only pins that have their connection property equal to PinConnection.Auto participate in the automatic connection.

close()

Closes the Transcoder. When closed it can neither accept, nor deliver data.

inputs and outputs are not modified.

dispose()

Disposes the Transcoder and reclaims the resources used by the object.

end_of_stream(input_index: int) bool

Tells the Transcoder that there’s no more data for the specified input socket.

Parameters:

input_index – Specifies the index of the input socket for which there’s no more data.

Returns:

True if the operation is successful; otherwise False.

property error: ErrorInfo | None

The error information for the last transcoder operation.

flush() bool

Flushes the data buffered in the Transcoder to the output.

Returns:

True if the buffered data is successfully flushed; otherwise False.

property inputs: MediaSocketList

A modifiable collection of MediaSocket objects which describe the input data of the Transcoder.

Each socket in the collection represents an input point - it can be a container with one or more streams or just an elementary stream.

The default value of this property is an empty collection which can be modified but it cannot be replaced.

open() bool

Initializes the Transcoder based on the specified input and desired output.

Returns:

True if the Transcoder is successfully initialized and is ready to process data; otherwise False.

property outputs: MediaSocketList

A modifiable collection of MediaSocket objects which describe the output data of the Transcoder.

Each socket in the collection describes an output point - it can be a container with one or more streams or just an elementary stream.

The default value of this property is an empty collection which can be modified but it cannot be replaced.

pull(output_sample: MediaSample) Tuple[bool, int]

Pulls output data from the Transcoder.

Parameters:

output_sample – The MediaSample object receives the output data in the buffer property.

Returns:

  • success: True if the Transcoder has successfully generated output, otherwise False.

  • output_index: The index of the output socket to which the data belongs.

Return type:

A tuple of (success, output_index) where

pull_unmanaged(output_sample: MediaSample) Tuple[bool, int]

Pulls output data from the Transcoder.

Parameters:

output_sample – The MediaSample object receives the output data in the unmanaged_buffer property.

Returns:

  • success: True if the Transcoder has successfully generated output, otherwise False.

  • output_index: The index of the output socket to which the data belongs.

Return type:

A tuple of (success, output_index) where

push(input_index: int, input_sample: MediaSample | None) bool

Pushes input data to the Transcoder.

Parameters:
  • input_index – Specifies the index of the input socket whose data is pushed to the Transcoder.

  • input_sample – A MediaSample object that contains the input data in the buffer property.

Returns:

True when the Transcoder has successfully processed some or all of the input data, otherwise False.

push_unmanaged(input_index: int, input_sample: MediaSample | None) bool

Pushes input data to the Transcoder.

Parameters:
  • input_index – Specifies the index of the input socket whose data is pushed to the Transcoder.

  • input_sample – A MediaSample object that contains the input data in the unmanaged_buffer property.

Returns:

True when the Transcoder has successfully processed some or all of the input data, otherwise False.

run() bool

Runs an automatic transcoding.

Returns:

True when the transcoding has succeeded. False when there’s a transcoding error or the run() method cannot be used with the specified inputs and outputs.

TranscoderProgressEventArgs

class avblocks.TranscoderProgressEventArgs(current_time: float, total_time: float)

Bases: object

Contains the parameters of the on_progress event.

TranscoderStatusEventArgs

class avblocks.TranscoderStatusEventArgs(status: TranscoderStatus)

Bases: object

Contains the parameters of the on_status event.

TranscoderContinueEventArgs

class avblocks.TranscoderContinueEventArgs(current_time: float)

Bases: object

Contains the parameters of the on_continue event.

TranscoderInputChangeEventArgs

class avblocks.TranscoderInputChangeEventArgs(input_index: int)

Bases: object

Contains the parameters of the on_input_change event.