Skip to content

Liferenko/membrane_aac_fdk_plugin

 
 

Repository files navigation

Membrane AAC FDK plugin

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.18.7"}
  ]
end

This package depends on the FDK-AAC library. The precompiled build will be pulled and linked automatically. However, should there be any problems, consider installing it manually.

Manual instalation of dependencies

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.

Mix.install([:membrane_file_plugin, :membrane_wav_plugin, :membrane_aac_fdk_plugin])

defmodule AAC.Pipeline do
  use Membrane.Pipeline

  @impl true
  def handle_init(_ctx, _opts) do
    structure = 
      child(:source, %Membrane.File.Source{location: "input.wav"})
      |> child(:parser, Membrane.WAV.Parser)
      |> child(:aac_encoder, Membrane.AAC.FDK.Encoder)
      |> child(:sink, %Membrane.File.Sink{location: "output.aac"})

    {[spec: structure, playback: :playing], %{}}
  end
end

{:ok, _pipeline_supervisor, _pipeline} = AAC.Pipeline.start_link([])

Decoder

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

Mix.install([
  :membrane_file_plugin,
  :membrane_ffmpeg_swresample_plugin,
  :membrane_aac_fdk_plugin, 
  :membrane_portaudio_plugin
])

defmodule AAC.Pipeline do
  use Membrane.Pipeline

  @impl true
  def handle_init(_ctx, _opts) do
    structure =
      child(:source, %Membrane.File.Source{location: "input.aac"})
      |> child(:aac_decoder, Membrane.AAC.FDK.Decoder)
      |> child(:converter, %Membrane.FFmpeg.SWResample.Converter{
        output_stream_format: %Membrane.RawAudio{
          sample_format: :s16le,
          sample_rate: 48000,
          channels: 2
        }
      })
      |> child(:sink, Membrane.PortAudio.Sink)

    {[spec: structure, playback: :playing], %{}}
  end
end

{:ok, _pipeline_supervisor, _pipeline} = AAC.Pipeline.start_link([])

Copyright and License

Copyright 2018, Software Mansion

Software Mansion

Licensed under the Apache License, Version 2.0

About

Membrane AAC decoder and encoder based on FDK library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 75.0%
  • C 25.0%