MediaSocket¶
The MediaSocket class represents an input or output point of the Transcoder.
A MediaSocket object describes either a container (WAV, AVI, MP4, etc.) with one or more streams
or simply an elementary stream (MP3, M2V, etc.).
Class¶
- class avblocks.MediaSocket¶
Bases:
IImmutableAn input or output point of the Transcoder.
A MediaSocket object describes either a container (WAV, AVI, MP4, etc.) with one or more streams or simply an elementary stream (MP3, M2V, etc.)
When MediaSocket describes a container the child collection of media pins can contain one or more items (for each contained stream). The socket stream type designates the container type.
When MediaSocket describes an elementary stream the child collection of media pins contains a single item which is the elementary stream itself. The socket stream type is the same as the pin stream type.
- clone() MediaSocket¶
Creates a deep copy of this object.
- Returns:
A new MediaSocket object
- property file: str | None¶
The file associated with the media socket. The default value is None.
- static from_media_info(media_info: MediaInfo) MediaSocket | None¶
Creates a media socket from a MediaInfo object.
- Parameters:
media_info – A MediaInfo object with audio/video information. The object may or may not be loaded before calling this function. This object is not needed after the method returns.
- Returns:
A new MediaSocket object or None. The MediaSocket object contains the information supplied by the media_info parameter. When from_media_info fails, it returns None. In that case use the MediaInfo.error property to get error information.
This method is meant to help in setting correctly the inputs of a Transcoder. The intended usage is as follows: 1. Use MediaInfo to load information for a file or user stream. 2. Create a media socket from the MediaInfo object (MediaSocket.from_media_info(media_info)) 3. Add the newly created socket to the inputs of a Transcoder (transcoder.inputs.add(socket))
- static from_preset(preset: str) MediaSocket | None¶
Creates a media socket from an AVBlocks Preset.
- Parameters:
preset – A constant from the Preset enum
- Returns:
A new MediaSocket object which is configured for the specified preset, or None if the preset is invalid.
This method is meant to help in setting correctly the outputs of the Transcoder. The intended usage is as follows: 1. Create a media socket from a Preset (MediaSocket.from_preset(preset)) 2. Add the newly created socket to the outputs of the Transcoder (transcoder.outputs.add(socket))
- property immutable: bool¶
Returns whether the object is immutable. An immutable object cannot be modified and all modifying methods fail to produce a result.
An immutable object can be modified by the AVBlocks library. Object immutability spreads to all nested objects. Therefore it is not possible to add/set an immutable object to a mutable object. When cloned an immutable object becomes mutable.
- property params: ParameterList¶
A collection of socket parameters. These parameters are used when demuxing the input or multiplexing the output defined by this media socket. The default value of this property is an empty list.
- property pins: MediaPinList¶
A modifiable collection with all the pins (elementary streams) that are defined for this socket.
The default value of this property is an empty collection which can be modified but it cannot be replaced.
- property stream: RawIOBase | None¶
The user stream associated with the media socket. The default value of this property is None.
This is an alternative to the file property. When both a file and a user stream are associated with a socket the Transcoder prefers the user stream.
- property stream_sub_type: int¶
Specifies explicitly the subtype of the associated file or stream. The default value of this property is StreamSubType.Unknown.
- property stream_type: int¶
Specifies explicitly the format of the associated file or stream. The default value of this property is StreamType.Unknown.
- property time_position: float¶
Specifies the position within file / stream (in seconds).
The transcoder tries to seek to the time position before the transcoding operation starts. Seeking is not possible while transcoder is open. The Transcoder needs to be closed before setting a new time position with this property.