Membrane.MP3.Lame.Encoder (Membrane MP3 Lame Plugin v0.18.6)

View Source

Element encoding raw audio into MPEG-1, layer 3 format

Element options

Passed via struct Membrane.MP3.Lame.Encoder.t/0

  • gapless_flush

    boolean()

    Default value: true
    When this option is set to true, encoder will be flushed without outputting any tags and allowing to play such file gaplessly if concatenated with another file.

  • bitrate

    pos_integer() | nil

    Default value: nil
    Deprecated: pass the bitrate via the rate_control option instead, e.g. rate_control: {:cbr, bitrate: 192}.

    Output bitrate of encoded stream in kbit/sec, defaults to 192.

  • quality

    non_neg_integer()

    Default value: 5
    Value of this parameter affects quality by selecting one of the algorithms for encoding: 0 being best (and very slow) and 9 being worst.

    Recommended values:

    • 2 - near-best quality, not too slow
    • 5 - good quality, fast
    • 7 - ok quality, really fast
  • disable_reservoir

    boolean()

    Default value: false
    When set to true, disables the LAME bit reservoir. This makes each MP3 frame self-contained (main_data_begin is always 0), so frames can be cleanly spliced at any boundary without decoder artifacts.

    Useful for live streaming with ad insertion where audio from different sources is concatenated.

  • rate_control

    :cbr | {:cbr, bitrate: pos_integer()} | {:vbr, vbr_config()}

    Default value: :cbr
    Rate control mode for the encoder:

    • :cbr - Constant Bitrate at the default bitrate (192 kbps).
    • {:cbr, bitrate: kbps} - Constant Bitrate at the given bitrate.
    • {:vbr, config} - Variable Bitrate. See vbr_config/0 for details.

Pads

:input

Accepted formats:

%RawAudio{sample_format: :s32le, sample_rate: 44100, channels: 2}
Membrane.RemoteStream
Direction::input
Availability::always
Flow control::auto

:output

Accepted formats:

%MPEGAudio{channels: 2, sample_rate: 44100, layer: :layer3, version: :v1}
Direction::output
Availability::always
Flow control::auto

Summary

Types

t()

Struct containing options for Membrane.MP3.Lame.Encoder

VBR configuration for the rate_control option.

Functions

Returns description of options available for this module

Types

t()

@type t() :: %Membrane.MP3.Lame.Encoder{
  bitrate: pos_integer() | nil,
  disable_reservoir: boolean(),
  gapless_flush: boolean(),
  quality: non_neg_integer(),
  rate_control:
    :cbr | {:cbr, [{:bitrate, pos_integer()}]} | {:vbr, vbr_config()}
}

Struct containing options for Membrane.MP3.Lame.Encoder

vbr_config()

@type vbr_config() :: [
  mode: :mt | :rh | :abr | :mtrh | :default,
  mean_bitrate: pos_integer(),
  quality: number(),
  min_bitrate: pos_integer(),
  max_bitrate: pos_integer(),
  hard_min: boolean()
]

VBR configuration for the rate_control option.

For details, see Lame's header file: https://sourceforge.net/p/lame/svn/HEAD/tree/trunk/lame/include/lame.h

Available options:

  • :mode (required) - Sets the algorithm via lame_set_VBR.
  • :mean_bitrate (required for :abr, not allowed otherwise) - target average bitrate in kbps. Calls lame_set_VBR_mean_bitrate_kbps.
  • :quality (only for :rh, :mt, :mtrh, :default) - VBR quality level as a number in [0, 10) (0 = best, 9 = worst). Calls lame_set_VBR_quality, which accepts fractional values for finer-grained control. If omitted, LAME's default is used.
  • :min_bitrate - minimum allowed bitrate in kbps. See lame_set_VBR_min_bitrate_kbps for reference.
  • :max_bitrate - maximum allowed bitrate in kbps. Calls lame_set_VBR_max_bitrate_kbps.
  • :hard_min (boolean) - strictly enforce :min_bitrate even for silence. Calls lame_set_VBR_hard_min.

Functions

options()

@spec options() :: keyword()

Returns description of options available for this module