Module Avutil.Audio

Audio frames. The timestamps and the metadata are in Frame; the samples are read and written through the resampling library.

val create_frame : Sample_format.t -> Channel_layout.t -> int -> int -> audio frame

create_frame sample_format channel_layout sample_rate nb_samples returns a new audio frame with that sample format, a copy of that channel layout, that sample rate in Hz, and buffers allocated by FFmpeg for nb_samples samples per channel. The sample data is unspecified.

  • raises Error

    with `Failure when nb_samples is below 1, or when sample_rate or nb_samples exceeds a C int.

val frame_get_sample_format : audio frame -> Sample_format.t

The sample format of the frame.

  • raises Error

    with `Failure when the frame has a format this build has no constructor for.

val frame_get_sample_rate : audio frame -> int

The sample rate of the frame, in Hz.

val frame_get_channels : audio frame -> int

The number of channels of the frame's channel layout.

val frame_get_channel_layout : audio frame -> Channel_layout.t

A copy of the frame's channel layout, independent of the frame.

val frame_nb_samples : audio frame -> int

The number of samples per channel the frame holds.

type frame_format = {
  1. sample_format : Sample_format.t;
  2. sample_rate : int;
  3. channel_layout : Channel_layout.t;
}

What a consumer of audio frames is configured for: a frame whose format differs from the one before needs that consumer set up again.

val frame_format : audio frame -> frame_format

The format of the frame.

val same_frame_format : frame_format -> frame_format -> bool

Whether two formats are the same. Channel layouts are compared with Channel_layout.compare.