livekit / livekit-server-sdk-python

LiveKit Server SDK for Python
Apache License 2.0
26 stars 7 forks source link

How to use this SDK for egress server #5

Closed nhha1602 closed 1 year ago

nhha1602 commented 1 year ago

Hi,

I want to use this SDK and with gstreamer for python to do an egress server - called "myegress".

My scenario is:

Please advise if I can use this SDK for above scenario?

AlexJMohr commented 1 year ago

You should be able to use this SDK to send a TrackCompositeEgressRequest. In your case it sounds like you want to livekit to output an RTMP Stream. I believe you want the livekit.twirp.livekit_egress_twirp (livekit.twirp in v1.0.0) module from this library. To be honest I don't know if it's the Client or the Server (this code is generated from the livekit proto files)

The receiver of the stream would likely be a separate process where you would capture it with gstreamer and do your post-processing.

nhha1602 commented 1 year ago

Thank you for your answers. I tried with TrackCompositeEgressRequest and output is RTMP stream. Then I used OpenCV read the RTMP setram. But I got a delay from input stream to output stream ~ 25 seconds (I expected a deplay < 3 seconds). I'm not sure it cause by RTMP stream or cause by OpenCV. My flow as below:

A client send request: TrackCompositeEgressRequest to livekit-server Egress extract video and connect to a RTMP server. The client connect to RTMP server using OpenCV and read RTMP stream At the client side, I saw that the RTMP stream was deplayed about 25 seconds.

That why, I tried to use another solution - write an egress by using this SDK, so that I dont need to use RTMP. Because, Egress use gstreamer, so I can capture video at egress end point using OpenCV (OpenCV support gstreamer).

Please advise.

Thanks and regards,

AlexJMohr commented 1 year ago

Apologies for the delayed response. Unfortunately I'm not able to provide support with this one. I suggest trying to mock up what you want to do using one of the official server SDKs: https://docs.livekit.io/references/server-sdks/ or ask for help through the official livekit channels.