spdl.io.AudioEncoder¶
- class AudioEncoder[source]¶
Audio encoder.
Returned by
Muxer.add_encode_stream().Methods
encode(frames)Encode audio frames.
flush()Notify the encoder of the end of the stream and fetch the buffered packets.
Attributes
The number of frames that the internal encoder can handle at a time.
- encode(frames: AudioFrames) AudioPackets | None[source]¶
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() AudioPackets | None[source]¶
Notify the encoder of the end of the stream and fetch the buffered packets.
- property frame_size: int[source]¶
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.