### Install FFmpeg on Ubuntu Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/index Command to install FFmpeg on Ubuntu using the apt-get package manager. This is a prerequisite for the Membrane FFmpeg SWResample plugin if precompiled builds fail. ```bash sudo apt-get install ffmpeg ``` -------------------------------- ### Install FFmpeg on macOS Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/index Command to install FFmpeg on macOS using the Homebrew package manager. This is a prerequisite for the Membrane FFmpeg SWResample plugin if precompiled builds fail. ```bash brew install ffmpeg ``` -------------------------------- ### Install FFmpeg on Arch/Manjaro Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/index Command to install FFmpeg on Arch Linux or Manjaro using the pacman package manager. This is a prerequisite for the Membrane FFmpeg SWResample plugin if precompiled builds fail. ```bash pacman -S ffmpeg ``` -------------------------------- ### Get Converter Options Function Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample A function to retrieve a description of the available options for the Membrane.FFmpeg.SWResample.Converter module. This is useful for understanding configuration parameters. ```Elixir @spec options() :: keyword() ``` -------------------------------- ### Create Native Audio Converter (SWResample) Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample.Converter Initializes a native audio converter using the swresample library. Requires input and source audio format, sample rate, and channel configurations. This function sets up the necessary context for subsequent conversions. ```elixir create(input_format, input_rate, input_channels, src_format, src_rate, src_channels) ``` -------------------------------- ### Membrane.FFmpeg.SWResample.Converter Options Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample Retrieves the description of available options for the Membrane.FFmpeg.SWResample.Converter module. ```APIDOC ## Membrane.FFmpeg.SWResample.Converter Options Function ### Description Returns a description of the options available for the `Membrane.FFmpeg.SWResample.Converter` module. ### Method `options()` ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **options** (keyword()) - A keyword list describing the available options. #### Response Example ```elixir [ input_stream_format: [type: "RawAudio.t() | nil", default: nil, help: "Stream format for the input pad..."], output_stream_format: [type: "RawAudio.t()", required: true, help: "Audio stream format for output pad"] ] ``` ``` -------------------------------- ### Add Membrane FFmpeg SWResample Plugin Dependency (mix.exs) Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/readme This snippet shows how to add the Membrane FFmpeg SWResample plugin as a dependency in your `mix.exs` file. After adding this line, run `mix deps.get` to fetch the dependency. The plugin automatically handles precompiled FFmpeg builds. ```elixir {:membrane_ffmpeg_swresample_plugin, "~> 0.20.2"} ``` -------------------------------- ### Converter Element Options Struct Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample Defines the structure for options passed to the Membrane.FFmpeg.SWResample.Converter element. It includes input and output stream formats. The output stream format is required, while the input stream format is optional and defaults to nil. ```Elixir @type t() :: %Membrane.FFmpeg.SWResample.Converter{ input_stream_format: Membrane.RawAudio.t() | nil, output_stream_format: Membrane.RawAudio.t() } ``` -------------------------------- ### Elixir Audio Conversion and Resampling Pipeline Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/index An Elixir Membrane pipeline demonstrating audio conversion from 's24le' to 'f32le' sample format and resampling to 44.1 kHz. It uses `File.Source`, `Membrane.FFmpeg.SWResample.Converter`, and `File.Sink`. ```elixir 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 ``` -------------------------------- ### Add Dependency to mix.exs Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/index This code snippet shows how to add the Membrane FFmpeg SWResample plugin as a project dependency in Elixir's `mix.exs` file. After adding this line, run `mix deps.get` to fetch the dependency. ```elixir {:membrane_ffmpeg_swresample_plugin, "~> 0.20.2"} ``` -------------------------------- ### Convert Audio Payload (SWResample) Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample.Converter Performs audio data conversion using the native swresample implementation. Takes the payload containing audio data and the current state of the converter as input. Returns the converted audio data. ```elixir convert(payload, state) ``` -------------------------------- ### Membrane.FFmpeg.SWResample.Converter Element Source: https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/Membrane.FFmpeg.SWResample This element performs audio conversion, resampling, and channel mixing using the SWResample module of the FFmpeg library. ```APIDOC ## Membrane.FFmpeg.SWResample.Converter Element ### Description This element performs audio conversion/resampling/channel mixing, using SWResample module of FFmpeg library. ### Method N/A (Element configuration) ### Endpoint N/A ### Parameters #### Element Options - **input_stream_format** (RawAudio.t() | nil) - Optional - Stream format for the input pad. If set to nil (default value), stream format is assumed to be received through the pad. If explicitly set to some stream format, it cannot be changed by stream format received through the pad. - **output_stream_format** (RawAudio.t()) - Required - Audio stream format for output pad ### Request Example ```json { "input_stream_format": null, "output_stream_format": { "sample_format": ":f32le", "channels": 2, "rate": 48000 } } ``` ### Response #### Success Response (Configuration) This element does not have a direct success response in terms of a typical API call. Configuration is done during pipeline setup. #### Response Example N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.