kingdomcoder

kingdomcoder

Hey,

I’m trying to stream from PortAudio to HLS as below.

The pipeline breaks when converting RawAudio to AAC with Failed to create native encoder: :"Invalid config"

How can I get around this? Thanks.

child(:pa_src, PortAudio.Source)
|> child(:hls_out_aac_encoder, Membrane.AAC.FDK.Encoder)
|> via_in(Pad.ref(:input, :audio),
  options: [encoding: :AAC, segment_duration: Membrane.Time.milliseconds(2000)]
)
|> child(
  :hls_sink_bin,
  %Membrane.HTTPAdaptiveStream.SinkBin{
    manifest_name: manifest_name,
    manifest_module: Membrane.HTTPAdaptiveStream.HLS,
    storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{
      directory: directory
    },
    hls_mode: hls_mode,
    mp4_parameters_in_band?: true,
    target_window_duration: Membrane.Time.seconds(20)
  }
)

Showing Posts 1 to 9

mat-hek

mat-hek

Membrane Core Team

Hi, can you plug a debug filter right after the source and post the output here?

|> child(%Membrane.Debug.Filter{handle_buffer: &IO.inspect/1})
kingdomcoder

kingdomcoder OP

I get multiple instances of %Membrane.Buffer{}

The first two being:

%Membrane.Buffer{
  payload: <<93, 233, 0, 128, 93, 233, 0, 128, 174, 180, 0, 0, 93, 233, 0, 128,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, ...>>,
  pts: 0,
  dts: nil,
  metadata: %{}
}
%Membrane.Buffer{
  payload: <<128, 233, 0, 128, 128, 233, 0, 128, 192, 180, 0, 0, 128, 233, 0,
    128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>,
  pts: 75366,
  dts: nil,
  metadata: %{}
}

And the last two being:

%Membrane.Buffer{
  payload: <<130, 242, 0, 128, 130, 242, 0, 128, 65, 185, 0, 0, 130, 242, 0,
    128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>,
  pts: 75760762,
  dts: nil,
  metadata: %{}
}
%Membrane.Buffer{
  payload: <<206, 242, 0, 128, 206, 242, 0, 128, 103, 185, 0, 0, 206, 242, 0,
    128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>,
  pts: 75824006,
  dts: nil,
  metadata: %{}
}

And here’s a fuller stack trace of the original error:

[error] <0.977.0>/:hls_out_aac_encoder Error occured in Membrane Element:
** (RuntimeError) Failed to create native encoder: :"Invalid config"
    (membrane_aac_fdk_plugin 0.18.10) lib/membrane_aac_fdk_plugin/encoder.ex:255: Membrane.AAC.FDK.Encoder.mk_native!/5
    (membrane_aac_fdk_plugin 0.18.10) lib/membrane_aac_fdk_plugin/encoder.ex:111: Membrane.AAC.FDK.Encoder.handle_stream_format/4
    (membrane_core 1.1.2) lib/membrane/core/callback_handler.ex:139: Membrane.Core.CallbackHandler.exec_callback/4
    (membrane_core 1.1.2) lib/membrane/core/callback_handler.ex:69: Membrane.Core.CallbackHandler.exec_and_handle_callback/5
    (membrane_core 1.1.2) lib/membrane/core/element/stream_format_controller.ex:82: Membrane.Core.Element.StreamFormatController.exec_handle_stream_format/4
    (membrane_core 1.1.2) lib/membrane/core/element.ex:237: Membrane.Core.Element.handle_info/2
    (stdlib 6.1.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.1.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.1.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
mat-hek

mat-hek

Membrane Core Team

Oops sorry, I meant handle_stream_format, not handle_buffer

kingdomcoder

kingdomcoder OP

%Membrane.RawAudio{channels: 32, sample_rate: 44100, sample_format: :s16le}

mat-hek

mat-hek

Membrane Core Team

Right, so PortAudio somehow detects 32 audio channels in your input device, and AAC cannot encode that… Try setting channels: 1 or channels: 2 option in the source

kingdomcoder

kingdomcoder OP

Yes! That fixes it.

Thank you.

kingdomcoder

kingdomcoder OP

On a related note, is there then a way with membrane to stream AAC to an rtmp endpoint?

If it has to be via ffmpeg, any pointers on how to achieve that in a membrane pipeline?

kingdomcoder

kingdomcoder OP

This is helpful

Thanks!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews