Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send RTMP messages to receiver_pid #102

Conversation

lastcanal
Copy link
Contributor

Hello! Upon upgrading to v0.26 I've lost access to the RTMP messages which were previously available to the Validator.
I saw that Membrane.RTMP.MessageHandler already has an unused receiver_pid in it's state, so I used that for sending messages to the receiver.

To set the receiver_pid users can return a three-tuple from the handle_new_client callback like this:

{Membrane.RTMP.Source.ClientHandlerImpl, %{}, receiver_pid}

RTMP messages that get sent are simply forwareded Membrane.RTMP.Messages structs, not wrapped in any 'scoping' tuple. The OnDataFrame message is particularly important to me, as I am using it to calculate frame dimensions for transcoding with membrane_ffmpeg_swscale_plugin.

@lastcanal lastcanal force-pushed the send_messages_to_pipeline branch from e57ac5d to a277687 Compare October 28, 2024 20:54
@varsill
Copy link
Contributor

varsill commented Oct 29, 2024

Hello @lastcanal !
That's a good observation, it used to be possible to do it that way, but it'a not possible anymore. Could you provide some more context why do you need that "OnDataFrame" message (BTW - didn't you mean OnMetaData message?)
I think all the necessary information (like resolution etc.) should be available in the stream format.
Another thing is that I guess adding a new callback in the ClientHandlerBehaviour (like handle_rtmp_message) which would be called for each message received after RTMP handshake for a given client, aligns to the current architecture of the RTMP server in a greater degree.
On the other hand, it would mean that for your case you would need to implement a custom behaviour.
WDYT about such an approach?

@lastcanal
Copy link
Contributor Author

Hello! Sorry, I meant SetDataFrame, although OnMetaData should work too: I really only need width, height, and framerate for scaling video tracks while keeping the aspect ratio intact.

I took your suggestion and tried to use the stream format, but unfortunately framerate is always set to nil... Perhaps this is a bug? Here is the stream format for my OBS RTMP stream intercepted by a Tee.Parallel:

%Membrane.H264{
  width: 1280,
  height: 720,
  profile: :high,
  alignment: :au,
  nalu_in_metadata?: true,
  framerate: nil,
  stream_structure: {:avc3, <<1, 100, 0, 32, 255, 224, 0>>}
}

Sending messages through the client handler is a great idea and i managed to get that working. I've pushed a new branch #103 with the new handle_rtmp_message callback. Thanks!

@lastcanal lastcanal closed this Oct 29, 2024
@varsill
Copy link
Contributor

varsill commented Oct 30, 2024

@lastcanal - sure, I understand. Indeed, the framerate is missing, because the H264 stream format is created by the FLV Demuxer (a part of the SourceBin) and FLV demuxer is apparently unable to read that information from FLV, and at the same time metadata sent within RTMP messages is lost.
There are is a couple of possible approaches to that problem, I've described them here: membraneframework/membrane_core#903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants