Membrane AAC FDK plugin View Source

Hex.pm API Docs CircleCI

AAC decoder and encoder based on FDK library.

It is part of Membrane Multimedia Framework.

The docs can be found at HexDocs.

Installation

The package can be installed by adding membrane_aac_fdk_plugin to your list of dependencies in mix.exs:

def deps do
  [
    {:membrane_aac_fdk_plugin, "~> 0.9.0"}
  ]
end

This package depends on FDK-AAC library.

Ubuntu

(Make sure you have Multiverse repository enabled. See: https://help.ubuntu.com/community/Repositories/Ubuntu)

sudo apt-get install libfdk-aac-dev

Arch/Manjaro

pacman -S libfdk-aac

MacOS

brew install fdk-aac

Usage

Encoder

The following pipeline takes wav file as input and encodes it as AAC.

defmodule AAC.Pipeline do
  use Membrane.Pipeline

  @impl true
  def handle_init(_) do
    children = [
      source: %Membrane.File.Source{location: "input.wav"},
      parser: Membrane.WAV.Parser,
      aac_encoder: Membrane.AAC.FDK.Encoder,
      sink: %Membrane.File.Sink{location: "output.aac"}
    ]

    links = [
      link(:source)
      |> to(:parser)
      |> to(:aac_encoder)
      |> to(:sink)
    ]

    {{:ok, spec: %ParentSpec{children: children, links: links}}, %{}}
  end
end

Decoder

The following pipeline takes AAC file as input and plays it on speakers.

defmodule AAC.Pipeline do
  use Membrane.Pipeline

  @impl true
  def handle_init(_) do
    children = [
      source: %Membrane.File.Source{location: "input.aac"},
      aac_decoder: Membrane.AAC.FDK.Decoder,
      converter: %Membrane.FFmpeg.SWResample.Converter{
        output_caps: %Membrane.Caps.Audio.Raw{
          format: :s16le,
          sample_rate: 48000,
          channels: 2
        }
      },
      sink: Membrane.PortAudio.Sink
    ]

    links = [
      link(:source)
      |> to(:aac_decoder)
      |> to(:converter)
      |> to(:sink)
    ]

    {{:ok, spec: %ParentSpec{children: children, links: links}}, %{}}
  end
end

Copyright 2018, Software Mansion

Software Mansion

Licensed under the Apache License, Version 2.0