Membrane pipeline dashboard
Logger . configure ( level: :info )
Mix . install ( [
:kino_membrane ,
:membrane_hackney_plugin ,
:membrane_portaudio_plugin ,
:membrane_ffmpeg_swresample_plugin ,
:membrane_mp3_mad_plugin ,
{ :kino , "~> 0.9.4" }
] )
start_pipeline = fn mp3_url ->
import Membrane.ChildrenSpec
alias Membrane.RCPipeline
pipeline = RCPipeline . start_link! ( )
RCPipeline . exec_actions ( pipeline ,
spec:
child ( :hackney , % Membrane.Hackney.Source {
location: mp3_url ,
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
)
pipeline
end
form =
Kino.Control . form (
[
mp3_url:
Kino.Input . url ( "MP3 url" ,
default:
"https://raw.githubusercontent.com/membraneframework/membrane_demo/master/simple_pipeline/sample.mp3"
)
] ,
submit: "Submit"
)
Kino . listen ( form , fn % { data: % { mp3_url: url } } ->
pipeline = start_pipeline . ( url )
KinoMembrane . pipeline_dashboard ( pipeline ) |> Kino . render ( )
end )
form