Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Pipeline in livebook - dashboard example

examples/pipeline_in_livebook.livemd

Pipeline in livebook - dashboard example

Logger.configure(level: :info)

Mix.install([
  :kino_membrane,
  :membrane_hackney_plugin,
  :membrane_portaudio_plugin,
  :membrane_ffmpeg_swresample_plugin,
  :membrane_mp3_mad_plugin
])

Prerequisities

Make sure you have the following libraries installed on your OS:

clang-format, portaudio19-dev, FFmpeg 4.*, libavutil-dev, libswresample-dev, libmad0-dev

On Mac OS, you can install them via Homebrew:

brew install clang-format portaudio ffmpeg libmad pkg-config

and on Debian via apt:

apt install clang-format portaudio19-dev ffmpeg libavutil-dev libswresample-dev libmad0-dev

Dashboard

import Membrane.ChildrenSpec
alias Membrane.RCPipeline

pipeline = RCPipeline.start_link!()

RCPipeline.exec_actions(pipeline,
  spec:
    child(:hackney, %Membrane.Hackney.Source{
      location:
        "https://raw.githubusercontent.com/membraneframework/membrane_demo/master/simple_pipeline/sample.mp3",
      hackney_opts: [follow_redirect: true]
    })
    |> via_in(:input, auto_demand_size: 10)
    |> child(:decoder, Membrane.MP3.MAD.Decoder)
    |> child(:converter, %Membrane.FFmpeg.SWResample.Converter{
      output_stream_format: %Membrane.RawAudio{
        sample_format: :s16le,
        sample_rate: 48000,
        channels: 2
      }
    })
    |> child(:portaudio, Membrane.PortAudio.Sink),
  playback: :playing
)
KinoMembrane.pipeline_dashboard(pipeline)
Membrane.Pipeline.terminate(pipeline)