Skip to content

Commit

Permalink
Merge pull request #75 from membraneframework/use_precompiled_deps
Browse files Browse the repository at this point in the history
Use precompiled deps
  • Loading branch information
DominikWolek authored Oct 27, 2023
2 parents 35c3c86 + 2ad1ece commit ab6b788
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 21 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,36 @@ It is a part of [Membrane Multimedia Framework](https://membraneframework.org).

## Installation

First, you need to install FFmpeg on your system:
The package can be installed by adding `membrane_rtmp_plugin` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:membrane_rtmp_plugin, "~> 0.18.0"}
]
end
```

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.

### macOS
### Manual instalation of dependencies

#### macOS

```shell
brew install ffmpeg
```

### Ubuntu
#### Ubuntu

```shell
sudo apt-get install ffmpeg
```

The package can be installed by adding `membrane_rtmp_plugin` to your list of dependencies in `mix.exs`:
#### Arch / Manjaro

```elixir
def deps do
[
{:membrane_rtmp_plugin, "~> 0.17.4"}
]
end
```shell
pacman -S ffmpeg
```

## SourceBin
Expand Down
22 changes: 21 additions & 1 deletion bundlex.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
defmodule Membrane.RTMP.BundlexProject do
use Bundlex.Project

defp get_ffmpeg_url() do
membrane_precompiled_url_prefix =
"https://github.com/membraneframework-precompiled/precompiled_ffmpeg/releases/latest/download/ffmpeg"

case Bundlex.get_target() do
%{os: "linux"} ->
{:precompiled,
"https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.0-latest-linux64-gpl-shared-6.0.tar.xz"}

%{architecture: "x86_64", os: "darwin" <> _rest_of_os_name} ->
{:precompiled, "#{membrane_precompiled_url_prefix}_macos_intel.tar.gz"}

%{architecture: "aarch64", os: "darwin" <> _rest_of_os_name} ->
{:precompiled, "#{membrane_precompiled_url_prefix}_macos_arm.tar.gz"}

_other ->
nil
end
end

def project do
[
natives: natives(Bundlex.platform())
Expand All @@ -14,7 +34,7 @@ defmodule Membrane.RTMP.BundlexProject do
deps: [unifex: :unifex],
interface: [:nif],
preprocessor: Unifex,
pkg_configs: ["libavformat", "libavutil"]
os_deps: [{[get_ffmpeg_url(), :pkg_config], ["libavformat", "libavutil"]}]
]
]
end
Expand Down
8 changes: 7 additions & 1 deletion c_src/membrane_rtmp_plugin/sink/rtmp_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@ UNIFEX_TERM init_audio_stream(UnifexEnv *env, State *state, int channels,
}
state->audio_stream_index = audio_stream->index;

AVChannelLayout *channel_layout = malloc(sizeof *channel_layout);
if (!channel_layout) {
return unifex_raise(env, "Failed allocating channel layout");
}
av_channel_layout_default(channel_layout, channels);

audio_stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
audio_stream->codecpar->codec_id = AV_CODEC_ID_AAC;
audio_stream->codecpar->sample_rate = sample_rate;
audio_stream->codecpar->channels = channels;
audio_stream->codecpar->ch_layout = *channel_layout;
audio_stream->codecpar->extradata_size = aac_config->size;
audio_stream->codecpar->extradata =
(uint8_t *)av_malloc(aac_config->size + AV_INPUT_BUFFER_PADDING_SIZE);
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.RTMP.Mixfile do
use Mix.Project

@version "0.17.4"
@version "0.18.0"
@github_url "https://github.com/membraneframework/membrane_rtmp_plugin"

def project do
Expand Down
Loading

0 comments on commit ab6b788

Please sign in to comment.