Skip to main content

pyowt

PyPI PyPI - Downloads

A python client for Intel OWT Server

Installation

You can install using pip:

pip install owt

Quick Start

from owt import ConferenceClient

# create a client
client = ConferenceClient()
try:
    # join the conference using token created by owt-server
    # or if your owt-server is using the demo, the package provide an 
    # api to request token from the server directly. (It should not be permit in product environment)
    # from owt.utils import create_token_from_owt_demo
    # token = await create_token_from_owt_demo(url, user_name, role, room=room)
    conference = await client.join(token)
    # To publish, you need a LocalStream. 
    # To create a localStream, you need a MediaStreamTrack
    # which is the class of package aiortc. 
    # So you can find document of how to create a MediaStreamTrack
    # from https://github.com/aiortc/aiortc.
    # Here I provide a simple way to create it:
    stream = create_local_tracks('file', Path.join(Path.dirname(__file__), 'fixtures/video.mp4'))
    # You can add some custom attribute to the stream. After published, 
    # another endpoint will accept it and using it to distinguish the stream.
    stream.attributes = {
        'tag': 'test-video',
        'origin': stream.id,
    }
    # now publish it.
    pub = await client.publish(stream)
    # Though after the method publish returned, the publication is completed. 
    # you may not accept the new remote stream 
    # (Of course you can subscribe the stream you published)
    # immediately. Here I provide an api to wait it.
    remote_stream = await client.wait_for_stream(lambda st: st.attributes.get('origin') == local_stream.id, timeout=10)
    # now you can subscribe the video you just published
    sub = await client.subscribe(remote_stream)
    # You can read the video stream from sub.video_track()
    # or audio stream from sub.audio_track() 
    track = sub.video_track()
    # We know we just publish a video, so the video track should not be None
    assert track
    while True:
        # What's is frame is? Please see the document of [aiortc](https://github.com/aiortc/aiortc), Of course, you can convert it to numpy array.
        frame = await track.recv()
        # do something about the frame
    await sub.close()
    await pub.close()
finally:
    await client.leave()

This package is based on aiortc because it need the support of webrtc tec. And aiortc is based on pyav. So I suggest you read the document of them too.

Here is another useful api:

from owt import ConferenceClient

client = ConferenceClient()
try:
    await client.join(token)
    async def consume_stream(stream: RemoteStream):
        # first filter the stream
        if ...:
            # then subscribe it
            sub = await client.subscribe(stream)
            track = sub.video_track()
            # then process it
            while True:
                frame = await track.recv()
                ...
    # The method consume_streams will consume all the remote streams 
    # (Someone published, here someone include yourselvies.), 
    # including the stream exist and coming in in future.
    # Here timeout mean the method will wait 10 second until all the 
    # consume_stream callbacks have done and no new remote streams found.
    handle = client.consume_streams(consume_stream, timeout=10)
    # The handle will return only when all your consume_stream callbacks
    # have done and no new remote streams found for 10 seconds.
    await handle.wait()
finally:
    # leave the conference will automatically close all the 
    # related publications and subscribations
    await client.leave()

Metadata

Release files for owt 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for owt 0.1.9
File Size Uploaded
owt-0.1.9.tar.gz 41.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for owt 0.1.9
File Interpreter ABI Platform
owt-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 88.9 kB

Release files / owt-0.1.9.tar.gz

Download URL owt-0.1.9.tar.gz
Size 41.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b1047cfbf69e796dc005ce1a8448d0394693869a2b6d7945b723ce1817241f25
BLAKE2b-256 checksum
How to use checksums
5f52f6d4b4afdbd30cf5f6a2ec409da62dbe866c646e56e5477df9feb906c59b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.6 Windows/10

Release files / owt-0.1.9-py3-none-any.whl

Download URL owt-0.1.9-py3-none-any.whl
Size 47.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f89bd287ff3dbb0dae1f04cbc9b7d444090c6fb818d995edb43e698c3851ede8
BLAKE2b-256 checksum
How to use checksums
7f335ebbea185f5cb80ec00b13507a576a002457b5408b98f45e2bdc3bb18c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.6 Windows/10

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page