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

Start RTMP forwarding when RTMP source arrives #129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lastcanal
Copy link
Collaborator

This fixes a ~1 second delay in audio when multi-streaming, tested on Twitch.

It is possible that calling :multicast_algora may still result in a de-sync of audio and video while forwarding. Adding a field/flag to the user/channel would allow multicasting to "Algora" when the RTMP source arrives, instead of ad-hoc like it is now.

@zcesur
Copy link
Member

zcesur commented Dec 17, 2024

Very nice!

I ran into an issue where some pipeline components crashed while the pipeline itself remained running. In this scenario, attempting to reconnect leads to [warning] No demand made for client /live/●●●●●●●●●●●, terminating connection. until the pipeline is manually terminated 🤔

@lastcanal
Copy link
Collaborator Author

It seems like starting RTMP forwarding in the same group as the source has messed up reconnecting...

I am getting this error now:

[error] GenServer #PID<0.2169.0> terminating
** (MatchError) no match of right hand side value: %{input: [{Membrane.Pad, :input, #Reference<0.740859990.2745171970.64194>}]}
    (membrane_mp4_plugin 0.35.2) lib/membrane_mp4/muxer/cmaf.ex:227: Membrane.MP4.Muxer.CMAF.handle_playing/2
    (membrane_core 1.0.1) lib/membrane/core/callback_handler.ex:139: Membrane.Core.CallbackHandler.exec_callback/4
    (membrane_core 1.0.1) lib/membrane/core/callback_handler.ex:69: Membrane.Core.CallbackHandler.exec_and_handle_callback/5
    (membrane_core 1.0.1) lib/membrane/core/element/lifecycle_controller.ex:84: Membrane.Core.Element.LifecycleController.handle_playing/1
    (membrane_core 1.0.1) lib/membrane/core/element.ex:249: Membrane.Core.Element.handle_info/2
    (stdlib 6.1) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.1) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {Membrane.Core.Message, :play, [], []}

@zcesur
Copy link
Member

zcesur commented Dec 17, 2024

I don't think that's related to forwarding - been having this issue before this PR, even without any forwarding. Seems to be caused by a timeout when sending link messages between CMAF muxers and the sink. See #131

This fixes a ~1 second delay in audio when multistreaming

starve rtmp connection if already playing

allow passing stream key as app

cleanup unused handle_init

initialize rtmp connection before aborting
@lastcanal
Copy link
Collaborator Author

I've rebased this against main and got rid of the delay when reconnecting. Denying incoming RTMP connections isn't very straight forward, or at least I couldn't figure out a way to do it without adding it to a pipeline, so I added Algora.Pipeline.AbortPipeline which accepts the RTMP connection before letting the pipeline terminate, which does an orderly shutdown of the RTMP connection. Might be worth looking into adding something to membrane_rtmp_plugin to make denying an incoming RTMP connections a bit easier.

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