Skip to content

Fixed audio chunk size support #405

@Yahweasel

Description

@Yahweasel

(Apologies if this has already been suggested. I couldn't find it.)

Some environments (muxers, protocols) require that each audio chunk contain some fixed number of samples, typically either 20ms worth or the same as some associated video framerate. In FFmpeg terms, this is the "frame size" of the encoder. It would be nice to, for such environments, be able to set a fixed chunk size in AudioEncoder.configure.

I propose adding an optional chunkSize field to AudioEncoderConfig that restricts the chunk sizes produced by the encoder. Ideally, chunkSize could be a ConstrainULong, since it's a restriction on the output rather than a property of the input, and that way a maximum or minimum could be set instead of an exact value. Since sampleRate is optional, chunkSize may need to be in microseconds instead of samples, or alternatively it may be sensible to make chunkSize only valid if sampleRate is provided. Naturally, isConfigSupported should reject the configuration if the audio codec doesn't support the requested frame size.

Alternatively, it could be encoded into the codec string, but it's not a standard part of codec strings in common MIME types (as far as I'm aware), so that would be a deviation from standards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TPAC 2022Issues to discuss in upcoming TPAC meetingextensionInterface changes that extend without breaking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions