Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/membraneframework/membrane_ffmpeg_swresample_plugin
Plugin performing audio conversion, resampling and channel mixing, using SWResample module of FFmpeg library
https://github.com/membraneframework/membrane_ffmpeg_swresample_plugin
Last synced: 2 days ago
JSON representation
Plugin performing audio conversion, resampling and channel mixing, using SWResample module of FFmpeg library
- Host: GitHub
- URL: https://github.com/membraneframework/membrane_ffmpeg_swresample_plugin
- Owner: membraneframework
- License: apache-2.0
- Created: 2017-04-14T06:09:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T12:40:22.000Z (7 months ago)
- Last Synced: 2024-04-04T14:07:46.690Z (7 months ago)
- Language: Elixir
- Homepage:
- Size: 452 KB
- Stars: 2
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Membrane FFmpeg SWResample plugin
[![Hex.pm](https://img.shields.io/hexpm/v/membrane_ffmpeg_swresample_plugin.svg)](https://hex.pm/packages/membrane_ffmpeg_swresample_plugin)
[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_ffmpeg_swresample_plugin/)
[![CircleCI](https://circleci.com/gh/membraneframework/membrane_ffmpeg_swresample_plugin.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane_ffmpeg_swresample_plugin)Plugin performing audio conversion, resampling and channel mixing, using SWResample module of [FFmpeg](https://www.ffmpeg.org/) library.
It is a part of [Membrane Multimedia Framework](https://membrane.stream).
## Installation
Add the following line to your `deps` in `mix.exs`. Run `mix deps.get`.
```elixir
{:membrane_ffmpeg_swresample_plugin, "~> 0.20.2"}
```The precompiled builds of the [ffmpeg](https://www.ffmpeg.org) will be pulled and linked automatically. However, should there be any problems, consider installing it manually.
### Manual instalation of dependencies
#### macOS
```shell
brew install ffmpeg
```#### Ubuntu
```shell
sudo apt-get install ffmpeg
```#### Arch / Manjaro
```shell
pacman -S ffmpeg
```## Usage
The pipeline takes raw audio, converts the sample format from `s24le` to `f32le` and resamples
it to 44.1 kHz rate.```elixir
defmodule Resampling.Pipeline do
use Membrane.Pipelinealias 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 and License
Copyright 2018, [Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=membrane)
[![Software Mansion](https://logo.swmansion.com/logo?color=white&variant=desktop&width=200&tag=membrane-github)](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=membrane)
Licensed under the [Apache License, Version 2.0](LICENSE)