Plugin performing audio conversion, resampling and channel mixing, using SWResample module of FFmpeg library.
It is a part of Membrane Multimedia Framework.
Add the following line to your deps
in mix.exs
. Run mix deps.get
.
{:membrane_ffmpeg_swresample_plugin, "~> 0.20.2"}
The precompiled builds of the ffmpeg will be pulled and linked automatically. However, should there be any problems, consider installing it manually.
brew install ffmpeg
sudo apt-get install ffmpeg
pacman -S ffmpeg
The pipeline takes raw audio, converts the sample format from s24le
to f32le
and resamples
it to 44.1 kHz rate.
defmodule Resampling.Pipeline do
use Membrane.Pipeline
alias Membrane.FFmpeg.SWResample.Converter
alias Membrane.{File, RawAudio}
@impl true
def handle_init(_ctx, _opts) do
structure = [
child(:file_src, %File.Source{location: "/tmp/input.raw"})
|> child(:converter, %Converter{
input_stream_format: %RawAudio{channels: 2, sample_format: :s24le, sample_rate: 48_000},
output_stream_format: %RawAudio{channels: 2, sample_format: :f32le, sample_rate: 44_100}
})
|> child(:file_sink, %File.Sink{location: "/tmp/output.raw"})
]
{[spec: structure, playback: :playing], nil}
end
@impl true
def handle_element_end_of_stream(:file_sink, _pad, _ctx_, _state) do
{[playback: :stopped], nil}
end
end
Copyright 2018, Software Mansion
Licensed under the Apache License, Version 2.0