livekit / livekit-server-sdk-python Goto Github PK
View Code? Open in Web Editor NEWLiveKit Server SDK for Python
License: Apache License 2.0
LiveKit Server SDK for Python
License: Apache License 2.0
Is it possible to rename this project to "livekitserver" or something similar so it does not conflict with the Python Client SDK?
After adding in poetry , i got error at runtime that livekit module not found.
Hi, it's me again :)
Still a user of this package, and thanks again for making it.
I find myself in need of using the Webhook and unsure (can't see it anyway) if this package has support for webhooks
EDIT: I imagine I can simply look at the token, decode it to validate it and do what ever I need to do, even if not directly supported in this library
Hi,
I'm using this sdk for my backend. My flow at my backend as below:
Livekit server: v1.2.5
livekit-server-sdk-python: 0.4.1
In init.py of livekit-server-sdk-python, I added following code:
class TrackServiceClient:
"""
Client to access Egress APIs
"""
def init(self, host: str, api_key: str, api_secret: str):
self._client = TwirpEgressServiceClient(host)
self._api_key = api_key
self._api_secret = api_secret
def _create_context(self, **grant_kwargs):
grant = VideoGrant(**grant_kwargs)
access_token = AccessToken(
self._api_key,
self._api_secret,
grant=grant,
ttl=timedelta(minutes=10),
)
return Context(headers={"Authorization": f"Bearer {access_token.to_jwt()}"})
def list_egress(
self,
room_name: str
):
"""
Do list egress.
"""
ctx = self._create_context(room_admin=True, room=room_name)
request = ListEgressRequest(room_name=room_name)
self._client.ListEgress(ctx=ctx, request=request)
def track_egress(
self,
room_name: str,
track_id: str,
rtmpUrl: str
):
"""
Do track egress.
"""
ctx = self._create_context(room_admin=True, room_record=True, room=room_name)
rtmpOutput = StreamOutput(protocol=1, urls=[rtmpUrl])
request = TrackCompositeEgressRequest(room_name=room_name, video_track_id=track_id, stream=rtmpOutput)
self._client.StartTrackEgress(ctx=ctx, request=request)
I called track_egress with rtmpUrl = "rtmp://esw-rtmp.livekit:1935/live/test-room1"
But I got below error at my backend:
raise exceptions.TwirpServerException.from_json(resp.json())
twirp.exceptions.TwirpServerException: the protobuf request could not be decoded
And on livekit server logs:
2023-01-04T09:52:26.579Z INFO livekit service/twirp.go:111 API Egress.StartTrackEgress {"service": "Egress", "method": "StartTrackEgress", "duration": "67.808µs", "status": "400", "error": "the protobuf request could not be decoded", "code": "malformed"}
How can I fixed it ? please advise this.
I fixed it, I called wrong function in track_egress, it should be: StartTrackCompositeEgress
For example: I used livekit-cli for stream request as below and it worked:
{
"room_name": "test-room1",
"video_track_id": "TR_VCHQ3DH3JauRdJ",
"stream": {
"urls": [
"rtmp://esw-rtmp.livekit:1935/live/test"
]
}
}
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?
Can i get basic instructions on how to setup my development env on pycharm and how to i start the server.
i ran the following
i created development.env file and added export LIVEKIT_API_KEY=
export LIVEKIT_API_SECRET=
git clone --recurse-submodules https://github.com/tradablebits/livekit-server-sdk-python.git
python3 -m venv env
source env/Script/activate
pip install --editable . // . is for current folder
i am not sure how do i proceed further, can you guide me on how to start the server,
I also have GoLang installed on my system
It will be great help if you could guide me further. Thanks
Hi and thanks for making this
I'm using it and works fine for me
Wanted to ask if I'm missing something or this feature isn't supported:
When you create a token, along with the identity and other stuff, you can also give that user a name (in the participant info)
https://docs.livekit.io/server/room-management/#participantinfo
That name is used in the front-end
displayName = participant.name || participant.identity;
But I don't see anywhere in this package the name
For example, this php package seems to have it
https://github.com/agence104/livekit-server-sdk-php/blob/f6965a4d593356ffa762648c4acbb2cbfe048251/src/AccessToken.php#L89
I presume it's a new feature of livekit, perhaps
Hello, thanks for the Python SDK!
Is there any example of sending a request to the Egress server?
I am somehow trying to send TrackEgressRequest after joining a room below, while the server responds "status": "401", "error": "permissions denied", "code": "unauthenticated"
.
It is really helpful If there are any guides about how to use the EgressClient, thanks!
egress_client = livekit.twirp.EgressClient(address=MY_LIVEKIT_SERVER)
response = egress_client.StartTrackEgress(
ctx=twirp.context.Context(),
request=livekit.egress.TrackEgressRequest(
room_name=MY_ROOM,
track_id=MY_TRACK,
websocket_url=MY_WEBSOCKET_SERVER,
),
headers={"Authorization": f"Bearer {MY_TOKEN}"},
)
Hi @AlexJMohr
I'm wondering how (if at all possible) I could connect to a room from the backend, and listen to data events.
At the moment the only webhooks livekit supports are on participant leave etc, but not on data messages, I was looking at that option
Not having that ability is quite limiting, as I can send WS data, but cannot receive (meaning I have to receive API calls instead)
I've been using the channels py library as well, but don't want to use two WS systems - so want to get rid of that one entirely
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.