Skip to main content

Class: MediaProcessor

Media processor class holding and running insertable streams pipeline. The class should be created on the proper thread. Options are:

  • Application main thread when media processing wants to be performed in the main thread.
  • Worker thread when media processing wants to be performed in a Web worker thread.

Hierarchy

Implements

Constructors

constructor

new MediaProcessor()

Overrides

Emittery<EventDataMap\>.constructor

Methods

setTrackExpectedRate

setTrackExpectedRate(trackExpectedRate): void

Sets the expected rate of the track per second. The media processor will use this number for calculating drops in the rate. This could happen when the transformation will take more time than expected. This will not cause an error, just warning to the client. Mostly: Video: 30 frames per second Audio: 50 audio data per second for OPUS In case of increased frame dropping rate a warning will be emitted according to info here. This is an optional method.

Parameters

NameTypeDescription
trackExpectedRatenumbernumber holds the predicted track rate.

Returns

void


transform

transform(readable, writable): Promise<void>

Starts running the tranformation logic performed by the media processor instance. When running an instance of this class on a Web worker thread the call for this function should be made by the user. See example here. When running an instance of this class on the application main thread there is no need to call this method given it will be called by the MediaProcessorConnector instance.

Parameters

NameTypeDescription
readableReadableStream<any>Readable stream associated to the media source being processed.
writableWritableStream<any>Writable stream associated to the resulting media once processed.

Returns

Promise<void>

Implementation of

MediaProcessorInterface.transform


setTransformers

setTransformers(transformers): Promise<void>

Sets an array of transfromer instances that will be hold and ran by the media processor instance. See example here

Parameters

NameTypeDescription
transformersTransformer<any, any>[]An array of transformer instances.

Returns

Promise<void>


destroy

destroy(): Promise<void>

Stops running the tranformation logic performed by the media processor instance.

Returns

Promise<void>

Implementation of

MediaProcessorInterface.destroy