spdl.io.AudioEncoder

class AudioEncoder

Audio encoder.

Returned by Muxer.add_encode_stream().

Attributes

encode

Encode audio frames.

flush

Notify the encoder of the end of the stream and fetch the buffered packets.

frame_size

The number of frames that the internal encoder can handle at a time.

encode

Encode audio frames.

Parameters:

frames – Audio frames. Use create_reference_audio_frame() to convert tensor/array objects into frames.

Returns:

Packets objects if encoder generates one.

flush

Notify the encoder of the end of the stream and fetch the buffered packets.

property frame_size

The number of frames that the internal encoder can handle at a time.

Some audio encoders are strict on the number of frames it can handle at a time. In such case, retrieve the number of expected frames (par channel) here, slice data accordingly, then encode slice by slice.