pystreaming.video package

Submodules

pystreaming.video.collect module

class pystreaming.video.collect.CollectDevice(endpoint, seed)[source]

Bases: pystreaming.video.device.Device

Create a collection device.

Binds to a zmq PULL socket and republishes through a PUSH socket.

Parameters
  • endpoint (str) – Descriptor of stream publishing endpoint.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

pystreaming.video.collect.collect_ps(*, shutdown, barrier, infd, outfd)[source]

pystreaming.video.dec module

class pystreaming.video.dec.DecoderDevice(nproc, seed, fwdbuf=False)[source]

Bases: pystreaming.video.device.Device

Create a multiprocessing frame decoder device.

Parameters
  • nproc (int) – Number of decoding processes.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

  • fwdbuf (bool, optional) – True if we forward the compressed frame. Defaults to False.

handler(timeout)[source]

Yield a package of data from the decoder pool.

Parameters

timeout (int) – Timeout period in milliseconds.

Yields

list – [arr, buf, meta, ftime, fno] or None, if timeout is reached.

recv(timeout=60000)[source]

Receive a package of data from the decoder pool.

Parameters
  • timeout (int, optional) – Timeout period in milliseconds.

  • to None to wait forever. Defaults to 60_000. (Set) –

Raises

TimeoutError – Raised when no messages are received in the timeout period.

Returns

[arr, buf, meta, ftime, fno].

Return type

list

pystreaming.video.dec.dec_ps(*, shutdown, barrier, infd, outfd, fwdbuf)[source]

pystreaming.video.device module

class pystreaming.video.device.Device(dfunc, dkwargs, nproc)[source]

Bases: object

Background running device.

Parameters
  • dfunc (function) – Function to run in background. Must have ‘shutdown’ and ‘barrier’ as arguments.

  • dkwargs (dict) – Kwargs to pass to dfunc.

  • nproc (int) – Number of background processes to launch.

start()[source]

Start background processes. Does nothing if already started.

stop()[source]

Stop background processes. Does nothing if already stopped.

pystreaming.video.dist module

class pystreaming.video.dist.DistributorDevice(tracks, endpoint, seed)[source]

Bases: pystreaming.video.device.Device

Create a multiprocessing frame distributor device.

Parameters
  • tracks (list) – List of strings, where each string describes a track.

  • endpoint (str) – Descriptor of distributor endpoint.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

pystreaming.video.dist.dist_ps(*, shutdown, barrier, infd, endpoint, tracks)[source]

pystreaming.video.enc module

class pystreaming.video.enc.EncoderDevice(nproc, seed)[source]

Bases: pystreaming.video.device.Device

Create a multiprocessing frame encoder device.

Parameters
  • nproc (int) – Number of encoding processes.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

send(frame)[source]

Send a frame to the encoder bank.

Parameters

frame (np.ndarray) – A frame of video. Send None to stop the stream.

Raises

RuntimeError – Raised if encoder processes cannot compresss frame fast enough

pystreaming.video.enc.enc_ps(*, shutdown, barrier, infd, outfd)[source]

pystreaming.video.pub module

class pystreaming.video.pub.PublisherDevice(endpoint, seed)[source]

Bases: pystreaming.video.device.Device

Create a publisher device.

Binds to a zmq PULL socket and republishes through a PUB socket.

Parameters
  • endpoint (str) – Descriptor of stream publishing endpoint.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

pystreaming.video.pub.pullpub_ps(*, shutdown, barrier, infd, outfd)[source]

pystreaming.video.req module

class pystreaming.video.req.RequesterDevice(source, track, nthread, seed)[source]

Bases: pystreaming.video.device.Device

Create a asyncio frame requester device.

Parameters
  • source (str) – Descriptor of stream endpoint.

  • track (str) – Video stream track name.

  • nthread (int) – Number of requester threads.

  • seed (str) – File descriptor seed (to prevent ipc collisions).

pystreaming.video.req.aiomain(*, shutdown, barrier, source, outfd, track, nthread)[source]
async pystreaming.video.req.aioreq(context, source, track, drain, lock)[source]
async pystreaming.video.req.stop(shutdown)[source]

pystreaming.video.sub module

class pystreaming.video.sub.SubscriberDevice(endpoint, seed)[source]

Bases: pystreaming.video.device.Device

Create a multiprocessing subscriber.

Connects to a zmq SUB socket and republishes through a PUSH socket.

Parameters
  • endpoint (str) – Descriptor of stream publishing endpoint.

  • seed (str, optional) – File descriptor seed (to prevent ipc collisions). Defaults to “”.

pystreaming.video.sub.subpush_ps(*, shutdown, barrier, infd, outfd)[source]

Module contents