oleg.okunevych
oleg.okunevych
SMSoftware Mansion
Created by oleg.okunevych on 9/25/2024 in #membrane-help
stream RTMP to VLC Network stream
@mat_hek @Łukasz Kita thank you for details, will come back to that feature in a while
9 replies
SMSoftware Mansion
Created by oleg.okunevych on 9/25/2024 in #membrane-help
stream RTMP to VLC Network stream
I believe that the idea of RTMP.Sink is to push stream to some endpoint that is already listening for incoming connections
9 replies
SMSoftware Mansion
Created by oleg.okunevych on 9/25/2024 in #membrane-help
stream RTMP to VLC Network stream
Exactly, using Membrane.RMTP.Sink module was first that came into my mind, however it can be used to push the stream to something that already waiting the stream itself. It worked for me with Youtube. However, we need the ability to send RTMP stream on demand, for instance user clicks the link, we handle this http response adding some Sink to the pipeline and respond user with rtmp url that he can use with ffplay or some other tool
9 replies
SMSoftware Mansion
Created by oleg.okunevych on 9/25/2024 in #membrane-help
stream RTMP to VLC Network stream
Hey @mat_hek thanks for your answer. Using ffplay to validate the stream is totally fine for our purposes, the thing is that I still getting an error. Currently we run the RTMP server to receive the stream using following code:
handle_new_client = fn client_ref, app, stream_key ->
Logger.info("New RTMP connection: #{inspect(client_ref)}")
send(parent_process_pid, {:client_ref, client_ref, app, stream_key})
Membrane.RTMP.Source.ClientHandlerImpl
end

{:ok, _server} =
RTMPServer.start_link(
handle_new_client: handle_new_client,
port: Keyword.get(state.opts, :server_port, 1935),
use_ssl?: Keyword.get(state.opts, :use_ssl?, false)
)
handle_new_client = fn client_ref, app, stream_key ->
Logger.info("New RTMP connection: #{inspect(client_ref)}")
send(parent_process_pid, {:client_ref, client_ref, app, stream_key})
Membrane.RTMP.Source.ClientHandlerImpl
end

{:ok, _server} =
RTMPServer.start_link(
handle_new_client: handle_new_client,
port: Keyword.get(state.opts, :server_port, 1935),
use_ssl?: Keyword.get(state.opts, :use_ssl?, false)
)
Our pipeline looks following:
child(:rtmp_funnel, Membrane.Funnel),
child(:rtmp_tcp_sink, %Membrane.TCP.Sink{
connection_side: :server,
local_address: {127, 0, 0, 1},
local_port_no: 1937,
close_on_eos: false,
on_connection_closed: :drop_buffers
}),
child(:source, %SourceBin{
client_ref: state.client_ref
})
|> via_out(:video)
|> get_child(:rtmp_funnel)
|> get_child(:rtmp_tcp_sink),
get_child(:source)
|> via_out(:audio)
|> get_child(:rtmp_funnel)
|> get_child(:rtmp_tcp_sink)
child(:rtmp_funnel, Membrane.Funnel),
child(:rtmp_tcp_sink, %Membrane.TCP.Sink{
connection_side: :server,
local_address: {127, 0, 0, 1},
local_port_no: 1937,
close_on_eos: false,
on_connection_closed: :drop_buffers
}),
child(:source, %SourceBin{
client_ref: state.client_ref
})
|> via_out(:video)
|> get_child(:rtmp_funnel)
|> get_child(:rtmp_tcp_sink),
get_child(:source)
|> via_out(:audio)
|> get_child(:rtmp_funnel)
|> get_child(:rtmp_tcp_sink)
I assume that this pipeline should pass the payload from the RTMP server through the funnel into :rtmp_tcp_sink which creates a TCP connection on the 1937 port. Using netcat, I see that we are receiving the payload over the TCP Connection, also Membrane Pipeline visualization tool show that TCP Sink processes the data. However, when using ffplay ffplay rtmp://localhost:1937/app/stream1 we get an error:
[rtmp @ 0x60000331ab50] Server response validating failed
rtmp://localhost:1937/app/stream1: Input/output error
[rtmp @ 0x60000331ab50] Server response validating failed
rtmp://localhost:1937/app/stream1: Input/output error
Should I use Membrane.TCP.Sink, or we may consider other library/module/approach for our use case?
9 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
I think I found the problem, error dissapeared after updating app alpine image from alpine:3.17 to alpine:3.18.5 Thank you for help!
12 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
still the same results. What other Docker image would you suggest to try?
12 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
for build stage following libs are used:
RUN \
apk add --no-cache \
build-base \
git \
npm \
make \
cmake \
openssl-dev \
libsrtp-dev \
libsrt-dev \
ffmpeg-dev \
fdk-aac-dev \
opus-dev \
openssh-client \
ca-certificates \
curl
RUN \
apk add --no-cache \
build-base \
git \
npm \
make \
cmake \
openssl-dev \
libsrtp-dev \
libsrt-dev \
ffmpeg-dev \
fdk-aac-dev \
opus-dev \
openssh-client \
ca-certificates \
curl
for app stage we have:
RUN \
apk add --no-cache \
libstdc++6 \
openssl \
libsrtp \
ffmpeg \
fdk-aac \
opus \
openssh-client \
curl \
ncurses \
mesa \
mesa-dri-gallium \
mesa-dev
RUN \
apk add --no-cache \
libstdc++6 \
openssl \
libsrtp \
ffmpeg \
fdk-aac \
opus \
openssh-client \
curl \
ncurses \
mesa \
mesa-dri-gallium \
mesa-dev
12 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
thanks for quick answer 🙂
membrane_rtmp_plugin uses bundlex under the hood.
membrane_rtmp_plugin uses bundlex under the hood.
Does it mean that BundlexProject module is required to be configured in the application? I am using elixir:1.16.2-otp-26-alpine image. There are no warnings when building rtmp plugin:
#24 149.7 ==> membrane_rtmp_plugin
#24 149.7 Bundlex: Building natives: rtmp_sink
#24 149.9 Compiling 38 files (.ex)
#24 150.3 Generated membrane_rtmp_plugin app
#24 149.7 ==> membrane_rtmp_plugin
#24 149.7 Bundlex: Building natives: rtmp_sink
#24 149.9 Compiling 38 files (.ex)
#24 150.3 Generated membrane_rtmp_plugin app
12 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
2024-04-26 16:11:04 =INFO REPORT==== 26-Apr-2024::13:11:04.944615 ===
2024-04-26 16:11:04 application: kernel
2024-04-26 16:11:04 exited: {{shutdown,
2024-04-26 16:11:04 {failed_to_start_child,on_load,
2024-04-26 16:11:04 {on_load_function_failed,
2024-04-26 16:11:04 'Elixir.Membrane.RTMP.Sink.Native.Nif',abort}}},
2024-04-26 16:11:04 {kernel,start,[normal,[]]}}
2024-04-26 16:11:04 type: permanent
2024-04-26 16:11:04
2024-04-26 16:11:05 Kernel pid terminated (application_controller) ("{application_start_failure,kernel,{{shutdown,{failed_to_start_child,on_load,{on_load_function_failed,'Elixir.Membrane.RTMP.Sink.Native.Nif',abort}}},{kernel,start,[normal,[]]}}}")
2024-04-26 16:11:05
2024-04-26 16:11:05 Crash dump is being written to: erl_crash.dump...done
2024-04-26 16:11:04 =INFO REPORT==== 26-Apr-2024::13:11:04.944615 ===
2024-04-26 16:11:04 application: kernel
2024-04-26 16:11:04 exited: {{shutdown,
2024-04-26 16:11:04 {failed_to_start_child,on_load,
2024-04-26 16:11:04 {on_load_function_failed,
2024-04-26 16:11:04 'Elixir.Membrane.RTMP.Sink.Native.Nif',abort}}},
2024-04-26 16:11:04 {kernel,start,[normal,[]]}}
2024-04-26 16:11:04 type: permanent
2024-04-26 16:11:04
2024-04-26 16:11:05 Kernel pid terminated (application_controller) ("{application_start_failure,kernel,{{shutdown,{failed_to_start_child,on_load,{on_load_function_failed,'Elixir.Membrane.RTMP.Sink.Native.Nif',abort}}},{kernel,start,[normal,[]]}}}")
2024-04-26 16:11:05
2024-04-26 16:11:05 Crash dump is being written to: erl_crash.dump...done
I've seen similar kind of error related to bundlex in this group, however I am not using Bundlex and it seems to be another kind of error.
12 replies
SMSoftware Mansion
Created by oleg.okunevych on 4/26/2024 in #membrane-help
Running Docker image with Membrane RTMP Plugin
2024-04-26 16:11:04 =CRASH REPORT==== 26-Apr-2024::13:11:04.944480 ===
2024-04-26 16:11:04 crasher:
2024-04-26 16:11:04 initial call: application_master:init/4
2024-04-26 16:11:04 pid: <0.2480.0>
2024-04-26 16:11:04 registered_name: []
2024-04-26 16:11:04 exception exit: {{shutdown,
2024-04-26 16:11:04 {failed_to_start_child,on_load,
2024-04-26 16:11:04 {on_load_function_failed,
2024-04-26 16:11:04 'Elixir.Membrane.RTMP.Sink.Native.Nif',
2024-04-26 16:11:04 abort}}},
2024-04-26 16:11:04 {kernel,start,[normal,[]]}}
2024-04-26 16:11:04 in function application_master:init/4 (application_master.erl, line 142)
2024-04-26 16:11:04 ancestors: [<0.2479.0>]
2024-04-26 16:11:04 message_queue_len: 1
2024-04-26 16:11:04 messages: [{'EXIT',<0.2481.0>,normal}]
2024-04-26 16:11:04 links: [<0.2479.0>,<0.2478.0>]
2024-04-26 16:11:04 dictionary: []
2024-04-26 16:11:04 trap_exit: true
2024-04-26 16:11:04 status: running
2024-04-26 16:11:04 heap_size: 233
2024-04-26 16:11:04 stack_size: 28
2024-04-26 16:11:04 reductions: 166
2024-04-26 16:11:04 neighbours:
2024-04-26 16:11:04
2024-04-26 16:11:04 =CRASH REPORT==== 26-Apr-2024::13:11:04.944480 ===
2024-04-26 16:11:04 crasher:
2024-04-26 16:11:04 initial call: application_master:init/4
2024-04-26 16:11:04 pid: <0.2480.0>
2024-04-26 16:11:04 registered_name: []
2024-04-26 16:11:04 exception exit: {{shutdown,
2024-04-26 16:11:04 {failed_to_start_child,on_load,
2024-04-26 16:11:04 {on_load_function_failed,
2024-04-26 16:11:04 'Elixir.Membrane.RTMP.Sink.Native.Nif',
2024-04-26 16:11:04 abort}}},
2024-04-26 16:11:04 {kernel,start,[normal,[]]}}
2024-04-26 16:11:04 in function application_master:init/4 (application_master.erl, line 142)
2024-04-26 16:11:04 ancestors: [<0.2479.0>]
2024-04-26 16:11:04 message_queue_len: 1
2024-04-26 16:11:04 messages: [{'EXIT',<0.2481.0>,normal}]
2024-04-26 16:11:04 links: [<0.2479.0>,<0.2478.0>]
2024-04-26 16:11:04 dictionary: []
2024-04-26 16:11:04 trap_exit: true
2024-04-26 16:11:04 status: running
2024-04-26 16:11:04 heap_size: 233
2024-04-26 16:11:04 stack_size: 28
2024-04-26 16:11:04 reductions: 166
2024-04-26 16:11:04 neighbours:
2024-04-26 16:11:04
12 replies