Code Monkey home page Code Monkey logo

membrane_opus_plugin's Introduction

Membrane Opus plugin

Hex.pm API Docs CircleCI

Opus encoder and decoder.

It is a part of Membrane Multimedia Framework.

Installation

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

def deps do
  [
    {:membrane_opus_plugin, "~> 0.10.0"}
  ]
end

This package depends on libopus library.

Ubuntu

sudo apt-get install libopus-dev

Arch/Manjaro

pacman -S opus

MacOS

brew install opus

Usage example

Encoder

Encode sample raw file and save it as opus file:

defmodule Membrane.ReleaseTest.Pipeline do
  use Membrane.Pipeline

  alias Membrane.Caps.Audio.Raw

  @impl true
  def handle_init(_) do
    children = [
      source: %Membrane.File.Source{
        location: "/tmp/input.raw"
      },
      encoder: %Membrane.Opus.Encoder{
        application: :audio,
        input_caps: %Raw{
          channels: 2,
          format: :s16le,
          sample_rate: 48_000
        }
      },
      serializer: Membrane.Opus.Serializer,
      sink: %Membrane.File.Sink{
        location: "/tmp/output.opus"
      }
    ]

    links = [
      link(:source)
      |> to(:encoder)
      |> to(:serializer)
      |> to(:sink)
    ]

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

Decoder

Decode sample opus file and save it as raw file:

defmodule Membrane.ReleaseTest.Pipeline2 do
  use Membrane.Pipeline

  @impl true
  def handle_init(_) do
    children = [
      source: %Membrane.File.Source{
        location: "/tmp/input.opus"
      },
      parser: Membrane.Opus.Parser,
      opus: Membrane.Opus.Decoder,
      sink: %Membrane.File.Sink{
        location: "/tmp/output.raw"
      }
    ]

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

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

For more information please refer to Membrane.Opus.Encoder/Membrane.Opus.Decoder module documentation or our tests.

Copyright and License

Copyright 2019, Software Mansion

Software Mansion

Licensed under the Apache License, Version 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.